PyTorch torch.empty_strided Function


Pytorch torch 参考手册Pytorch torch Reference Manual

torch.empty_stridedIt is a function in PyTorch for creating an uninitialized tensor with a specified stride.

Function Definition

torch.empty_strided(size, stride, dtype=None, device=None, requires_grad=False)

Usage Example

Example

import torch

# Create a tensor of shape (3, 4) with stride (1, 3)
x = torch.empty_strided((3, 4), (1, 3))

print(x)
print("Shape:", x.shape)
print("Stride:", x.stride())
print("Note: The values are uninitialized memory values")

Pytorch torch 参考手册Pytorch torch Reference Manual

Other Extensions