cuquantum.cutensornet.set_device_mem_handler¶
- cuquantum.cutensornet.set_device_mem_handler(intptr_t handle, handler)[source]¶
Set the device memory handler for cuTensorNet.
The
handlerobject can be passed in multiple ways:If
handleris anint, it refers to the address of a fully initializedcutensornetDeviceMemHandler_tstruct.If
handleris a Python sequence:If
handleris a sequence of length 4, it is interpreted as(ctx, device_alloc, device_free, name), where the first three elements are the pointer addresses (int) of the corresponding members.nameis astras the name of the handler.If
handleris a sequence of length 3, it is interpreted as(malloc, free, name), where the first two objects are Python callables with the following calling convention:ptr = malloc(size, stream)free(ptr, size, stream)
with all arguments and return value (
ptr) being Pythonint.nameis the same as above.
Note
Only when
handleris a length-3 sequence will the GIL be held whenever a routine requires memory allocation and deallocation, so for all other cases be sure yourhandlerdoes not manipulate any Python objects.- Parameters
handle (intptr_t) – The library handle.
handler – The memory handler object, see above.
See also