tritonclient.utils.shared_memory

tritonclient.utils.shared_memory#

Functions

create_shared_memory_region(triton_shm_name, ...)

Creates a system shared memory region with the specified name and size.

destroy_shared_memory_region(shm_handle)

Unlink a system shared memory region with the specified handle.

get_contents_as_numpy(shm_handle, datatype, ...)

Generates a numpy array using the data stored in the system shared memory region specified with the handle.

mapped_shared_memory_regions()

Return all system shared memory regions that were mapped but not unmapped/destroyed.

set_shared_memory_region(shm_handle, ...[, ...])

Copy the contents of the numpy array into the system shared memory region.

Exceptions

SharedMemoryException(err)

Exception indicating non-Success status.

exception tritonclient.utils.shared_memory.SharedMemoryException(err)#

Exception indicating non-Success status.

Parameters:

err (c_void_p) – Pointer to an Error that should be used to initialize the exception.

tritonclient.utils.shared_memory._raise_error(msg)#
tritonclient.utils.shared_memory._raise_if_error(errno)#

Raise SharedMemoryException if ‘err’ is non-success. Otherwise return nothing.

class tritonclient.utils.shared_memory._utf8#
classmethod from_param(value)#
tritonclient.utils.shared_memory.create_shared_memory_region(triton_shm_name, shm_key, byte_size)#

Creates a 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.

Returns:

shm_handle – The handle for the system shared memory region.

Return type:

c_void_p

Raises:

SharedMemoryException – If unable to create the shared memory region.

tritonclient.utils.shared_memory.destroy_shared_memory_region(shm_handle)#

Unlink a system shared memory region with the specified handle.

Parameters:

shm_handle (c_void_p) – 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 (c_void_p) – 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 (c_void_p) – 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.

Modules