Mojo 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) -> 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 numpy array.
Returns:
UnsafePointer 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.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
If you'd like to share more information, please report an issue on GitHub
😔 What went wrong?