PyTorch torch.empty_strided function
PyTorch torch reference manual
torch.empty_strided is a PyTorch function for creating an uninitialized tensor with a specified stride.
Function definition
torch.empty_strided(size, stride, dtype=None, device=None, requires_grad=False)
Usage examples
Example
import
torch
Create a tensor with shape (3, 4) and stride (1, 3)
x
=
torch.
empty_strided
(
(
3
,
4
)
,
(
1
,
3
)
)
(
x
)
(
"Shape:"
,
x.
shape
)
(
"Stride:"
,
x.
stride
(
)
)
(
"Note: values are uninitialized memory values"
)