REACTION Configuration
reaction.yaml is the entry point of every REACTION run. It describes one experiment: which
model to use, which conversion and compilation path to follow, which target to run on, and what
to measure. reaction start reads this file from the REACTION root directory
(/opt/rcar-xos/v3.xx.0/tools/hyco/reaction) and drives the whole pipeline from it — ONNX
export, quantization, TVM compilation for the CNN-IP, execution on the board over RPC, and the
accuracy or latency report. Changing the flow therefore means editing the YAML file, not the
command line.
Important
This section is only an overview of the most relevant keys. The complete reference is
delivered with the SDK, in /opt/rcar-xos/v3.xx.0/docs/sw/hyco/user_manual.
Basic Structure
experiment:
name: my_test # Optional
model_name: ResNet18
task: tvm_cch
action: eval
line: onnx
target: v4h2
convert_configs:
tvm:
host: <board IP address> # IP address of the board
port: 9090 # Port of the manually started TVM RPC server
user: ubuntu # SSH user of the board
passwd: ubuntu # SSH password of the board
rpc_server_auto: false # The RPC server is started manually on the board
Key |
Description |
|---|---|
|
Experiment name. Artifacts are generated in |
|
Exact name of the model in the REACTION registry, or the alias of a registered custom model. Names are case-sensitive. |
|
Conversion and inference stage to run. See the table below. |
|
What to measure. See the table below. |
|
Conversion line to follow: |
|
Target board: |
|
Optional. Target operating system: |
|
Path to the ONNX weights of a model that is not in the registry, relative to the REACTION
root directory. Given together with |
|
Path to the pre-processing script that prepares the calibration images, relative to the
REACTION root directory. Given together with |
Tasks
Task |
Description |
|---|---|
|
Evaluate a PyTorch model, or convert it to FP32 ONNX and evaluate. |
|
Quantize an ONNX or PyTorch model and evaluate. |
|
Compile with TVM and run on the x86 host CPU. Useful as an accuracy reference.
|
|
Compile with TVM and run on CNN-IP + CPU of the board with the TVM runtime. It does not use the CEVA DSP, so this is the usual choice on the R-Car V4H SH platform. |
|
Compile with TVM and run on CNN-IP + CEVA DSP + CPU of the board. The CEVA DSP is not supported in this release, so this task is not available on the R-Car V4H SH platform. |
|
Compile the model into a standalone bundle covering all three compute units. It relies on the CEVA DSP, which is not supported in this release, so this task is not available on the R-Car V4H SH platform. |
Actions
Action |
Description |
|---|---|
|
Default. Conversion and inference on the target backend, reporting accuracy and latency. |
|
Measure latency only. |
|
Collect performance metrics with the profiler. |
|
Run through the common application, selecting the core automatically. |
|
Search for the best quantization parameters. |
Conversion Options
convert_configs holds the per-stage options of the conversion pipeline, grouped by stage:
onnxruntime— ONNX export options such asopset_version,input_shape,input_namesandoutput_names, and the manualpartitionedges for layers that the compiler cannot handle and that must run in ONNX Runtime on the host CPU.quantization— calibration settings such ascalibration_method,calib_data_rootanddataset_samples, the data typesweight_typeandactivation_type, andnodes_to_excludeto keep selected nodes in floating point.tvm— board connection (host,port,user,passwd,rpc_server_auto) and compilation settings such astarget,opt_level,timeout,cnnip_batch_sizeandcnnip_skip_layers.
A typical configuration only needs the board connection:
experiment:
model_name: ResNet18
task: tvm_cch
action: eval
line: onnx
target: v4h2
convert_configs:
tvm:
host: <board IP address> # IP address of the board
port: 9090 # Port of the manually started TVM RPC server
user: ubuntu # SSH user of the board
passwd: ubuntu # SSH password of the board
rpc_server_auto: false # The RPC server is started manually on the board
Application Options
With action: app the model is not evaluated over the RPC server but built into a common
application that runs standalone on the board, see REACTION Sample Application. The tvm stage
then takes a few additional keys:
Key |
Description |
|---|---|
|
SSH port of the board, |
|
Remove the quantize node next to the input. |
|
Same for the dequantize node next to the output. |
|
Skip the quantization of mean nodes. Needed by |
|
Keep the |
|
Convert an argmax node to |
|
Path to the custom node configuration, needed by the |
The exec_config.json File
While reaction.yaml describes which model is compiled and for which target,
exec_config.json describes how the generated application runs on the board: how many
frames and threads, which model libraries are loaded, which images are fed in, how the
quantization values are applied, how the blocks are wired together. Every application folder
under models/ carries its own copy, and the generator parses it at build time, so the
application has to be rebuilt with reaction start after every change.
The file has seven mandatory blocks:
{
"app-opts": { },
"compile-opts": { },
"inputs": { },
"outputs": { },
"models": { },
"connections": [ ],
"threads": [ ]
}
The last block is the threading block; its key is steps, threads or workers. The
example below is the complete configuration of MobileNet_v1-app reduced to a single thread:
{
"app-opts": {
"frame_per_loop": 1, // Frames processed per loop, match the thread count
"number_of_loops": 100, // Number of loops
"warmup": true // Discard a first warm-up run
},
"compile-opts": {
"threads": 1, // Number of threads the application is built for
"stream_input": false, // true to read the images from a folder continuously
"print_inference": false // true to print the inference results as well
},
"inputs": {
"in0": {
"file": "mobilenet_v1-app/test_data/cat.jpg",
"quantize": { "scale": 0.01865844801068306, "zero": -14 }
}
},
"outputs": {
"out0": [ { "dequantize": { "scale": 0.003920175600796938, "zero": -128 } } ]
},
"models": {
"dsp0": { "file": "mobilenet_v1-app/models/model_dsp0.so", "runtime": "tvm" }
},
"connections": [
"in0[0] -> dsp0[0]",
"dsp0[0] -> out0[0]"
],
"threads": [ "dsp0" ]
}
Note
The comments above are for reading only, JSON does not allow them.
Block |
Content |
|---|---|
|
Runtime options: |
|
Build-time options: |
|
One entry per input node. |
|
One entry per output node, with the |
|
One entry per model library: |
|
Wiring between the three blocks above, see below. |
|
Execution plan, see below. The key is |
Connections
A connection has the form <source>[index] -> <destination>[index], where the source is an
input or a model, and the destination is a model or an output. The index selects the connection
point and is only different from 0 for models with several inputs or outputs:
"connections": [
"in0[0] -> dsp0[0]",
"dsp0[1] -> post0[0]",
"dsp0[0] -> post0[1]",
"post0[0] -> out0[0]"
]
Threading
The threading block decides how the elements are scheduled. The three keywords can be nested
freely, but workers has to be at the root when it is used:
Keyword |
Behavior |
|---|---|
|
One thread, elements executed one after the other. For a model whose input is the output
of the previous one, for example |
|
Several threads in parallel, treated as one unit: the run is finished when all elements
are finished. For models that process the same frame, for example
|
|
Several independent threads, each finishing on its own. For identical pipelines on
different frames, for example four |
Keep frame_per_loop and the number of entries in models aligned with
compile-opts.threads: in the simple case of one input and unsplit models, all three have the
same value.
The CMakeLists.txt File
Next to exec_config.json, every application folder holds a CMakeLists.txt that tells the
generator which model libraries to build into the application. It consists of one model()
entry per model, and those entries have to match the file entries of the models block:
model(model_dsp0)
model(model_dsp1)
model(model_dsp2)
model(model_dsp3)
The provided applications are built for four threads, one model library per thread. Reducing the application to a single thread therefore means keeping a single entry:
model(model_dsp0)
For an application that runs several different models, name each one after its ONNX model instead:
model(models/<your-onnx-model-name>)
Important
The reference of both files is delivered with the SDK, in
reaction/app/generator/docs/execution_configuration.md and
reaction/app/generator/docs/model_specific_cmakelists.md.
Enabling Debug Logs
The log level defaults to INFO. Set it to DEBUG under deploy_configs to trace each
step of the execution:
experiment:
deploy_configs:
log_level: DEBUG
The additional logs appear on the terminal and in
work_dir/<experiment_name>/tvm-v4h2/<task>/conversion.log and validation.log.
Tip
With the YAML extension installed in VS Code, adding "configs/schema.json": "reaction.yaml"
to yaml.schemas in settings.json enables auto-completion and model-name suggestions
from the registry. The schema path is relative to the reaction folder, so VS Code must be
opened inside it.