Skip to main content
Log in

Mojo struct

EngineNumpyView

@register_passable 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, CollectionElement, Copyable, Movable, UnknownDestructibility

Methods

__init__

__init__(out 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) -> UnsafePointer[NoneType]

Returns type erased pointer to the start of numpy array.

Returns:

UnsafePointer of given type.

dtype

dtype(self) -> DType

Get DataType of the array backing the view.

Returns:

DataType of the array backing the view.

spec

spec(self) -> TensorSpec

Returns the spec of numpy array backing the view.

Returns:

Numpy array spec in format of Stdlib TensorSpec.