tritonclient.utils.shared_memory#
Functions
|
Return a handle of the system shared memory region with the specified name and size. |
|
Release the handle, unlink a system shared memory region with the specified handle if it is the last managed handle. |
|
Generates a numpy array using the data stored in the system shared memory region specified with the handle. |
Return all system shared memory regions that were mapped but not unmapped/destroyed. |
|
|
Copy the contents of the numpy array into the system shared memory region. |
Classes
|
Exceptions
Exception type for shared memory related error. |
- exception tritonclient.utils.shared_memory.SharedMemoryException#
Exception type for shared memory related error.
- class tritonclient.utils.shared_memory.SharedMemoryRegion(triton_shm_name: str, shm_key: str)#
- tritonclient.utils.shared_memory.create_shared_memory_region(
- triton_shm_name,
- shm_key,
- byte_size,
- create_only=False,
Return a handle of the system shared memory region with the specified name and size.
- Parameters:
triton_shm_name (str) – The unique name of the shared memory region to be created.
shm_key (str) – The unique key of the shared memory object.
byte_size (int) – The size in bytes of the shared memory region to be created.
create_only (bool) – Whether a shared memory region must be created. If False and a shared memory region of the same name exists, a handle to that shared memory region will be returned and user must be aware that the previously allocated shared memory size can be different from the size requested.
- Returns:
shm_handle – The handle for the system shared memory region.
- Return type:
- Raises:
SharedMemoryException – If unable to create the shared memory region.
- tritonclient.utils.shared_memory.destroy_shared_memory_region(shm_handle)#
Release the handle, unlink a system shared memory region with the specified handle if it is the last managed handle.
- Parameters:
shm_handle (SharedMemoryRegion) – The handle for the system shared memory region.
- Raises:
SharedMemoryException – If unable to unlink the shared memory region.
- tritonclient.utils.shared_memory.get_contents_as_numpy(shm_handle, datatype, shape, offset=0)#
Generates a numpy array using the data stored in the system shared memory region specified with the handle.
- Parameters:
shm_handle (SharedMemoryRegion) – The handle for the system shared memory region.
datatype (np.dtype) – The datatype of the array to be returned.
shape (list) – The list of int describing the shape of the array to be returned.
offset (int) – The offset, in bytes, into the region where you want the array extracted. The default value is 0.
- Returns:
The numpy array generated using the contents of the specified shared memory region.
- Return type:
np.array
- tritonclient.utils.shared_memory.mapped_shared_memory_regions()#
Return all system shared memory regions that were mapped but not unmapped/destroyed.
- Returns:
The list of mapped system shared memory regions.
- Return type:
list
- tritonclient.utils.shared_memory.set_shared_memory_region(shm_handle, input_values, offset=0)#
Copy the contents of the numpy array into the system shared memory region.
- Parameters:
shm_handle (SharedMemoryRegion) – The handle for the system shared memory region.
input_values (list) – The list of numpy arrays to be copied into the shared memory region.
offset (int) – The offset, in bytes, into the region where you want the array copied. The default value is 0.
- Raises:
SharedMemoryException – If unable to mmap or set values in the system shared memory region.