File UserMemoryMap.h

Parent directory (DlSystem)

Definition (DlSystem/UserMemoryMap.h)

Includes

Full File Listing

Typedefs

typedef void *Snpe_UserMemoryMap_Handle_t

A typedef to indicate a SNPE User Memory handle

Functions

Snpe_UserMemoryMap_Handle_t Snpe_UserMemoryMap_Create()

Creates a new empty UserMemory map

Snpe_UserMemoryMap_Handle_t Snpe_UserMemoryMap_Copy(Snpe_UserMemoryMap_Handle_t other)

copy constructor.

Parameters

other[in] : Handle to the other object to copy.

Snpe_ErrorCode_t Snpe_UserMemoryMap_Assign(Snpe_UserMemoryMap_Handle_t srcHandle, Snpe_UserMemoryMap_Handle_t dstHandle)

Copy-assigns the contents of srcHandle into dstHandle

Parameters
  • srcHandle[in] Source UserMemoryMap handle

  • dstHandle[out] Destination UserMemoryMap handle

Returns

SNPE_SUCCESS on successful copy-assignment

Snpe_ErrorCode_t Snpe_UserMemoryMap_Delete(Snpe_UserMemoryMap_Handle_t handle)

Destroys/frees UserMemory Map

Parameters

handle[in] : Handle to access UserMemory Map

Returns

SNPE_SUCCESS if Delete operation successful.

Snpe_ErrorCode_t Snpe_UserMemoryMap_Add(Snpe_UserMemoryMap_Handle_t handle, const char *name, void *address)

Adds a name and the corresponding buffer address to the map.

Parameters
  • handle[in] : Handle to access UserMemory Map

  • name[in] : The name of the UserMemory

  • address[in] : The pointer to the buffer memory. The addess is assumed to be DSP Fast RPC allocated memory (libcdsprpc.so/dll)

Note

If a UserBuffer with the same name already exists, the new address would be added to the map along with the existing entries.

Snpe_ErrorCode_t Snpe_UserMemoryMap_AddFdOffset(Snpe_UserMemoryMap_Handle_t handle, const char *name, void *address, size_t totalAllocatedSize, int32_t fd, uint64_t offset)

Adds a name and the corresponding buffer address to the map.

Parameters
  • handle[in] : Handle to access UserMemory Map

  • name[in] : The name of the UserMemory

  • address[in] : The pointer to the buffer memory

  • totalAllocatedSize[in] : Total allocated size in bytes

  • fd[in] : The file descriptor to the Buffer Memory. Passing -1 would lead SNPE to assume the address to be DSP Fast RPC allocated memory (libcdsprpc.so/dll)

  • offset[in] : The byte offset to the Buffer Memory. This allows a single large block of memory to be allocated for multiple tensors and individual tensors are identified by a common address/fd and an unique byte offset to the real address

Note

totalAllocatedSize is the total size of the allocation even if all of it is not used or only a portion of it is used via offsets. This will not always be equal to tensor size

Note

If a UserBuffer with the same name already exists, the new address/fd/offset would be added to the map along with the existing entries. Passing totalAllocatedSize=0, fd=-1 and offset=0 to this API is equivalent to invoking Snpe_UserMemoryMap_Add()

Snpe_ErrorCode_t Snpe_UserMemoryMap_Remove(Snpe_UserMemoryMap_Handle_t handle, const char *name)

Removes a mapping of one Buffer address and its name by its name.

Parameters
  • handle[in] : Handle to access UserMemory Map

  • name[in] : The name of Memory address to be removed

Note

If no UserBuffer with the specified name is found, nothing is done.

size_t Snpe_UserMemoryMap_Size(Snpe_UserMemoryMap_Handle_t handle)

Returns the number of User Memory addresses in the map.

Parameters

handle[in] : Handle to access UserMemory Map

Snpe_ErrorCode_t Snpe_UserMemoryMap_Clear(Snpe_UserMemoryMap_Handle_t handle)

Removes all User Memory from the map

Parameters

handle[in] : Handle to access UserMemory Map

Snpe_StringList_Handle_t Snpe_UserMemoryMap_GetUserBufferNames(Snpe_UserMemoryMap_Handle_t handle)

Returns the names of all User Memory

Parameters

handle[in] : Handle to access UserMemory Map

Returns

Returns a handle to the stringList.

size_t Snpe_UserMemoryMap_GetUserMemoryAddressCount(Snpe_UserMemoryMap_Handle_t handle, const char *name)

Returns the no of UserMemory addresses mapped to the buffer.

Parameters
  • handle[in] : Handle to access UserMemory Map

  • name[in] : The name of the UserMemory

void *Snpe_UserMemoryMap_GetUserMemoryAddressAtIndex(Snpe_UserMemoryMap_Handle_t handle, const char *name, uint32_t index)

Returns address at a specified index corresponding to a UserMemory buffer name.

Parameters
  • handle[in] : Handle to access UserMemory Map

  • name[in] : The name of the buffer

  • index[in] : The index in the list of addresses

size_t Snpe_UserMemoryMap_GetUserMemoryTotalAllocatedSizeAtIndex(Snpe_UserMemoryMap_Handle_t handle, const char *name, uint32_t index)

Returns total allocated size at a specified index corresponding to a UserMemory buffer name.

Parameters
  • handle[in] : Handle to access UserMemory Map

  • name[in] : The name of the buffer

  • index[in] : The index in the list of addresses

int32_t Snpe_UserMemoryMap_GetUserMemoryFdAtIndex(Snpe_UserMemoryMap_Handle_t handle, const char *name, uint32_t index)

Returns file descriptor at a specified index corresponding to a UserMemory buffer name.

Parameters
  • handle[in] : Handle to access UserMemory Map

  • name[in] : The name of the buffer

  • index[in] : The index in the list of addresses

uint64_t Snpe_UserMemoryMap_GetUserMemoryOffsetAtIndex(Snpe_UserMemoryMap_Handle_t handle, const char *name, uint32_t index)

Returns offset at a specified index corresponding to a UserMemory buffer name.

Parameters
  • handle[in] : Handle to access UserMemory Map

  • name[in] : The name of the buffer

  • index[in] : The index in the list of addresses