Skip to content

ncarray

Name Description
ArrayImpl The ArrayImpl provides the mean entry point for all array types. It is a templated class inheriting from Layout and Storage classes, allowing it to be customized to different kinds of array setups. E.g. suboffsets and NCArray style classes are both accessed via the ArrayImpl.
index_error
Stencil A Stencil for defining expressions over an array with determined offsets.
type_error
AllTraits Traits to find minima along axes.
AnyTraits Traits to find minima along axes.
ArgmaxTraits Traits to find the indices of maxima along axes.
ArgminTraits Traits to find the indices of minima along axes.
ArrayElementProxy The element proxy can be returned by arrays during indexing to provide reference based access to the underlying data.
AxisDescr A description of an axis of an array. This struct can be used for creation of new views.
BaseOpTraits Numeric traits for specifying types during arithmetic as well as providing operations for types that don’t have them, or overriding their default behaviour.
concat A struct for concatenating type_lists together.
concat< List >
concat< type_list< Ts... >, type_list< Us... >, Rest... >
DevDeleter
DevOwnerPolicy
DevRefPolicy
DevTag
DevViewPolicy
Double2 A 2-double (double precision) vector data type.
Double3 A 3-double (double precision) vector data type.
Double4 A 4-double (double precision) vector data type.
dtype_traits A small struct that maps a type to the DType enumerator via the value member.
DynamicExprMVNode
Ellipsis An empty struct indicating skipped axes when indexing an array.
ExpressionTag
ExprMVNode A multi-view array expression builder.
ExprOpInterface
FixedMetadata For simplifying CPU/GPU compatibility, STL containers are replaced with a fixed struct for expressing metadata surrounding arrays. E.g. shape and strides information. Currently, ncarray supports up to 10 dimensions in an array.
Float2 A 2-float (single precision) vector data type.
Float3 A 3-float (single precision) vector data type.
Float4 A 4-float (single precision) vector data type.
HostDeleter
HostEngine The HostEngine is ultimately responsible for dispatching all operations involving arrays on the host/CPU. This includes binary operations, reductions, unary operations, copies, assignments, fills and so on.
HostTag
IndexItem A generic indexing argument with a tag indicating the type to be used.
is_exprmv_node
is_exprmv_node< ExprMVNode< MemTag > >
is_in_list Struct for testing presence of a type in a type_list.
is_in_list< T, type_list< Ts... > >
is_layout_policy Type-trait style struct for the IsLayoutPolicy concept default falsey specialization.
is_layout_policy< LayoutPolicy< D > > Type-trait style struct for the IsLayoutPolicy concept true specialization.
is_ncoffsets_policy Type-trait style struct for whether NCOffsetsPolicy default false specialization.
is_ncoffsets_policy< NCOffsetsPolicy > Type-trait style struct for whether NCOffsetsPolicy true specialization.
is_soarray_policy Type-trait style struct for whether SOArrayPolicy default false specialization.
is_soarray_policy< SOArrayPolicy > Type-trait style struct for whether SOArrayPolicy true specialization.
KeyValPair A small struct for holding a key and value.
LayoutPolicy The LayoutPolicy dictates the overall organization of an array object. E.g. if it has offsets or suboffsets.
list_dispatcher A dispatch engine for matching a DType to the underlying type and running a function.
list_dispatcher< type_list< T, Ts... > >
list_dispatcher< type_list<> >
MaxTraits Traits to find maxima along axes.
MeanTraits
MemTag
MinTraits Traits to find minima along axes.
NCOffsetsPolicy The NCOffsetsPolicy provides an additional offsets attribute and allows for a single pointer axis.
op_traits
op_traits< bool >
op_traits< complex< T > >
op_traits< Double2 >
op_traits< Double3 >
op_traits< Double4 >
op_traits< Float2 >
op_traits< Float3 >
op_traits< Float4 >
op_traits< int16_t >
op_traits< int8_t >
op_traits< uint16_t >
op_traits< uint8_t >
OwnerPolicy The OwnerPolicy dictates an array that manages its own buffer for the memory that backs the array.
OwnerTag
Reducer A wrapping class for reduction traits.
ReductionParams A struct to define mapping requirements when performing axis-aware reductions.
RefPolicy The RefPolicy dictates arrays which hold pointers to the individual components of the array.
RefTag
Slice A struct representing a slice for indexing by a step between a start and stop index.
SOArrayPolicy The SOArrayPolicy implements PEP3118 compliance with the addition of a suboffsets field.
StaticCoords A small struct with compile-time constant size for indexing arrays.
StaticExprMVNode
StdTraits Traits to find the standard deviation along axes.
StoragePolicy The StoragePolicy specifies the storage class for the array in question. E.g., a view type array holds no memory, while an owning type does.
StoragePolicyTraits
StoragePolicyTraits< DevTag >
StoragePolicyTraits< HostTag >
SumTraits Traits for a summation along axes.
type_list Basic type list.
VarAccumulator An accumulator used for the calculation of variance and standard deviation.
VarTraits Traits to find the variance along axes.
ViewPolicy The ViewPolicy dictates arrays that have only a view of the data.
ViewTag
wrap_list A helper struct to wrap a templated class.
wrap_list< Wrapper, type_list< Ts... > >
Name Description
DType The main identifier for the ncarray type system. The DType determines array element type.
IndexType A tag identifier for the type of indexing argument when constructing lists of args.
OpCode OpCodes indicate types of operations or expressions.

