Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Latest commit

 

History

History
172 lines (91 loc) · 4.41 KB

PythonAPI.md

File metadata and controls

172 lines (91 loc) · 4.41 KB

Python API

The python API for Micron DLA has these functions:


Compile

Compiles a ONNX/NNEF network and produce .bin file with everything that is needed to execute

Parameters:

modelpath: path to a model file in ONNX format.

outfile: path to a file where a model in Micron DLA ready format will be saved. If this param is used then Init call is needed afterwards

inshapes: it is an optional string with shape information in the form of size0xsize1x...sizeN. In case of multiple inputs, shapes are semi-colon separated. This parameter is normally inferred from the model file, it can be overridden in case we want to change some input dimension

samples: a list of images in numpy float32 format used to choose the proper quantization for variable-fixed-point

MDLA: MDLA object to link together so that models can be load into memory together

Return value: List of the output nodes names returned by the network


Init

Loads a bitfile on an FPGA if necessary and prepares to run Micron DLA hardware.

Parameters:

infile: model binary file path. .bin file created by Compile

MDLA: another MDLA obj to be combined with this MDLA run.


SetFlag

Set some flags that change the behaviour of the API.

Parameters:

Name name of the flag to be set

Value value to set the flag as a numpy string

Currently available options are listed in here


GetInfo

Gets information of the SDK options.

Parameters:

Name info name to be returned

Currently available options are listed in here


Free

Frees the network.

Parameters:

None


GetResult

Get an output from a buffer. If the blocking flag was set then it will wait for Micron DLA hardware.

Return value:: Output tensor or list of output tensors and the userobj that was associated with this buffer in the PutInput function call.


PutInput

Put an input into a buffer and start Micron DLA hardware.

Parameters:

Image input data as a [list of] numpy array of type float32

userobj user defined object to keep track of the given input

Return value: Error or no error


Run

Runs a single inference on Micron DLA hardware.

Parameters:

Image input data as a [list of] numpy array of type float32

Return Result output tensor or list of output tensors of the model


Run_sw

Runs a single inference on the Micron DLA hardware simulator.

Parameters:

Image input data as a [list of] numpy array of type float32

Return Result output tensor or list of output tensors of the model


Run_th

Runs a single inference using thnets.

Parameters:

Image input data as a [list of] numpy array of type float32

Return Result output tensor or list of output tensors of the model