Skip to main content

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 tensor: Tensor[type]) -> Self

Creates a non-owning view of given Tensor.

Parameters:

  • type (DType): DType of the tensor.

Args:

  • tensor (Tensor[type]): Tensor backing the view.

Returns:

An instance of EngineTensorView of given tensor.

data

data[type: DType](self: Self) -> DTypePointer[$0, 0]

Returns pointer to the start of tensor.

Parameters:

  • type (DType): Expected type of tensor.

Returns:

DTypePointer of given type.

Raises:

If the given type does not match the type of tensor.

data(self: Self) -> DTypePointer[invalid, 0]

Returns type erased pointer to the start of tensor.

Returns:

DTypePointer of invalid type.

spec

spec(self: Self) -> TensorSpec

Returns the spec of tensor backing the view.

Returns:

Stdlib TensorSpec of the tensor.