enum DType

The main identifier for the ncarray type system. The DType determines array element type.

Value Description
bool_ Boolean type.
char_ char type (signed 8-bit)
uint8 8-bit unsigned integer
uint16 16-bit unsigned integer
uint32 32-bit unsigned integer
uint64 64-bit unsigned integer
int8 8-bit signed integer
int16 16-bit signed integer
int32 32-bit signed integer
int64 64-bit signed integer
float32 single precision float
float64 double precision float
float128 equivalent to long double
complex64 complex
complex128 complex
complex256 complex
vfloat2 2-float vector type (Float2)
vfloat3 3-float vector type (Float3)
vfloat4 4-float vector type (Float4)
vdouble2 2-double vector type (Double2)
vdouble3 3-double vector tyep (Double3)
vdouble4 4-double vector type (Double4)

enum IndexType

A tag identifier for the type of indexing argument when constructing lists of args.

Value Description
Integer
Slice
Ellipsis

enum OpCode

OpCodes indicate types of operations or expressions.

When interfacing with Python these are used for the virtual machine. In normal C++ usage, they are used by the various BinaryExpr/UnaryExpr and so on.

All supported operations (add, subtract, etc.) are included here, in addition to the necessary codes to indicate loading/retrieval of the operands (arrays, or constant scalars)

