Skip to main content

struct

EngineNumpyView

A register_passable view of a numpy array.

Keeps its own reference to the NumPy PythonObject, so there is no need to manually keep the Python object alive after construction.

Implemented traits

AnyType, Copyable, Movable

Methods

__init__

__init__(inout self: Self, tensor: PythonObject)

Creates a non-owning view of given numpy array.

Args:

  • tensor (PythonObject): Numpy Array backing the view.

unsafe_ptr

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

Returns type erased pointer to the start of numpy array.

Returns:

DTypePointer of given type.

dtype

dtype(self: Self) -> DType

Get DataType of the array backing the view.

Returns:

DataType of the array backing the view.

spec

spec(self: Self) -> TensorSpec

Returns the spec of numpy array backing the view.

Returns:

Numpy array spec in format of Stdlib TensorSpec.