Class UserMemoryMap¶
Defined in File UserMemoryMap.hpp
Class Documentation¶
-
class UserMemoryMap¶
Public Functions
-
UserMemoryMap()¶
Creates a new empty UserMemory map.
-
UserMemoryMap(const UserMemoryMap &other)¶
Copy constructor to create an object.
- Parameters
other – [in] object to copy from
-
UserMemoryMap(UserMemoryMap &&other) noexcept¶
Move constructor to create an object.
- Parameters
other – [in] is reference to source object
-
UserMemoryMap &operator=(const UserMemoryMap &other)¶
Assignment operator to create an object.
- Parameters
other – [in] is reference to source object
-
DlSystem::ErrorCode add(const char *name, void *address) noexcept¶
Adds a name and the corresponding buffer address to the map.
- Parameters
name – [in] The name of the UserMemory
address – [in] The pointer to the Buffer Memory. The address 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.
-
DlSystem::ErrorCode add(const char *name, void *address, size_t totalAllocatedSize, int32_t fd, uint64_t offset) noexcept¶
Adds a name and the corresponding buffer address to the map.
- Parameters
name – [in] The name of the UserMemory
address – [in] The pointer to the buffer memory
totalAllocatedSize – [in] Total size of the allocated buffer 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
-
DlSystem::ErrorCode remove(const char *name)¶
Removes a mapping of one Buffer address and its name by its name.
- Parameters
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 size() const noexcept¶
Returns the number of User Memory addresses in the map.
-
StringList getUserBufferNames() const¶
Returns the names of all User Memory.
- Returns
A list of Buffer names.
-
size_t getUserMemoryAddressCount(const char *name) const noexcept¶
Returns the no of UserMemory addresses mapped to the buffer.
- Parameters
name – [in] The name of the UserMemory
-
void *getUserMemoryAddressAtIndex(const char *name, uint32_t index) const noexcept¶
Returns address at a specified index corresponding to a UserMemory buffer name.
- Parameters
name – [in] The name of the buffer
index – [in] The index in the list of addresses
-
int32_t getUserMemoryFdAtIndex(const char *name, uint32_t index) const noexcept¶
Returns file descriptor at a specified index corresponding to a UserMemory buffer name.
- Parameters
name – [in] The name of the buffer
index – [in] The index in the list of addresses
-
uint64_t getUserMemoryOffsetAtIndex(const char *name, uint32_t index) const noexcept¶
Returns offset at a specified offset corresponding to a UserMemory buffer name.
- Parameters
name – [in] The name of the buffer
index – [in] The index in the list of addresses
-
size_t getUserMemoryTotalAllocatedSizeAtIndex(const char *name, uint32_t index) const noexcept¶
Returns total allocated size at a specified index corresponding to a UserMemory buffer name.
- Parameters
name – [in] The name of the buffer
index – [in] The index in the list of addresses
-
UserMemoryMap()¶