Value Description
NOOP Null op.
IDX Index generator (Like APL)
LOAD_NCARR Load an NCArray (VM only)
LOAD_SOARR Load an SOArray (VM only)
LOAD_CONST Load a constant (VM only)
NEG Negative.
INC Increment.
DEC Decrement.
SZOF Size of.
ADDR Address of.
INDR Indirection/dereference.
CAST Cast.
LNOT Logical not.
BNOT Bitwise not.
ADD Addition.
SUB Subtraction.
MUL Multiplication.
DIV True division.
MOD Modulo.
FDIV Floor (integer) division.
EQ Equal to.
NE Not equal.
LT Less than.
LE Less than or equal.
GT Greater than.
GE Greater than or equal.
LAND Logical and.
LOR Logical or.
BAND Bitwise and (&)
BOR Bitwise or (
XOR Bitwise XOR (^)
LSHFT Left shift (<<)
RSHFT Right shift (>>)
Return Name Description
ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::View > NCViewFor
ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::Ref > NCRefFor
ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::Owner > NCOwnerFor
ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::View > SOViewFor
ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::Ref > SORefFor
ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::Owner > SOOwnerFor
std::variant< bool, char, uint8_t, uint16_t, uint32_t, uint64_t, int8_t, int16_t, int32_t, int64_t, float, double, long double, complex< float >, complex< double >, complex< long double >, Float2, Float3, Float4, Double2, Double3, Double4 > Scalar The set of scalar types used by ncarray - one for each DType.
type_list< bool, char, uint8_t, uint16_t, uint32_t, uint64_t, int8_t, int16_t, int32_t, int64_t, float, double, long double, complex< float >, complex< double >, complex< long double >, Float2, Float3, Float4, Double2, Double3, Double4 > base_types All supported base datatypes in ncarray.
typename concat< Lists... >::type concat_t The full type of a set of type_lists concatenated with concat.
typename wrap_list< VarAccumulator, base_types >::type accumulator_types
KeyValPair< ssize_t, T > IndexedKVP The KeyValPair type used for reductions in ncarray.
typename wrap_list< IndexedKVP, base_types >::type keyval_types
type_list< long, unsigned long, long long, unsigned long long > device_int_compat_types Provide supporting types for the ArrayElementProxy restricted conversion operators.
concat_t< base_types, accumulator_types, keyval_types, device_int_compat_types > all_supported_types The set of all types in ncarray, including accumulators and the base dtypes.
FixedMetadata< ssize_t > Metadata By default, Metadata will use ssize_t which is compatible with the conventions used in many places for a signed integer to describe shapes, strides, suboffsets and so on.
ArrayImpl< NCOffsetsPolicy, ViewPolicy > NCArrayView
ArrayImpl< NCOffsetsPolicy, RefPolicy > NCArrayRef
ArrayImpl< NCOffsetsPolicy, OwnerPolicy > NCArray
uint32_t Instruction Instructions for the virutal machine are stored in a packed format in 32 bit ints.
ArrayImpl< SOArrayPolicy, ViewPolicy > SOArrayView
ArrayImpl< SOArrayPolicy, RefPolicy > SOArrayRef
ArrayImpl< SOArrayPolicy, OwnerPolicy > SOArray

using NCViewFor = ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::View >

using NCRefFor = ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::Ref >

using NCOwnerFor = ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::Owner >

using SOViewFor = ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::View >

using SORefFor = ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::Ref >

using SOOwnerFor = ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::Owner >

using Scalar = std::variant< bool, char, uint8_t, uint16_t, uint32_t, uint64_t, int8_t, int16_t, int32_t, int64_t, float, double, long double, complex< float >, complex< double >, complex< long double >, Float2, Float3, Float4, Double2, Double3, Double4 >

The set of scalar types used by ncarray - one for each DType.


using base_types = type_list< bool, char, uint8_t, uint16_t, uint32_t, uint64_t, int8_t, int16_t, int32_t, int64_t, float, double, long double, complex< float >, complex< double >, complex< long double >, Float2, Float3, Float4, Double2, Double3, Double4 >

All supported base datatypes in ncarray.

This includes basic C++ types, complex numbers and vector types.


using concat_t = typename concat< Lists... >::type

The full type of a set of type_lists concatenated with concat.


using accumulator_types = typename wrap_list< VarAccumulator, base_types >::type

using IndexedKVP = KeyValPair< ssize_t, T >

The KeyValPair type used for reductions in ncarray.


using keyval_types = typename wrap_list< IndexedKVP, base_types >::type

using device_int_compat_types = type_list< long, unsigned long, long long, unsigned long long >

Provide supporting types for the ArrayElementProxy restricted conversion operators.

Due to differences in definitions of fixed-width ints on host and device (std, vs cuda::std), the ArrayElementProxy concept on the operator T& may delete needed operators inside kernels. This type_list adds back the requisite types.


using all_supported_types = concat_t< base_types, accumulator_types, keyval_types, device_int_compat_types >

The set of all types in ncarray, including accumulators and the base dtypes.


using Metadata = FixedMetadata< ssize_t >

By default, Metadata will use ssize_t which is compatible with the conventions used in many places for a signed integer to describe shapes, strides, suboffsets and so on.


using NCArrayView = ArrayImpl< NCOffsetsPolicy, ViewPolicy >

using NCArrayRef = ArrayImpl< NCOffsetsPolicy, RefPolicy >

using NCArray = ArrayImpl< NCOffsetsPolicy, OwnerPolicy >

using Instruction = uint32_t

Instructions for the virutal machine are stored in a packed format in 32 bit ints.

The op code (e.g. ADD, LOAD_ARRAY etc) is stored in the lower 8 bits. The index of the operand in the VM’s stack is in the remaining bits.


using SOArrayView = ArrayImpl< SOArrayPolicy, ViewPolicy >

using SOArrayRef = ArrayImpl< SOArrayPolicy, RefPolicy >

using SOArray = ArrayImpl< SOArrayPolicy, OwnerPolicy >
Return Name Description
std::vector< ssize_t > calculate_c_order_strides inline Calculate the strides for a standard C-order (row-major) contiguous array of given shape.
std::vector< ssize_t > calculate_c_order_strides inline Calculate the strides for a standard C-order (row-major) contiguous array of given shape.
NCA_HD void calculate_c_order_strides inline Calculate the strides for a standard C-order (row-major) contiguous array of given shape.
auto promote_to_so Convert an NCOffsets array to an SOArray.
NCA_HDArrayElementProxy static_index inline Given a linearized index and array, construct a StaticCoords object to index.
ReductionParams build_reduction_params inline Setup a small struct with strides, offsets and masks for reducing axes.
std::ostream & operator<< A formatting helper for printing vector datatypes.
NCA_HD T nca_sqrt inline A helper for setting up square roots on various types.
NCA_HD size_t itemsize inline Returns the size in bytes of the provided DType.
std::string to_string inline Returns the string representation of the DType for printing.
Scalar to_scalar Convert a pointer to an array element to a Scalar.
NCA_HD auto dispatch_integers inline A restricted dispatcher for integer types. This is useful when using arrays to hold indices for other arrays.
NCA_HD auto dispatch inline Dispatch a visitor/lambda based on DType.
size_t bytes_for_dynamic_vm inline
DynamicExprMVNode< MemTag > get_dynamic_mv_node inline
DType promote_expr_types inline The enum DTypes are already ordered. For expressions’ working dtype, promote to the numerically larger. The final value is determined using op_traits.
bool can_linearize
std::string hash_to_hex
std::string get_arch_opt
fs::path get_cache_dir Get the cache directory for the system.
std::string get_install_library_path Return the path to the currently loaded JIT shared library.
std::string get_install_include_path Return the path to the include headers for ncarray relative to the shared library.
std::string read_file Read a file at the provided path. The entire contents are returned in a string.
void * read_bin_file_to_exec_mem Read a binary file at the provided path into executable memory.
void write_file Write a file to the provided path.
void write_file Write a binary object to the provided path.
NCA_HDDType determine_dtype_for_op inline For a specific operation and input datatype determine the correct result dtype.
NCA_HD uint32_t pack_instruction inline Pack an op code and an operand index into a single VM instruction.
NCA_HDOpCode get_op inline From a packed instruction retrieve the op code.
NCA_HD int get_index inline From a packed instruction retrieve the operand stack index.
str get_include
str get_lib_dir
lazy_mode Context manager to delay immediate evaluation of results.

inline

inline std::vector< ssize_t > calculate_c_order_strides(const std::vector< ssize_t > & shape, const ssize_t itemsize)

Calculate the strides for a standard C-order (row-major) contiguous array of given shape.

  • shape The shape to calculate strides for.

  • itemsize The size in bytes of a single element of the array.

The C-order calculated strides.


inline

inline std::vector< ssize_t > calculate_c_order_strides(const ssize_t ndim, const ssize_t * shape, const ssize_t itemsize)

Calculate the strides for a standard C-order (row-major) contiguous array of given shape.

  • The number of dimensions in the array.

  • shape The shape to calculate strides for (pointer to first element).

  • itemsize The size in bytes of a single element of the array.

The C-order calculated strides.


inline

inline NCA_HD void calculate_c_order_strides(const ssize_t ndim, const ssize_t * shape, const ssize_t itemsize, ssize_t * new_strides)

Calculate the strides for a standard C-order (row-major) contiguous array of given shape.

  • The number of dimensions in the array.

  • shape The shape to calculate strides for (pointer to first element).

  • itemsize The size in bytes of a single element of the array.

  • strides The C-order calculated strides will be output in this pointer.


template<typename MemTag> auto promote_to_so(const ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemTag >::View > & nc)

Convert an NCOffsets array to an SOArray.

For convenience the function will consume all offsets in the NCOffsetsArray. All suboffsets should then be -1 or 0.

  • [MemTag](api-ncarray-MemTag.md#memtag) The tag indicating whether array is host- or device-resident.
  • nc The NCArray* to be converted to SOArray*.

The SOArray* equivalent to the input nc array.


inline

template<class Array> inline NCA_HDArrayElementProxy static_index(Array arr, unsigned idx)

Given a linearized index and array, construct a StaticCoords object to index.

Because the StaticCoords object has a constexpr size, using it for indexing as opposed to linearized indices can have major performance benefits, particularly for device code applications. E.g., the constexpr size generally allows loops to be fully unrolled, and stack spilling to be avoided in compiled kernels.

This routine simply converts the linearized ravel index to a StaticCoords object of the correct dimensionality of the array, using a switch dispatch.

  • Array The type of the input array.
  • arr The input array.

  • idx The linearized ravel index.

The ArrayElementProxy to the requested data element.


inline

inline ReductionParams build_reduction_params(const std::vector< ssize_t > & axes, ssize_t arr_ndim, const ssize_t * in_shape, const ssize_t * in_strides, ssize_t(&) new_shape, ssize_t & new_ndim, ssize_t itemsize, double ddof = 0.0)

Setup a small struct with strides, offsets and masks for reducing axes.

  • axes The user-requested axes that willbe reduced.

  • arr_ndim The number of dimensions (axes) in the array currently.

  • in_shape The shape of the axes in the array.

  • in_strides The strides of the axes in the array in ELEMENTS (not bytes).

  • new_shape The new shape for the array following reduction.

  • new_ndim The number of dimensions after reduction.

  • itemsize The size in bytes of the array elements data type.

  • ddof The delta degrees of freedom – only passed through to var/std reductions.

params The reduction parameter table.


template<Vector2DType T> std::ostream & operator<<(std::ostream & oss, const T & vec)

A formatting helper for printing vector datatypes.

  • T The input datatype, requires at least Vector2DType.
  • oss The stream to write the contents to.

  • vec The vector data type to print to the stream.


inline

template<typename T> inline NCA_HD T nca_sqrt(const T & val)

A helper for setting up square roots on various types.

  • T The datatype of the value to take the square root of.
  • val The value to take the square root of.

The square root overload for handling the elementwise square-root of vector types.

  • T The datatype of the value to take the square root of, requires at least Vector2DType.
  • val The vector value to take the elementwise square root of.

inline

inline NCA_HD size_t itemsize(DType type)

Returns the size in bytes of the provided DType.

Todo: Formally enforce these guarantees. This should be correct in all currently supported use cases – but its not guaranteed. The fixed sizes listed here need to be handled (via whatever types required) in the event they are not satisfied in a particular case/on a particular platform.

  • type The input DType.

The size in bytes.


inline

inline std::string to_string(DType type)

Returns the string representation of the DType for printing.

  • type The input DType.

The string representation of the data type.


template<typename T> Scalar to_scalar(const void * ptr)

Convert a pointer to an array element to a Scalar.

  • T The underlying type of the array element.
  • ptr The pointer to the array element.

The Scalar wrapper.


inline

template<typename Visitor> inline NCA_HD auto dispatch_integers(DType type, Visitor && visitor)

A restricted dispatcher for integer types. This is useful when using arrays to hold indices for other arrays.


inline

template<typename Visitor> inline NCA_HD auto dispatch(DType type, Visitor && visitor)

Dispatch a visitor/lambda based on DType.

This function dispatches only on the base_types (this controls combinatorial explosion to some degree). In certain places, broader dispatching may be desired. In that case, using list_dispatcher directly with specialized type lists can be done instead.

  • Visitor The type of the visitor to be dispatched based on DType.
  • type The DType to use for dispatching.

  • visitor The lambda visitor.

Whatever is returned by the visitor.


inline

template<typename MemTag> inline size_t bytes_for_dynamic_vm(const ExprMVNode< MemTag > & node, size_t alignment = 16)

inline

template<typename MemTag> inline DynamicExprMVNode< MemTag > get_dynamic_mv_node(const ExprMVNode< MemTag > & node, uint8_t * h_ptr, uint8_t * d_ptr = nullptr, size_t alignment = 16)

inline

inline DType promote_expr_types(DType a, DType b)

The enum DTypes are already ordered. For expressions’ working dtype, promote to the numerically larger. The final value is determined using op_traits.


template<class MemTag> bool can_linearize(const ExprMVNode< MemTag > & node)

std::string hash_to_hex(const std::string & input)

std::string get_arch_opt()

fs::path get_cache_dir()

Get the cache directory for the system.

Uses XDG_CACHE_HOME on Linux if set, or LOCALPPDATA on Windows.


std::string get_install_library_path()

Return the path to the currently loaded JIT shared library.


std::string get_install_include_path()

Return the path to the include headers for ncarray relative to the shared library.


std::string read_file(fs::path file_path)

Read a file at the provided path. The entire contents are returned in a string.

  • file_path The path to read.

contents The file contents as a string. Empty if there was an error.


void * read_bin_file_to_exec_mem(fs::path file_path)

Read a binary file at the provided path into executable memory.

  • file_path The path to read.

contents The data loaded into executable memory.


void write_file(fs::path file_path, const std::string & contents)

Write a file to the provided path.

  • file_path The path to write to.

  • contents The file contents to write out.


void write_file(fs::path file_path, std::size_t k_size, const std::uint8_t * k_data)

Write a binary object to the provided path.

  • file_path The path to write to.

  • k_size Number of bytes to write.

  • k_data Pointer to the start of the data to write.


inline

inline NCA_HDDType determine_dtype_for_op(OpCode code, DType left)

For a specific operation and input datatype determine the correct result dtype.

[op_traits](api-ncarray-op_traits.md#op_traits) define certain semantics for type promotion or conversion depending on the operation being performed. E.g. to avoid frequent overflows very small integers (uint8, uint16) will be promoted to larger ones. The output datatype for an ADD operation for uint8 will then be uint64 (int8 -> int64).

  • code The op code for this operation.

  • left The datatype of the leftmost operand.

  • res_dtype The appropriate output datatype for the operation.


inline

inline NCA_HD uint32_t pack_instruction(OpCode op, int idx)

Pack an op code and an operand index into a single VM instruction.


inline

inline NCA_HDOpCode get_op(Instruction instr)

From a packed instruction retrieve the op code.


inline

inline NCA_HD int get_index(Instruction instr)

From a packed instruction retrieve the operand stack index.


str get_include()

str get_lib_dir()

lazy_mode()

Context manager to delay immediate evaluation of results.

Return Name Description
constexpr bool is_in_type_list_v constexpr Whether a requested type is in the specified type_list.
constexpr bool is_exprmv_node_v constexpr
constexpr bool is_layout_policy_v constexpr Underlying trait to check for layout policy descendence.
constexpr bool is_ncoffsets_policy_v constexpr Underlying trait to check for if NCOffsetsPolicy.
constexpr bool is_soarray_policy_v constexpr Underlying trait to check for if SOArrayPolicy.
str lib_dir
str core_dir
bool has_driver
str stub_path
mode

constexpr

constexpr bool is_in_type_list_v = <T, List>::value

Whether a requested type is in the specified type_list.

  • T The object under test.

  • List The list to check for the inclusion of T.


constexpr

constexpr bool is_exprmv_node_v = <Expr>::value

constexpr

constexpr bool is_layout_policy_v = <L>::value

Underlying trait to check for layout policy descendence.


constexpr

constexpr bool is_ncoffsets_policy_v = <L>::value

Underlying trait to check for if NCOffsetsPolicy.


constexpr

constexpr bool is_soarray_policy_v = <L>::value

Underlying trait to check for if SOArrayPolicy.


str lib_dir = ()

str core_dir = os.path.join(os.path.dirname(__file__), "core")

bool has_driver = ctypes.util.find_library("cuda") is not None

str stub_path = os.path.join(
os.path.dirname(__file__), "core", "stubs", "libcuda.so"
)

mode