SSCMEx.Engine
(sscmex v0.3.6)
Copy Markdown
SSCMA-Micro EngineCVI wrapper.
The engine is automatically garbage collected when no longer referenced.
Summary
Functions
Get input tensor as map with binary data.
Get input tensor index by name.
Get input quantization parameters.
Get input tensor shape as list of integers.
Returns the number of input tensors.
Get output tensor as map with binary data.
Get output tensor index by name.
Get output quantization parameters.
Get output tensor shape as list of integers.
Returns the number of output tensors.
Loads a model from file path.
Creates and initializes a new CVI engine.
Run inference (blocking, uses dirty CPU scheduler).
Set input tensor data from binary.
Types
Functions
@spec get_input(t(), non_neg_integer()) :: {:ok, map()} | {:error, term()}
Get input tensor as map with binary data.
Returns a map with keys:
:shape- tensor shape as list of integers:type- tensor type atom (:u8, :s8, :f32, etc.):size- tensor size in bytes:quant_param- quantization parameters map with:scaleand:zero_point:data- tensor data as binary:name- tensor name string:is_physical- boolean atom (:true or :false)
Get input tensor index by name.
Returns the index of the input tensor with the given name.
@spec get_input_quant_param(t(), non_neg_integer()) :: {:ok, map()} | {:error, term()}
Get input quantization parameters.
Returns a map with :scale (float) and :zero_point (integer).
@spec get_input_shape(t(), non_neg_integer()) :: {:ok, [integer()]} | {:error, term()}
Get input tensor shape as list of integers.
@spec get_input_size(t()) :: {:ok, non_neg_integer()} | {:error, term()}
Returns the number of input tensors.
@spec get_output(t(), non_neg_integer()) :: {:ok, map()} | {:error, term()}
Get output tensor as map with binary data.
See get_input/2 for return format.
Get output tensor index by name.
Returns the index of the output tensor with the given name.
@spec get_output_quant_param(t(), non_neg_integer()) :: {:ok, map()} | {:error, term()}
Get output quantization parameters.
Returns a map with :scale (float) and :zero_point (integer).
@spec get_output_shape(t(), non_neg_integer()) :: {:ok, [integer()]} | {:error, term()}
Get output tensor shape as list of integers.
@spec get_output_size(t()) :: {:ok, non_neg_integer()} | {:error, term()}
Returns the number of output tensors.
Loads a model from file path.
Examples
:ok = SSCMEx.Engine.load(engine, "/path/to/model.cvimodel")
Creates and initializes a new CVI engine.
Examples
{:ok, engine} = SSCMEx.Engine.new()
Run inference (blocking, uses dirty CPU scheduler).
After calling this function, output tensors will contain the inference results.
@spec set_input(t(), non_neg_integer(), binary()) :: :ok | {:error, term()}
Set input tensor data from binary.
The binary size must match the expected tensor size exactly.