File IUserBuffer.h¶
↰ Parent directory (DlSystem)
Contents
Definition (DlSystem/IUserBuffer.h)¶
Includes¶
DlSystem/DlError.h(File DlError.h)DlSystem/SnpeApiExportDefine.h(File SnpeApiExportDefine.h)DlSystem/TensorShape.h(File TensorShape.h)stddef.hstdint.h
Functions¶
Typedefs¶
Full File Listing¶
Typedefs
-
typedef void *Snpe_UserBufferEncoding_Handle_t¶
A typedef to indicate a SNPE UserByfferEncoding handle
-
typedef void *Snpe_UserBufferSource_Handle_t¶
A base class buffer source type
Note
UserBuffer from CPU support all kinds of runtimes; UserBuffer from GLBUFFER support only GPU runtime.
-
typedef void *Snpe_IUserBuffer_Handle_t¶
A typedef to indicate a SNPE IUserBuffer handle UserBuffer contains a pointer and info on how to walk it and interpret its content.
Enums
-
enum Snpe_UserBufferEncoding_ElementType_t¶
An enum class of all supported element types in a IUserBuffer
Values:
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_UNKNOWN = 0¶
Unknown element type.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_FLOAT = 1¶
Each element is presented by float.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_UNSIGNED8BIT = 2¶
Each element is presented by an unsigned int.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_FLOAT16 = 3¶
Each element is presented by float16.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_TF8 = 10¶
Each element is presented by an 8-bit quantized value.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_TF16 = 11¶
Each element is presented by an 16-bit quantized value.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_INT32 = 12¶
Each element is presented by Int32.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_UINT32 = 13¶
Each element is presented by UInt32.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_INT8 = 14¶
Each element is presented by Int8.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_UINT8 = 15¶
Each element is presented by UInt8.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_INT16 = 16¶
Each element is presented by Int16.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_UINT16 = 17¶
Each element is presented by UInt16.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_BOOL8 = 18¶
Each element is present by Bool8.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_INT64 = 19¶
Each element is present by Int64.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_UINT64 = 20¶
Each element is present by UInt64.
-
enumerator SNPE_USERBUFFERENCODING_ELEMENTTYPE_UNKNOWN = 0¶
-
enum Snpe_UserBufferSource_SourceType_t¶
Values:
-
enumerator SNPE_USERBUFFERSOURCE_SOURCETYPE_UNKNOWN = 0¶
Unknown buffer source type.
-
enumerator SNPE_USERBUFFERSOURCE_SOURCETYPE_CPU = 1¶
The network inputs are from CPU buffer.
-
enumerator SNPE_USERBUFFERSOURCE_SOURCETYPE_GLBUFFER = 2¶
The network inputs are from OpenGL buffer.
-
enumerator SNPE_USERBUFFERSOURCE_SOURCETYPE_UNKNOWN = 0¶
Functions
-
Snpe_UserBufferEncoding_ElementType_t Snpe_UserBufferEncoding_GetElementType(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Retrieves the element type.
- Parameters
userBufferEncodingHandle – [in] : Handle to access userBufferEncoding
- Returns
Element type
-
size_t Snpe_UserBufferEncoding_GetElementSize(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Retrieves the size of the element, in bytes.
- Parameters
userBufferEncodingHandle – [in] : Handle to access userBufferEncoding
- Returns
Size of the element, in bytes.
-
Snpe_ErrorCode_t Snpe_UserBufferEncoding_Delete(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Destroys/frees a UserBufferEncoding.
- Parameters
userBufferEncodingHandle – [in] : Handle to access UserBufferEncoding
- Returns
indication of success/failures
-
Snpe_UserBufferSource_SourceType_t Snpe_UserBufferSource_GetSourceType(Snpe_UserBufferSource_Handle_t userBufferSourceHandle)¶
Retrieves the source type.
- Parameters
userBufferSourceHandle – [in] : Handle to access userBufferSource
- Returns
Source type
-
Snpe_ErrorCode_t Snpe_UserBufferSource_Delete(Snpe_UserBufferSource_Handle_t userBufferSourceHandle)¶
Destroys/frees a UserBufferSource.
- Parameters
userBufferSourceHandle – [in] : Handle to access UserBufferSource
- Returns
indication of success/failures
-
Snpe_UserBufferSource_Handle_t Snpe_UserBufferSourceGLBuffer_Create()¶
An source type where input data is delivered from OpenGL buffer
-
Snpe_ErrorCode_t Snpe_UserBufferSourceGLBuffer_Delete(Snpe_UserBufferSource_Handle_t userBufferSourceHandle)¶
Destroys the userBuffer.
- Parameters
userBufferSourceHandle – [in] : Handle to access the UserBuffer
- Returns
Error code. Returns SNPE_SUCCESS if destruction successful
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingUnsigned8Bit_Create()¶
An encoding type where each element is represented by an unsigned int.
Userbuffer size assumes uint8 encoding for each element. (i.e., a tensor with dimensions (2,3) will be represented by (2 * 3) * 1 = 6 bytes in memory).
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingUnsigned8Bit_CreateCopy(Snpe_UserBufferEncoding_Handle_t otherHandle)¶
Copy Constructor for UserBufferEncodingUnsigned8Bit.
An encoding type where each element is represented by an unsigned int.
Userbuffer size assumes uint8 encoding for each element. (i.e., a tensor with dimensions (2,3) will be represented by (2 * 3) * 1 = 6 bytes in memory).
- Parameters
otherHandle – [in] : a handle to another UserBufferEncodingUnsigned8Bit to copy
- Returns
a handle to the UserBufferEncodingUnsigned8Bit
-
Snpe_ErrorCode_t Snpe_UserBufferEncodingUnsigned8Bit_Delete(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Destroys the encodingUnsigned8Bit.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encodingUnsigned8Bit
- Returns
Error code. Returns SNPE_SUCCESS if destruction successful
-
size_t Snpe_UserBufferEncodingUnsigned8Bit_GetElementSize(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Retrieves the size of the element, in bytes.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Size of the element, in bytes.
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingFloat_Create()¶
An encoding type where each element is represented by a float.
Userbuffer size assumes float encoding for each element. (i.e., a tensor with dimensions (2,3) will be represented by (2 * 3) * 4 = 24 bytes in memory).
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingFloat_CreateCopy(Snpe_UserBufferEncoding_Handle_t otherHandle)¶
Copy Constructor for UserBufferEncodingFloat.
An encoding type where each element is represented by a float.
Userbuffer size assumes float encoding for each element. (i.e., a tensor with dimensions (2,3) will be represented by (2 * 3) * 4 = 24 bytes in memory).
- Parameters
otherHandle – [in] : a handle to another UserBufferEncodingFloat to copy
- Returns
a handle to the constructed UserBufferEncodingFloat
-
Snpe_ErrorCode_t Snpe_UserBufferEncodingFloat_Delete(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Destroys the encodingFloat.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Error code. Returns SNPE_SUCCESS if destruction successful
-
size_t Snpe_UserBufferEncodingFloat_GetElementSize(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Retrieves the size of the element, in bytes.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Size of the element, in bytes.
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingFloatN_Create(uint8_t bWidth)¶
An encoding type where each element is represented by a float N
Userbuffer size assumes float N encoding for each element. (i.e., a tensor with dimensions (2,3) with a provided bitwidth of 16 will be represented by (2 * 3) * 2 = 12 bytes in memory).
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingFloatN_CreateCopy(Snpe_UserBufferEncoding_Handle_t otherHandle)¶
Copy Constructor for UserBufferEncodingFloatN.
An encoding type where each element is represented by a float N
Userbuffer size assumes float N encoding for each element. (i.e., a tensor with dimensions (2,3) with a provided bitwidth of 16 will be represented by (2 * 3) * 2 = 12 bytes in memory).
- Parameters
otherHandle – [in] : a handle to another UserBufferEncodingFloatN to copy
- Returns
a handle to the constructed UserBufferEncodingFloatN
-
Snpe_ErrorCode_t Snpe_UserBufferEncodingFloatN_Delete(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Destroys the encodingFloatN.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Error code. Returns SNPE_SUCCESS if destruction successful
-
size_t Snpe_UserBufferEncodingFloatN_GetElementSize(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Retrieves the size of the element, in bytes.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Size of the element, in bytes.
-
Snpe_UserBufferEncoding_ElementType_t Snpe_UserBufferEncodingFloatN_GetTypeFromWidth(uint8_t width)¶
Get the Float type corresponding to a given bitwidth.
- Parameters
width – bitwidth of Float type
- Returns
ElementType corresponding to a Float of width bits
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingTfN_Create(uint64_t stepFor0, float stepSize, uint8_t bWidth)¶
An encoding type where each element is represented by tfN, which is an N-bit quantized value, which has an exact representation of 0.0
Userbuffer size assumes tf N encoding for each element. (i.e., a tensor with dimensions (2,3) with a provided bitwidth of 16 will be represented by (2 * 3) * 2 = 12 bytes in memory).
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingTfN_CreateCopy(Snpe_UserBufferEncoding_Handle_t otherHandle)¶
Copy Constructor for UserBufferEncodingTfN.
An encoding type where each element is represented by tfN, which is an N-bit quantized value, which has an exact representation of 0.0
Userbuffer size assumes tf N encoding for each element. (i.e., a tensor with dimensions (2,3) with a provided bitwidth of 16 will be represented by (2 * 3) * 2 = 12 bytes in memory).
- Parameters
otherHandle – the UserBufferEncodingTfN to copy
- Returns
a handle to a newly constructed UserBufferEncodingTfN
-
Snpe_ErrorCode_t Snpe_UserBufferEncodingTfN_Delete(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Destroys the encodingTfN.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Error code. Returns SNPE_SUCCESS if destruction successful
-
size_t Snpe_UserBufferEncodingTfN_GetElementSize(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Retrieves the size of the element, in bytes.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Size of the element, in bytes.
-
void Snpe_UserBufferEncodingTfN_SetStepExactly0(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle, uint64_t stepExactly0)¶
Sets the step value that represents 0.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
stepExactly0 – [in] : The step value that represents 0
-
void Snpe_UserBufferEncodingTfN_SetQuantizedStepSize(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle, float quantizedStepSize)¶
Sets the float value that each step represents.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
quantizedStepSize – [in] : The float value of each step size
-
uint64_t Snpe_UserBufferEncodingTfN_GetStepExactly0(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Retrieves the step that represents 0.0.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Step value
-
float Snpe_UserBufferEncodingTfN_GetQuantizedStepSize(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Retrieves the step size.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Step size
-
float Snpe_UserBufferEncodingTfN_GetMin(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Calculates the minimum floating point value that can be represented with this encoding.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Minimum representable floating point value
-
float Snpe_UserBufferEncodingTfN_GetMax(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Calculates the maximum floating point value that can be represented with this encoding.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Maximum representable floating point value
-
Snpe_UserBufferEncoding_ElementType_t Snpe_UserBufferEncodingTfN_GetTypeFromWidth(uint8_t width)¶
Get the tfN type corresponding to a given bitwidth.
- Parameters
width – bitwidth of tfN type
- Returns
ElementType corresponding to a tfN of width bits
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingIntN_Create(uint8_t bWidth)¶
An encoding type where each element is represented by a Int
Userbuffer size assumes int N encoding for each element. (i.e., a tensor with dimensions (2,3) with a provided bitwidth of 32 will be represented by (2 * 3) * 4 = 24 bytes in memory).
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingIntN_CreateCopy(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Copy Constructor for UserBufferEncodingIntN.
An encoding type where each element is represented by a Int
Userbuffer size assumes int N encoding for each element. (i.e., a tensor with dimensions (2,3) with a provided bitwidth of 32 will be represented by (2 * 3) * 4 = 24 bytes in memory).
- Parameters
otherHandle – the UserBufferEncodingIntN to copy
- Returns
a handle to a newly constructed UserBufferEncodingIntN
-
Snpe_ErrorCode_t Snpe_UserBufferEncodingIntN_Delete(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Destroys the encodingIntN.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Error code. Returns SNPE_SUCCESS if destruction successful
-
size_t Snpe_UserBufferEncodingIntN_GetElementSize(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Retrieves the size of the element, in bytes.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Size of the element, in bytes.
-
Snpe_UserBufferEncoding_ElementType_t Snpe_UserBufferEncodingIntN_GetTypeFromWidth(uint8_t bWidth)¶
Get the int type corresponding to a given bitwidth.
- Parameters
width – bitwidth of int type
- Returns
ElementType corresponding to a int of width bits
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingUintN_Create(uint8_t bWidth)¶
An encoding type where each element is represented by a Uint
Userbuffer size assumes uint N encoding for each element. (i.e., a tensor with dimensions (2,3) with a provided bitwidth of 32 will be represented by (2 * 3) * 4 = 24 bytes in memory).
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingUintN_CreateCopy(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Copy Constructor for UserBufferEncodingUintN.
An encoding type where each element is represented by a Uint
Userbuffer size assumes uint N encoding for each element. (i.e., a tensor with dimensions (2,3) with a provided bitwidth of 32 will be represented by (2 * 3) * 4 = 24 bytes in memory).
- Parameters
otherHandle – the UserBufferEncodingUintN to copy
- Returns
a handle to a newly constructed UserBufferEncodingUintN
-
Snpe_ErrorCode_t Snpe_UserBufferEncodingUintN_Delete(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Destroys the encodingUintN.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Error code. Returns SNPE_SUCCESS if destruction successful
-
size_t Snpe_UserBufferEncodingUintN_GetElementSize(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Retrieves the size of the element, in bytes.
- Parameters
userBufferEncodingHandle – [in] : Handle to access the encoding
- Returns
Size of the element, in bytes.
-
Snpe_UserBufferEncoding_ElementType_t Snpe_UserBufferEncodingUintN_GetTypeFromWidth(uint8_t bWidth)¶
Get the uint type corresponding to a given bitwidth.
- Parameters
width – bitwidth of uint type
- Returns
ElementType corresponding to a uint of width bits
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingBool_Create(uint8_t bWidth)¶
An encoding type where each element is represented by a Bool
-
Snpe_UserBufferEncoding_Handle_t Snpe_UserBufferEncodingBool_CreateCopy(Snpe_UserBufferEncoding_Handle_t userBufferEncodingHandle)¶
Copy Constructor for UserBufferEncodingBool.
An encoding type where each element is represented by a bool
- Parameters
otherHandle – the UserBufferEncodingBool to copy
- Returns
a handle to a newly constructed UserBufferEncodingBool
-
Snpe_ErrorCode_t Snpe_UserBufferEncodingBool_Delete(Snpe_UserBufferEncoding_Handle_t userBufferHandle)¶
Destroys the encodingBool.
- Parameters
userBufferHandle – [in] : Handle to access the encoding
- Returns
Error code. Returns SNPE_SUCCESS if destruction successful
-
size_t Snpe_UserBufferEncodingBool_GetElementSize(Snpe_UserBufferEncoding_Handle_t userBufferHandle)¶
Retrieves the size of the element, in bytes.
- Parameters
userBufferHandle – [in] : Handle to access the encoding
- Returns
Size of the element, in bytes.
-
Snpe_ErrorCode_t Snpe_IUserBuffer_Delete(Snpe_IUserBuffer_Handle_t userBufferHandle)¶
Destroys/frees an IUserBuffer
- Parameters
userBufferHandle – [in] : Handle to access the IUserBuffer
- Returns
SNPE_SUCCESS if Delete operation successful.
-
Snpe_TensorShape_Handle_t Snpe_IUserBuffer_GetStrides_Ref(Snpe_IUserBuffer_Handle_t userBufferHandle)¶
Retrieves the total number of bytes between elements in each dimension if the buffer were to be interpreted as a multi-dimensional array.
- Parameters
userBufferHandle – [in] : Handle to access the UserBuffer
- Returns
A const reference to the number of bytes between elements in each dimension. e.g. A tightly packed tensor of floats with dimensions [4, 3, 2] would return strides of [24, 8, 4].
Warning
Do not modify the TensorShape returned by reference. Treat it as a const reference.
-
size_t Snpe_IUserBuffer_GetSize(Snpe_IUserBuffer_Handle_t userBufferHandle)¶
Retrieves the size of the buffer, in bytes.
- Parameters
userBufferHandle – [in] : Handle to access the UserBuffer
- Returns
Size of the underlying buffer, in bytes.
-
size_t Snpe_IUserBuffer_GetOutputSize(Snpe_IUserBuffer_Handle_t userBufferHandle)¶
Retrieves the size of the inference data in the buffer, in bytes.
The inference results from a dynamic-sized model may not be exactly the same size as the UserBuffer provided to SNPE. This function can be used to get the amount of output inference data, which may be less or greater than the size of the UserBuffer.
If the inference results fit in the UserBuffer, getOutputSize() would be less than or equal to getSize(). But if the inference results were more than the capacity of the provided UserBuffer, the results would be truncated to fit the UserBuffer. But, getOutputSize() would be greater than getSize(), which indicates a bigger buffer needs to be provided to SNPE to hold all of the inference results.
- Parameters
userBufferHandle – [in] : Handle to access the UserBuffer
- Returns
Size required for the buffer to hold all inference results, which can be less or more than the size of the buffer, in bytes.
-
uint64_t Snpe_IUserBuffer_GetAddressOffset(Snpe_IUserBuffer_Handle_t userBufferHandle)¶
Retrieves the byte offset to the starting address of the buffer.
- Parameters
userBufferHandle – [in] : Handle to access the UserBuffer.
- Returns
byte offset of the buffer from total allocated memory address.
-
int Snpe_IUserBuffer_SetBufferAddress(Snpe_IUserBuffer_Handle_t userBufferHandle, void *buffer)¶
Changes the underlying memory that backs the UserBuffer.
This can be used to avoid creating multiple UserBuffer objects when the only thing that differs is the memory location.
- Parameters
userBufferHandle – [in] : Handle to access the UserBuffer
buffer – [in] : Pointer to the memory location
- Returns
Whether the set succeeds.
-
int Snpe_IUserBuffer_SetBufferAddressOffset(Snpe_IUserBuffer_Handle_t userBufferHandle, uint64_t offset)¶
Updates the address offset of the UserBuffer.
- Parameters
userBufferHandle – [in] : Handle to access the UserBuffer.
offset – [in] : byte offset to the starting address of the UserBuffer.
- Returns
Whether the set succeeds.
-
Snpe_UserBufferEncoding_Handle_t Snpe_IUserBuffer_GetEncoding_Ref(Snpe_IUserBuffer_Handle_t userBufferHandle)¶
Gets a reference to the data encoding object of the underlying buffer.
This is necessary when the UserBuffer is re-used, and the encoding parameters can change. For example, each input can be quantized with different step sizes.
- Parameters
userBufferHandle – [in] : Handle to access the UserBuffer.
- Returns
Data encoding meta-data