Edge AI Add-on API 2.2.0
Loading...
Searching...
No Matches

◆ nrf_axon_nn_model_infer_sync()

nrf_axon_result_e nrf_axon_nn_model_infer_sync ( const nrf_axon_nn_compiled_model_s * compiled_model,
const int8_t * input_vector,
int8_t * output_buffer )

Blocking inference function of a compiled model.

  • Reserves Axon for its exclusive access (using nrf_axon_platform_reserve_for_user()).
  • Copies the input_vector to its location in the interlayer buffer. This input_vector is assumed to be packed in memory.
  • Performs the inference.
  • copies and packs unpacked output from interlayer buffer to output_buffer (optional)
  • Frees Axon for other users.
  • Returns to user.

If input_vector is NULL, the user has to copy the model input to the correct location in the interlayer buffer (specified by the compiled_model). In a dynamic system where there are other threads utilizing axon and/or asynchronous inference is occurring, the user must 1st call nrf_axon_platform_reserve_for_user() prior to accessing the interlayer_buffer, then invoke this function.

Similarly, output_buffer cannot be NULL in a dynamic system as there is no way to retain control of axon after inference completes.

Cannot be called from interrupt context.

Parameters
[in]compiled_modelThe compiled model to perform inference on that has been validated by calling nrf_axon_nn_model_validate(compiled_model).
[in]input_vectorPacked input that is copied to the model's input_ptr prior to inference. Can be NULL (see above).
[out]output_bufferBuffer to hold the packed output result. Can be NULL (see above).
Return values
0on success, are a negative error code.