oneflow.as_strided(input, size, stride, storage_offset=None)Tensor

Create a view of an existing oneflow.Tensor input with specified size, stride and storage_offset. The documentation is referenced from:

  • input (Tensor) – the input tensor.

  • size (tuple or ints) – the shape of the output tensor.

  • stride (tuple or ints) – the stride of the output tensor.

  • storage_offset (int) – the offset in the underlying storage of the output tensor


the output Tensor.

Return type


For example:

>>> import oneflow as flow

>>> input = flow.rand(2,3,5)
>>> output = flow.as_strided(input, (2,3,3), (1,2,3), 1)
>>> output.size()
oneflow.Size([2, 3, 3])