Mojo struct
EngineTensorView
A non-owning register_passable view of a tensor that does runtime type checking.
CAUTION: Make sure the source tensor outlives the view.
Implemented traitsβ
AnyType
,
Copyable
,
Movable
Methodsβ
__init__
β
__init__[type: DType](inout self: Self, tensor: Tensor[type])
Creates a non-owning view of given Tensor.
Parameters:
- βtype (
DType
): DType of the tensor.
Args:
- βtensor (
Tensor[type]
): Tensor backing the view.
data
β
data[type: DType](self: Self) -> UnsafePointer[SIMD[$0, 1], 0, 0, alignof[::AnyType,__mlir_type.!kgen.target]() if triple_is_nvidia_cuda() else 1]
Returns pointer to the start of tensor.
Parameters:
- βtype (
DType
): Expected type of tensor.
Returns:
UnsafePointer of given type.
Raises:
If the given type does not match the type of tensor.
unsafe_ptr
β
unsafe_ptr(self: Self) -> UnsafePointer[NoneType, 0, 0, alignof[::AnyType,__mlir_type.!kgen.target]() if triple_is_nvidia_cuda() else 1]
Returns type erased pointer to the start of tensor.
Returns:
UnsafePointer of invalid type.
spec
β
spec(self: Self) -> TensorSpec
Returns the spec of tensor backing the view.
Returns:
Stdlib TensorSpec of the tensor.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
π What went wrong?