Skip to content

pyncarray

Return Name Description
NCA_PYNCARRAY_API void set_eager
NCA_PYNCARRAY_API bool is_eager
bool is_nc_array inline
bool needs_device_vm inline
void _build_node_helper
py::object eval_python_expr
void register_expr_class
void register_common_array_methods Helper function to attach common methods to a Python binding for an array specialization.
auto host_dispatch inline This is a duplicate dispatch to that in ncarry/array_impl.hh but host only. The original needs to be host/device, so we get a lot of spurious warnings.
ncarray::DType pydtype_to_dtype inline Cast a pybind11 array dtype to a ncarray::DType.
auto pyarray_to_view inline Construct a view over a NumPy array.
ncarray::ArrayImpl< LayoutT, RefT > pyarray_to_ref inline Construct a reference type array from an array of arrays.
ncarray::ArrayImpl< LayoutT, RefT > pylist_to_ref inline Construct a reference type array from a list of arrays.
py::array ncarr_to_numpy inline Construct a NumPy array from an input nc/soarray type object.
ncarray::Slice pyslice_to_slice inline
std::vector< ncarray::IndexItem > pytuple_to_indices inline

NCA_PYNCARRAY_API void set_eager(bool eager)

NCA_PYNCARRAY_API bool is_eager()

inline

template<class LPolicy, class MemType> inline bool is_nc_array(const py::handle & val)

inline

inline bool needs_device_vm(const py::handle & node)

template<typename MemType> void _build_node_helper(ncarray::ExprMVNode< MemType > & self, py::object other)

template<typename MemType> py::object eval_python_expr(const py::object & pyexpr)

template<typename MemType> void register_expr_class(py::module_ & m, const std::string & name)

template<typename ArrayT> void register_common_array_methods(py::classh< ArrayT > & arr_cl)

Helper function to attach common methods to a Python binding for an array specialization.

All array specializations generally have the same functions in C++ and in their Python bindings (plus/minus some speciality features). This function just attaches those all.

  • ArrayT The kind of array being used. This is a full array specifier, including storage+layout specifier.
  • arr_cl The class of the Python binding.

inline

template<typename Visitor> inline auto host_dispatch(ncarray::DType type, Visitor && visitor)

This is a duplicate dispatch to that in ncarry/array_impl.hh but host only. The original needs to be host/device, so we get a lot of spurious warnings.

We do NOT want to just silence the warning (e.g. pragma diag_suppress 20014) for nvcc as we want to catch other instances of host/device called from host.


inline

inline ncarray::DType pydtype_to_dtype(py::dtype dtype)

Cast a pybind11 array dtype to a ncarray::DType.

  • dtype The pybind11 datatype.

The ncarray datatype.


inline

template<class ViewType> inline auto pyarray_to_view(const py::array & arr, ssize_t target_ndim = -1)

Construct a view over a NumPy array.

  • ViewType The kind of view to construct. E.g. NCArrayView, SOArrayView.
  • arr An input NumPy array to convert.

  • target_ndim The target dimensionality of the output with padding. TODO: This mostly serves as a hack until broadcasting is suppported. Because of the implicit dimensionality mismatch between NCArrays* and NumPy….

A view of ViewType over the data from the NumPy array.


inline

template<class LayoutT, class RefT = ncarray::RefPolicy> inline ncarray::ArrayImpl< LayoutT, RefT > pyarray_to_ref(const py::array & arr, const bool read_only_ = false)

Construct a reference type array from an array of arrays.

NOTE: This function assumes the arrays in the array all have the same shape and strides.

  • LayoutT The layout specifier for the returned reference type. E.g., NCOffsetsPolicy or SOArrayPolicy (PEP3118).

  • RefT The reference storage specifier. E.g. RefPolicy or DevRefPolicy.

  • arr The input array of arrays.

  • read_only_ Whether this reference should be read only.

The constructed reference type.


inline

template<class LayoutT, class RefT = ncarray::RefPolicy> inline ncarray::ArrayImpl< LayoutT, RefT > pylist_to_ref(const py::list & list, const bool read_only_ = false)

Construct a reference type array from a list of arrays.

NOTE: This function assumes the arrays in the list all have the same shape and strides.

  • LayoutT The layout specifier for the returned reference type. E.g., NCOffsetsPolicy or SOArrayPolicy (PEP3118).

  • RefT The reference storage specifier. E.g. RefPolicy or DevRefPolicy.

  • list The input list of arrays.

  • read_only_ Whether this reference should be read only.

The constructed reference type.


inline

template<class ArrayT> inline py::array ncarr_to_numpy(const ArrayT & ncarr, std::optional< ncarray::DType > dtype = std::nullopt)

Construct a NumPy array from an input nc/soarray type object.

  • ArrayT The kind of array being used. This is a full array specifier, including storage+layout specifier.
  • ncarr The input array to convert.

  • dtype The datatype for the converted NumPy array. I.e., if provided a cast will be performed. Otherwise, the input array dtype will be used.

A NumPy array of specified dtype over the input data.


inline

inline ncarray::Slice pyslice_to_slice(ssize_t axis_shape, py::slice slice)

inline

template<class ArrayT> inline std::vector< ncarray::IndexItem > pytuple_to_indices(const ArrayT & self, py::tuple tup)
Return Name Description
NCA_PYNCARRAY_API bool g_eager_eval Global toggle for whether Python will eagerly convert Expr objects to arrays.

NCA_PYNCARRAY_API bool g_eager_eval = true

Global toggle for whether Python will eagerly convert Expr objects to arrays.