Model Compilation for TIDL

July 2, 2026 · View on GitHub

This document provides information about model compilation for TIDL framework, including what compilation means, how compiled model artifacts are structured, and how to use them.

Table of Contents

Python-Only Compilation Support

Currently, TIDL model compilation is supported only through Python APIs. The C++ APIs are limited to inference only.

Introduction to Model Compilation

Model compilation in TIDL is the process of converting and optimizing neural network models from frameworks like ONNX and TensorFlow Lite into a format that can be efficiently executed on TI's hardware accelerators (C7x DSP and MMA). This process involves several key steps:

  1. Parsing: Analyzing the model structure to identify operations that can be offloaded on C7x DSP and MMA. See Supported Operators for more details on what is supported.
  2. Graph Optimization: Internal optimizations applied by TIDL software to enable support and optimize performance
  3. Quantization & Calibration: Converting floating-point operations to fixed-point operations
  4. Memory Planning: Optimizing memory usage and data layout for TI hardware

The compilation process transforms models into a hardware-optimized format that enables efficient inference on TI devices, significantly improving performance and power efficiency compared to running the original models on the CPU.

Compilation Flow

The TIDL model compilation architecture consists of multiple layers that work together to transform models into an optimized format for hardware acceleration. The diagram below illustrates this architecture:

  1. Runtime Frameworks: High-level interfaces that initiate the compilation process. Currently limited to Python APIs only
  2. TIDL TOOLS: Core components that perform the actual compilation. These "tools" are effectively static libraries, shared objects and .out files provided by TIDL and downloaded as a part of setup process.
  3. Compilation Execution: The TIDL TOOLS comes in two variants CPU and GPU. This dictates where the computational heavy part of model compilation i.e "Quantization and Calibration" will run. CPU tools are the default tools that are downloaded as part of setup.

Compiled Model Artifacts Directory

When a model is compiled for TIDL acceleration, it generates a set of artifacts in a specified directory. The structure of this directory typically looks like:

artifacts/
    ├── subgraph_0_tidl_net.bin         # Compiled network binary file
    ├── subgraph_0_tidl_io_1.bin        # IO descriptor binary file
    ├── metadata_1.txt                  # Extra files in case of compilation from OSRT
    ├── metadata_1.txt                  # Extra files in case of compilation from OSRT
    └── tempDir/                        # Temporary directory with additional files
        ├── runtimes_visualization.svg              # Visual representation of the offload
        ├── subgraph_0_tidl_net.bin.html            # HTML viwer for compiled model details
        ├── subgraph_0_tidl_net.bin.layer_info.txt  # Layer mapping details
        └── ...                                     # Other temporary files

In case of multiple subgraphs due to unsupported layers, multiple files will be generated in the artifacts.

