11#include <pybind11/pybind11.h>
12#include <pybind11/iostream.h>
13namespace py = pybind11;
17#define DNDS_PYBIND11_OSTREAM_GUARD py::call_guard<py::scoped_ostream_redirect, \
18 py::scoped_estream_redirect>()
27 return info.item_type_is_equivalent_to<T>();
32 bool is_contiguous =
true;
33 ssize_t stride = info.itemsize;
34 for (
int i = info.ndim - 1; i >= 0; --i)
36 if (info.strides[i] != stride)
38 is_contiguous =
false;
41 stride *= info.shape[i];
48 bool is_contiguous =
true;
49 ssize_t stride = info.itemsize;
50 for (
int i = 0; i < info.ndim; ++i)
52 if (info.strides[i] != stride)
54 is_contiguous =
false;
57 stride *= info.shape[i];
73 return {info.size, style};
79 return py::memoryview::from_buffer<T>(
89 .def(
"_get_UnInitReal", []()
91 .def(
"_get_UnInitIndex", []()
93 .def(
"_get_UnInitRowsize", []()
101 m.def(
"omp_set_num_threads", [](
int n)
102 { omp_set_num_threads(
n); });
Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
#define DNDS_assert_info(expr, info)
Debug-only assertion with an extra std::string info message.
the host side operators are provided as implemented
DNDS_CONSTANT const index UnInitIndex
Sentinel "not initialised" index value (= INT64_MIN).
py::classh< T > py_class_ssp
std::tuple< ssize_t, char > py_buffer_get_contigious_size(const py::buffer_info &info)
DNDS_CONSTANT const real UnInitReal
Sentinel "not initialised" real value (NaN). Cheap to detect with std::isnan or IsUnInitReal; survive...
void pybind11_bind_defines(py::module_ &m)
bool py_buffer_is_contigious_c(const py::buffer_info &info)
bool py_buffer_contains_T(const py::buffer_info &info)
py::memoryview py_vector_as_memory_view(std::vector< T > &vec, bool readonly)
DNDS_CONSTANT const rowsize UnInitRowsize
Sentinel "not initialised" rowsize value (= INT32_MIN).
bool py_buffer_is_contigious_f(const py::buffer_info &info)
Eigen::Vector3d n(1.0, 0.0, 0.0)