Struct CupyUtil
Defined in File cupy_util.hpp
-
struct CupyUtil
Structure that encapsulates cupy utilities.
Public Types
- using tensor_map_t = std::map<std::string, TensorObject>
- using py_tensor_map_t = std::map<std::string, pybind11::object>
Public Static Functions
-
static pybind11::module_ get_cp()
Import and return the cupy module. Requires GIL to have already been aqcuired.
- Returns
pybind11::module_
-
static bool is_cupy_array(pybind11::object test_obj)
Tests whether or not an object is an instance of
cupy.ndarray
- Parameters
- Returns
- Returns
test_obj – Python object to test
true The object is a cupy array
false The object is not a cupy array
-
static pybind11::object tensor_to_cupy(const TensorObject &tensor)
Convert a TensorObject to a CuPy array. Requires GIL to have already been aqcuired.
- Parameters
- Returns
tensor –
pybind11::object
-
static TensorObject cupy_to_tensor(pybind11::object cupy_array)
Convert a CuPy array into a TensorObject. Requires GIL to have already been aqcuired.
- Parameters
- Returns
cupy_array –
-
static tensor_map_t cupy_to_tensors(const py_tensor_map_t &cupy_tensors)
Convert a map of CuPy arrays into a map of TensorObjects. Requires GIL to have already been aqcuired.
- Parameters
- Returns
cupy_tensors –
tensor_map_t
-
static py_tensor_map_t tensors_to_cupy(const tensor_map_t &tensors)
Convert a map of TensorObjects into a map of CuPy arrays. Requires GIL to have already been aqcuired.
- Parameters
- Returns
tensors –
py_tensor_map_t
Public Static Attributes
- static pybind11::object cp_module = pybind11::none()