array_t#

Fully qualified name: wp::array_t

template<typename T>
struct array_t#

Binary-compatible view of a Python wp.array of element type T.

Layout matches wp::array_t<T> in the native Warp runtime: T* data, T* grad, :class:shape_t shape, int strides[4], int ndim. Strides are byte strides. grad is null when the array has no gradient.

Public Functions

inline array_t()#
inline array_t(T *data, int size, T *grad = nullptr)#

Constructs a one-dimensional array view over an existing buffer.

Parameters:
  • data[in] Pointer to the first element of the buffer.

  • size[in] Number of elements in the buffer.

  • grad[in] Optional pointer to the gradient buffer, or nullptr if none.

inline bool empty() const#

Returns whether the array has no backing data.

Returns:

True if the data pointer is null; false otherwise.

inline operator T*() const#

Implicitly converts the array view to a pointer to its underlying data.

Returns:

Pointer to the first element of the array data.

Public Members

T *data#

Pointer to the first element of the array data.

T *grad#

Pointer to the gradient buffer, or null when the array has no gradient.

shape_t shape#

Per-dimension element counts of the array.

int strides[ARRAY_MAX_DIMS]#

Per-dimension byte strides between consecutive elements.

int ndim#

Number of valid dimensions in the array.