Class IUserBuffer

Inheritance Relationships

Base Type

  • public Wrapper< IUserBuffer, Snpe_IUserBuffer_Handle_t, true >

Class Documentation

class IUserBuffer : public Wrapper<IUserBuffer, Snpe_IUserBuffer_Handle_t, true>

Public Functions

const TensorShape &getStrides() const

Retrieves the total number of bytes between elements in each dimension if the buffer were to be interpreted as a multi-dimensional array.

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 getSize() const

Retrieves the size of the buffer, in bytes.

Returns

Size of the underlying buffer, in bytes.

size_t getOutputSize() const

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.

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 getAddrOffset() const

Retrieves the byte offset to the starting address of the buffer.

Returns

byte offset of the buffer from total allocated memory address.

bool setBufferAddress(void *buffer) noexcept

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

buffer[in] : Pointer to the memory location

Returns

Whether the set succeeds.

bool setBufferAddressOffset(uint64_t offset) noexcept

Updates the address offset of the UserBuffer.

Parameters

offset[in] : byte offset to the starting address of the UserBuffer.

Returns

Whether the set succeeds.

const UserBufferEncoding &getEncoding() const noexcept

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.

Returns

Data encoding meta-data

UserBufferEncoding &getEncoding() noexcept

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.

Returns

Data encoding meta-data