2407077_en-US

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

2407077_en-US

2407077_en-US

imx93 m33 sdk ethosu_apps_rpmsg: how to get the result of model?

in the sdk version26.   ethosu_apps_rpmsg did not show the way to get result from ethosu.
how to do it?

InferenceProcess::InferenceJob job("job", networkModel, ifm, ofm, expectedOutput, pmuEventConfig, 0,
                       &ethosu_drv, 0, nullptr, 0, 0, false);
    job.invalidate();
    InferenceProcess::InferenceProcess inferenceprocess(inferenceProcessTensorArena, TENSOR_ARENA_SIZE);
    bool failed = inferenceprocess.runJob(job);
    job.clean();

how can I get the output of this calculation?

Re: imx93 m33 sdk ethosu_apps_rpmsg: how to get the result of model?

The inference result is in the OFM buffer you pass into the job — ofm in your constructor. expectedOutput is only for the SDK example’s validation path; it is not where the calculated result is returned. The i.MX93 Ethos-U flow writes the completed inference result into the output feature-map buffer and, in the Linux/RPMsg flow, sends the response back to Cortex-A after the OFM is populated .

For your code, the important part is:

InferenceProcess::InferenceJob job(

    "job",

    networkModel,

    ifm,

    ofm,              // <-- output buffer(s)

    expectedOutput,   // <-- reference/validation data, not the result

    pmuEventConfig,

    0,

    &ethosu_drv,

    0,

    nullptr,

    0,

    0,

    false);


job.invalidate();


bool failed = inferenceprocess.runJob(job);


job.clean();


if (!failed)

{

    // Read result from ofm

}

Conceptually:

Copy

if (!failed)

{

    // Output tensor 0

    uint8_t *outputData = ofm[0].data();

    size_t outputSize   = ofm[0].size();


    for (size_t i = 0; i < outputSize; i++)

    {

        PRINTF("ofm[%u] = %d\r\n", i, outputData[i]);

    }

}

Depending on the exact SDK type of ofm , the access may be slightly different, but the rule is the same: read from the same ofm buffer that you passed into InferenceJob .

If your model output is quantized, the bytes in ofm are usually int8_t or uint8_t , not final floating-point values. Convert them using the output tensor’s quantization parameters:

float real_value = (quantized_value - zero_point) * scale;

For example, for an int8 output:

int8_t *out = reinterpret_cast(ofm[0].data());


for (size_t i = 0; i < outputSize; i++)

{

    float y = (static_cast(out[i]) - output_zero_point) * output_scale;

    PRINTF("out[%u] q=%d real=%f\r\n", i, out[i], y);

}

In the RPMsg case, remember that ethosu_apps_rpmsg is mainly the Cortex-M33 firmware service. It receives the request from Cortex-A, runs the Ethos-U job, writes the result into the OFM buffer, and returns the response over RPMsg . On the Cortex-A/Linux side, the documented API path is to access the OFM buffers, for example inf->getOfmBuffers() .

So:

  • M33-side direct test: read ofm[0] after runJob() completes successfully.
  • A-core/Linux RPMsg inference: get the output from the Linux-side inference object’s OFM buffers, not from ethosu_apps_rpmsg console output.
  • Do not use expectedOutput as result ; it is only the golden/reference output used by the sample to compare correctness.

The output of your calculation is already in ofm ; after a successful runJob(job) , read ofm[0] and interpret/dequantize it according to your model’s output tensor type.

Tags (1)
No ratings
Version history
Last update:
Friday
Updated by: