C++ API
-
class SimaMlsocApi
Public Functions
-
void setLogVerbosity(SiMaLogLevel level) noexcept
Set the logs level.
- Parameters:
level – Verbosity of the logs
-
vector<string> enumerateDeviceGuids() noexcept
Enumerates all device guids Lists all sima device in the system.
- Parameters:
void –
- Return values:
Vector – of guids of all sima device in the system
-
shared_ptr<SiMaDevice> openDevice(string guid) noexcept
Open sima device.
- Parameters:
guid – GUID of the device to be opened
- Return values:
Shared_ptr – SiMaDevice
Load Custom/Pre parsed Model.
- Parameters:
simaDevicePtr – Shared ptr of SiMaDevice class
SiMaModel – Parsed Model containing input and output shapes
- Return values:
shared_ptr – SiMaBundle
@breif Will parse given bundle file and load it
- Parameters:
simaDevicePtr – Shared ptr of SiMaDevice class
bundlePath – MPK file path
data_qid – Data queue ID
- Return values:
shared_ptr – SiMaBundle
@breif Will deploy given mpk file and load preparsed bundle
- Parameters:
simaDevicePtr – Shared ptr of SiMaDevice class
bundlePath – path to Sima mpk file
- Return values:
shared_ptr – SiMaBundle
Unload Model.
- Parameters:
shared_ptr – SiMaBundle
- Return values:
sima – error code SiMaErrorCode
Check if runtime app is active on soc.
- Parameters:
shared_ptr – SiMaBundle
- Return values:
bool – true if active else false
Check if runtime app is active on soc.
- Parameters:
shared_ptr – simaDevicePtr
- Return values:
bool – true if active else false
Check if device is already open.
- Parameters:
shared_ptr – simaDevicePtr
- Return values:
bool – true if opened else false
Run synchronous inference Transfers data frames synchronously.
- Parameters:
bundle – Shared ptr of class SiMaBundle
inputTensors – Vector of class SiMaTensor Holds batch of input tensors
metaData – Vector of uint8_t
outputTensors – Vector of class SiMaTensor Holds batch of output tensors
- Return values:
sima – error code SiMaErrorCode
Run asynchronous inference Transfers data frames asynchronously.
- Parameters:
bundle – Shared ptr of class SiMaBundle
inputTensors – Vector of class SiMaTensor Holds batch of input tensors
metaData – Vector of uint8_t
function – Callback function to be called after receiving the response for the txed frame
- Return values:
sima – error code SiMaErrorCode
Close sima device.
- Parameters:
simaDevicePtr – Shared ptr of SiMaDevice class
- Return values:
SiMaErrorCode – invalid_input
SiMaErrorCode – overflow
SiMaErrorCode – success
Reset sima device.
- Parameters:
simaDevicePtr – Shared ptr of SiMaDevice class
- Return values:
SiMaErrorCode – invalid_input
SiMaErrorCode – overflow
SiMaErrorCode – success
Logs the given log string.
- Parameters:
simaDevicePtr – Shared ptr of SiMaDevice class
SiMaLogLevel – Shared ptr of SiMaDevice class
file – Name of file of calling function(FILE)
line – Line of the calling function(LINE)
function – Function name of the calling function(__FUNCTION_)
log – Log string that needs to be passed
-
SiMaErrorCode getLastErrorCode()
Returns last error code.
- Return values:
Last – error code
Set maximum outstanding i/o requests.
- Parameters:
simaDevicePtr – Shared ptr of SiMaDevice class
maxRequests – Maximum number of outstanding requests. maxRequests will number of queue entries in each data queue.
- Return values:
SiMaErrorCode – invalid_input
SiMaErrorCode – success
Get maximum outstanding i/o requests.
- Parameters:
simaDevicePtr – Shared ptr of SiMaDevice class
maxRequests – Pointer in which maximum number of outstanding requests will stored by the API. maxRequests will number of queue entries in each data queue.
- Return values:
SiMaErrorCode – invalid_input
SiMaErrorCode – success
Set i/o request abort timeout.
- Parameters:
simaDevicePtr – Shared ptr of SiMaDevice class
timeout – i/o request abort timeout. Default value for timeout is 40 seconds. Minimum value for timeout is 2 seconds. Maximum value for timeout is 0xFFFFFFFF.
- Return values:
SiMaErrorCode – invalid_input
SiMaErrorCode – success
Get i/o request abort timeout.
- Parameters:
simaDevicePtr – Shared ptr of SiMaDevice class
timeout – Pointer in which i/o request abort timeout will be stored by the API.
- Return values:
SiMaErrorCode – invalid_input
SiMaErrorCode – success
Resets specific data queue.
- Parameters:
simaDevicePtr – Shared ptr of SiMaDevice class
- Return values:
SiMaErrorCode – invalid_input
SiMaErrorCode – success
-
SimaMlsocApi(SimaMlsocApi&) = delete
-
void operator=(SimaMlsocApi&) = delete
-
SimaMlsocApi(SimaMlsocApi&&) = delete
-
void operator=(SimaMlsocApi&&) = delete
Public Static Functions
-
static shared_ptr<SimaMlsocApi> getInstance()
Get Instance of SimaMlsocApi class.
- Parameters:
void –
- Return values:
Shared_ptr – of SimaMlsocApi class
-
void setLogVerbosity(SiMaLogLevel level) noexcept
-
class SiMaDevice
Contains Device details.
-
class SiMaModel : public SiMaBundle
Derived class of SiMaBundle. TODO: Obsolete this.
-
template<typename T>
class SiMaTensor Contains SiMa tensor information.
Public Functions
-
inline SiMaTensor(std::vector<uint32_t> shape)
constructor: Allocates a shared_ptr to a malloced blob and assigns free as the deleter for the blob
- Parameters:
shape – Vector of shapes, for example, if you want a tensor of (224, 224, 3) then you need to pass in a vector<uint32_t> shape{224, 224, 3}
-
inline void reset(std::vector<uint32_t> shape)
resets memory allocated by simatensor class with help shape vector
- Parameters:
shape – vector of shapes
-
inline SiMaTensor(T *blob, uint32_t blob_size, std::vector<uint32_t> shape)
constructor Allocates a shared_ptr to the input blob and assigns free as the deleter for the blob side_effect: This constructor consumes the give malloced memory and will be automatically deleted when all copies of this SiMaTensor is destroyed.
- Parameters:
blob – Pointer to a malloced memory which can be freed with free
blob_size – Size of the malloced memory in bytes
shape – Vector of shapes, for example, if you want a tensor of (224, 224, 3) then you need to pass in a vector<uint32_t> shape{224, 224, 3}
-
inline void reset(T *blob, uint32_t blob_size, std::vector<uint32_t> shape)
Resets memory allocated by SiMaTensor class with help memory blob, memory blob size and shape vector.
- Parameters:
blob – Pointer to memeroy blob
blob_size – Memory blob size
shape – Vector of shapes
-
inline std::shared_ptr<T> getPtr() const
Get memory blob pointer.
- Parameters:
void –
- Return values:
Shared – pointer to memory blob
-
inline std::vector<uint32_t> getShape() const
Get shape vector.
- Parameters:
void –
- Return values:
Vector – of shape
-
inline uint32_t getSizeInBytes() const
Get size of memory blob in bytes.
- Parameters:
void –
- Return values:
Size – of memory blob in bytes
-
inline uint32_t getSeqId() const
Get sequence ID of tensor.
- Parameters:
void –
- Return values:
Sequence – ID of tensor
-
inline uint32_t getAppId() const
Get application ID of the tensor.
- Parameters:
void –
- Return values:
Application – ID of the tensor
-
inline void setSeqId(uint32_t seq_id)
Get sequence ID of tensor.
- Parameters:
uint32_t – Sequence ID of the tensor
- Return values:
void –
-
inline void setAppId(uint32_t app_id)
Set application ID of the tensor.
- Parameters:
uint32_t – Application ID of the tensor
- Return values:
void –
-
inline SiMaTensor(std::vector<uint32_t> shape)