Key Artifact Files

  1. Network Binary File (*_net.bin):

    • Contains the compiled model weights and execution instructions
    • Used by the TIDL to execute the model on hardware accelerators
    • The binary format is optimized for direct loading into TI hardware
  2. IO Descriptor Binary File (*_io_1.bin):

    • Describes the input and output tensor properties required by the compiled model
    • Contains information about tensor shapes, data types, memory layout, and padding requirements
    • Essential for correctly preparing input data and interpreting output results
    • For detailed information about the IO descriptor format, see IO Tensors Documentation
  3. Runtime Visualization (tempDir/runtimes_visualization.svg):

    • Visual representation of how the model is partitioned between hardware accelerators and CPU
    • Helps identify which parts of the model are offloaded to TIDL hardware
    • A fully offloaded model will have all nodes encapsulated under a single colored block
  4. Model Viewer (tempDir/*.html):

    • Contains layer-level detailed information about the compile model
    • Provides an easy to traverse html based viewer with detailed individual layer information
  5. Layer Info (tempDir/*.layer_info.txt):

    • Contains information about mapping of TIDL layer to actual model
    • Useful for debugging, see Debugging

Identifying Fully Offloaded Models

A model is considered "fully offloaded" when all of its operations can be executed on the TIDL hardware accelerators without requiring CPU involvement. Fully offloaded models:

  • Have better performance and power efficiency
  • Can be used with the TIDL runtime directly
  • Will have a single network binary file and IO descriptor file
  • Show all nodes encapsulated in a single block in the visualization SVG

Compilation Options

When compiling models, you can configure various options to control the compilation process, including optimization, quantization etc.

General Options

Option NameDescriptionAllowed ValuesDefault ValueNotes
tidl_tools_pathPath to TIDL TOOLSValid TIDL TOOLS pathNone (Required)Must point to a valid TIDL tools installation directory
artifacts_folderPath to save the compiled model artifactsValid directory pathNone (Required)Directory must exist and be empty
debug_levelLevel of debug information0 - No Debug Prints
>= 1 - Compilation debug prints
0Higher values provide more detailed debug information
tensor_bitsBit precision for tensor quantization8, 16, 32832-bit is floating point and not supported for target execution
advanced_options:add_data_convert_opsControl data conversion layer addition to input outputs0 - Do not add dataconvert layer
1 - Add data convert at inputs only
2 - Add data convert at outputs only
3 - Add dataconvert at both inputs and outputs
0
ti_internal_nc_flagInternal use only---

Optimization Specific Options

Option NameDescriptionAllowed ValuesDefault ValueNotes
advanced_options:graph_optimization_levelControls the level of graph optimizations applied during compilation0 - TIDL_OPTIMIZE_LEVEL_BASIC (basic optimizations only)
1 - TIDL_OPTIMIZE_LEVEL_EXTENDED (basic + extended optimizations)
0When set to TIDL_OPTIMIZE_LEVEL_EXTENDED, extended optimizations like shape-folding is enabled to enhance performance. Currently TIDL_OPTIMIZE_LEVEL_EXTENDED is an experimental feature and has gone through limited validation
advanced_options:batch_modeEnable batch processing mode0 - 10If enabled, i.e set to 1, the outermost non-singleton dimension of certain layers will be stitched to width dimension for performance improvements
advanced_options:partial_init_during_compileEnable partial initialization of handles during model compilation to reduce inference initialization time0-1 (Integer)0Inference on host-emulation will not work if model is compiled with this flag enabled. Enabling this flag reduces int initialization time during inference by performing some internal compuations during compile time which would otherwise be performed during inference initialization.
advanced_options:packetize_modeEnable packetization mode for sparse weights in the model0-1 (Integer)0For optimizing memory access patterns
advanced_options:high_resolution_optimizationEnable high resolution optimization for improving performance on high resolution models0-1 (Integer)0This option enables "Super Tiling" wher-in feature-maps in layers are processed in chunks instead of complete data for better memory optimization
advanced_options:pre_batchnorm_foldFuses BatchNorm present before a Convolution0-1 (Integer)1Improves performance by folding batch norm into convolution
advanced_options:optimize_batchnorm_higherdimsFuses higher dimension for batchnorm to lower dimensions for performance improvements0-1 (Integer)0

Quantization Specific Options

For detailed explanation of quantization in TIDL, check out Quantization

Option NameDescriptionAllowed ValuesDefault ValueNotes
accuracy_levelLevel of accuracy optimization0, 1, 2, 9 (Integer)1Higher values prioritize accuracy over performance
bias_calibration_factorBias Calibration FactorFloat0.05Contribution used to update the bias in each iteration based on the difference of actual mean with respect to the mean after quantization
advanced_options:calibration_framesNumber of frames to use for calibrationInteger > 020More frames can improve accuracy but increase compilation time. This option is only applicable when accuracy_level = 1
advanced_options:calibration_iterationsNumber of iterations for calibrationInteger > 050More iterations can improve accuracy but increase compilation time. This option is only applicable when accuracy_level = 1
advanced_options:quantization_scale_typeType of quantization style to use0 - Non-Power of 2
1 - Power of 2
3 - TFLite Pre-Quantized Model
4 - Asymmetric Per-Channel Quantization
0
advanced_options:mixed_precision_factorFactor to enable automatic mixed precision quantizationFloat-1 (Disable)Setting to to anything other that -1 will enable this feature. This is used to automatically decides which layers to set to 16bit for improving accuracy take a performance degradation hit. This parameter is defined as value = (Acceptable latency with mixed precision / Latency with 8 bit inference). Ex: If acceptable latency for accuracy improvement is 1.2 times the 8 bit inference latency, the automated mixed precision algorithm finds the most optimal layers to set to 16 bits to gain accuracy improvement while making sure performance constraint set is satisfied
advanced_options:output_feature_16bit_names_listList of output names to use 16-bit precisionStringNoneFor mixed precision
advanced_options:params_16bit_names_listList of output names whose weights to use 16-bit precision.StringNoneFor mixed precision parameters
advanced_options:activation_clippingEnable activation clipping0-1 (Integer)1Can reduce quantization error. This option is only applicable when accuracy_level = 9
advanced_options:weight_clippingEnable weight clipping0-1 (Integer)1Can reduce quantization error. This option is only applicable when accuracy_level = 9
advanced_options:bias_calibrationEnable bias calibration0-1 (Integer)1Can reduce quantization error. This option is only applicable when accuracy_level = 9
advanced_options:channel_wise_quantizationEnable channel-wise quantization0-1 (Integer)0Can reduce quantization error. This option is only applicable when accuracy_level = 9
advanced_options:quant_params_proto_pathPath to quantization proto fileValid file pathNoneAllows to configure quantization scales manually by specifying min/max values of outputs. For more information, check out Quantization Proto.
advanced_options:prequantized_modelIndicate if model is pre-quantized0-1 (Integer)0This enables reading of scales and zero-points from the QDQ models and bypass the need for calibration. Only applicable for ONNX QDQ models. For TFLite models quantization_scale_type = 3 has the same effect
advanced_options:enable_tfr_optimizationEnable Transformer optimization for calibration0 - Disable
1 - Preserve float range during calibration
2 - Reserved
0

Object Detection Specific Options

For detailed explanation of object detection meta architecture, check out OD Meta Arch.

Option NameDescriptionAllowed ValuesDefault ValueNotes
model_typeExplicitly define model type in case of Object Detection model"OD"NoneUsed to indicate the model is object detection model
object_detection:meta_arch_typeArchitecture type for object detection modelsIntegerNoneRequired for certain object detection models
object_detection:meta_layers_names_listPath to prototxt file for object detection modelsValid file pathNoneRequired for certain object detection models
object_detection:confidence_thresholdUser defined Confidence threshold0.0-1.0NoneOverwrite the value of confidence_threshold defined in prototxt
object_detection:nms_typeUser defined NMS Type0 - UPRIGHT_BOX_OVERLAP_NMS
1 - ROTATED_BOX_OVERLAP_NMS
2 - CIRCULAR_BOX_DIST_NMS
NoneOverwrite the value of nms_type defined in prototxt
object_detection:nms_thresholdUser defined NMS Threshold0.0-1.0NoneOverwrite the value of nms_threshold defined in prototxt
object_detection:top_kUser defined flag to topk valueValid IntegerNoneOverwrite the value of top_k defined in prototxt
object_detection:keep_top_kUser defined flag to keep topkValid IntegerNoneOverwrite the value of keep_top_k defined in prototxt

Multi Subgraph Specific Options

Option NameDescriptionAllowed ValuesDefault ValueNotes
max_num_subgraphsMaximum number of TIDL subgraphsInteger > 01Cannot exceed system-defined maximum (16). Applicable for only ONNX Runtime and TFLite Runtime.
deny_list:layer_typeList of operators to deny for TIDL accelerationComma-separated stringNoneForces specified operators to run on CPU. Applicable for only ONNX Runtime and TFLite Runtime.
deny_list:layer_nameList of layer names to deny for TIDL accelerationComma-separated stringNoneForces specified layers to run on CPU. Applicable for only ONNX Runtime and TFLite Runtime.
deny_listList of operators to deny for TIDL accelerationComma-separated stringNoneForces specified operators to run on CPU
allow_list:layer_nameList of layer names to allow for TIDL accelerationComma-separated stringNoneOnly specified layers are offloaded to DSP while others run on CPU. Applicable for only ONNX Runtime and TFLite Runtime.
advanced_options:max_num_subgraph_nodesMaximum number of nodes per subgraphInteger > 0System default (2048 for QDQ models, 846 for other)Controls subgraph partitioning. Applicable for only ONNX Runtime.
advanced_options:enable_rt_multi_subgraph_supportCombine multiple subgraphs into one if all nodes are offloaded.0-1 (Integer)0Applicable for only ONNX Runtime.. This feature combines multiple generated subgraphs into one network and io binary enabling inference support in TIDL runtime.

NOTE

  • allow_list and deny_list options cannot be enabled simultaneously
  • For Tflite, specify registration code as specified in TFLite builtin ops - EX: 'deny_list:layer_type':'1, 2' to deny offloading 'AveragePool2d' and 'Concatenation'.
  • For ONNX, specify names as specified in ONNX Operators - EX: 'deny_list:layer_type':'MaxPool, Add'.
  • For Layer Name, you can use tool like Netron to visualize and get the layer name of a layer. In models where layer name is not present, use the first output name.

Multi-Core Specific Options

For detailed explanation of multi-core inference, check out Multi C7x.

Option NameDescriptionAllowed ValuesDefault ValueNotes
advanced_options:inference_modeSpecifies how to compile the model for inference in different modes.0 - TIDL_inferenceModeDefault
1 - TIDL_inferenceModeHighThroughput
2 - TIDL_inferenceModeLowLatency
0
advanced_options:num_coresNumber of cores to compile the model with for splitting inference on the set coresInteger > 01
advanced_options:single_core_layers_names_listList of layer names to force on a single core even in multi-core modeStringNone
advanced_options:m_spatial_split_layers_names_listList of layers for names for spatial (height) splitting in TIDL_inferenceModeLowLatency modeStringNone
advanced_options:m_channel_split_layers_names_listList of layers for names for channel splitting in TIDL_inferenceModeLowLatency modeStringNone

Miscellaneous Options

Option NameDescriptionAllowed ValuesDefault ValueNotes
advanced_options:network_namePrefix name for the compiled network and io binariesString"subgraph_"This option is only applicable for ONNX runtime. Used for identification in logs and artifacts
advanced_options:c7x_firmware_versionVersion of C7x firmware to useString11_02_16_00For specific firmware compatibility
advanced_options:log_file_nameName of log fileString/tmpFor redirecting logs to a file
advanced_options:temp_buffer_dirDirectory for temporary openvx buffersValid directory path"/dev/shm"Must be a valid directory with write permissions. Path is limited to 64 characters
advanced_options:nc_temp_info_dirDirectory for temporary network compiler infoValid directory path"/tmp"Must be a valid directory with write permissions
advanced_options:net_inelement_typeForces input element type conversion to specified valueComma-separated integersNoneBy default, the input dataconvert converts based on the tensor_bit , i.e for 8 bit, it'll convert to int8 or unint8. This option overwrites this and forces to convert to a specific format bypassing the tensor_bits. Comma seperated string with integer is given for each input. Ex: '0, 1' means force input0 to uint8 and input1 to int8. Refer to eTIDL_ElementType for values.
advanced_options:enable_custom_layersEnable custom layer implementation support0-1 (Integer)0
advanced_options:custom_layers_names_listList of custom layer namesComma-separated stringNone

References

For more information about model compilation and usage, refer to: