Mojo struct
EngineTensorView
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
,
UnknownDestructibility
Methods
__init__
@implicit
__init__[type: DType](out 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) -> UnsafePointer[SIMD[type, 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) -> UnsafePointer[NoneType]
Returns type erased pointer to the start of tensor.
Returns:
UnsafePointer of invalid type.
spec
spec(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!