#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <array>
#include <cstring>
#include <Kokkos_Core.hpp>
#include <stdexcept>
#include <type_traits>
#include <utility>
#include <vector>
#include "peclet/core/common/view.hpp"
#include "peclet/core/python/kokkos_teardown.hpp"
Go to the source code of this file.
|
| template<class MemorySpace > |
| std::pair< int, int > | peclet::core::python::dlpack_device () |
| | Map a Kokkos memory space to a DLPack {device_type, device_id} pair.
|
| |
| template<class T > |
| void | peclet::core::python::require_dtype (const nb::ndarray<> &a, const char *who) |
| | Throw if a's element type is not T.
|
| |
| template<class V , std::size_t N> |
| auto | peclet::core::python::view_to_ndarray (const V &view, const std::array< std::size_t, N > &shape, const std::array< std::int64_t, N > &strides) |
| | Export a Kokkos View to a Python array without copying, with an explicit logical shape and element-unit strides over the View's memory (e.g.
|
| |
| template<class V > |
| auto | peclet::core::python::view_to_ndarray (const V &view) |
| | Export a Kokkos View to a Python array without copying.
|
| |
| template<class T > |
| nb::ndarray< nb::numpy, T > | peclet::core::python::vector_to_ndarray (std::vector< T > &&v, std::initializer_list< std::size_t > shape, std::initializer_list< std::int64_t > strides) |
| | Export a host std::vector<T> as a NumPy array of the given logical shape and element-unit strides, without the extra copy the old to_xyz made: the vector is moved into a capsule that backs the array.
|
| |
| template<class T > |
| peclet::core::View< T > | peclet::core::python::ndarray_to_view (const nb::ndarray<> &a, const std::string &label) |
| | Import a (contiguous) Python array into a freshly-allocated flat device peclet::core::View<T>.
|
| |
| template<class T > |
| std::vector< T > | peclet::core::python::ndarray_to_vector (const nb::ndarray<> &a) |
| | Import a (contiguous) Python array into a host std::vector<T>.
|
| |