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
test_obj – Python object to test
- Returns
true The object is a cupy array
- Returns
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
tensor –
- Returns
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
cupy_array –
- Returns
-
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
cupy_tensors –
- Returns
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
tensors –
- Returns
py_tensor_map_t
-
using tensor_map_t = std::map<std::string, TensorObject>