Function Snpe_Util_Convert_Float32ToTfN¶
Defined in File SNPEUtil.h
Function Documentation¶
-
bool Snpe_Util_Convert_Float32ToTfN(const float *inputBuffer, size_t inputBufferSizeBytes, bool isDynamicEncoding, float *scale, uint64_t *offset, void *outputBuffer, size_t outputBufferSizeBytes, unsigned bitWidth)¶
Converts/Quantizes a float32 buffer to an unsigned fixed point 8/16 bit buffer.
- Parameters
inputBuffer – [in] Pointer to the float32 buffer that the caller supplies
inputBufferSizeBytes – [in] Input buffer size, in bytes. Must be at least 4 bytes
isDynamicEncoding – [in] When set to false, scale and offset provided (next 2 argumets) will be used to qunatize. When set to true, scale and offset provided will be ignored and min/max will be computed from the inputBuffer to derrive the scale and offset for quantization. The computed scale and offset will be populated back to the caller in the next two arguments
[in/out] – scale Pointer to qunatization encoding scale to be passed in by the caller when isDynamicEncoding is true. When isDynamicEncoding is false this argument is ignored and is populated as an outparam.
[in/out] – offset Pointer to qunatization encoding offset to be passed in by the caller when isDynamicEncoding is true. When isDynamicEncoding is false this argument is ignored and is populated as an outparam.
outputBuffer – [in] Pointer to the unsigned fixed point 8/16 bit buffer that the caller supplies
outputBufferSizeBytes – [in] Output buffer size, in bytes. Must be large enough for all the inputs
bitWidth – [in] Quantization bitwidth (8 or 16)
Note
This API can do in-place quantization i.e. when outputBuffer equals inputBuffer pointer. But the output buffer CANNOT start at an offset from input buffer which will lead to corrupting inputs at sbsequent indexes.