Rate this Page

Function torch::stable::from_blob(void *, torch::headeronly::IntHeaderOnlyArrayRef, torch::headeronly::IntHeaderOnlyArrayRef, torch::stable::Device, torch::headeronly::ScalarType, int64_t, torch::headeronly::Layout)#

Function Documentation#

inline torch::stable::Tensor torch::stable::from_blob(void *data, torch::headeronly::IntHeaderOnlyArrayRef sizes, torch::headeronly::IntHeaderOnlyArrayRef strides, torch::stable::Device device, torch::headeronly::ScalarType dtype, int64_t storage_offset = 0, torch::headeronly::Layout layout = torch::headeronly::Layout::Strided)#

Creates a tensor from an existing data blob.

Creates a tensor that uses the provided data pointer as its storage. The tensor does not own the data, so the caller must ensure the data remains valid for the lifetime of the tensor.

Minimum compatible version: PyTorch 2.10.

Parameters:
  • data – Pointer to the data buffer.

  • sizes – The size of each dimension of the tensor.

  • strides – The stride for each dimension.

  • device – The device where the data resides.

  • dtype – The scalar type of the data.

  • storage_offset – The offset into the data buffer. Defaults to 0.

  • layout – The memory layout. Defaults to Strided.

Returns:

A tensor backed by the provided data.