QHAS Profiling

Brief

QHAS profiling has been enabled for SNPE workflow in HTP runtime. To enable, give the profiling level as qhas in snpe-dlc-graph-prepare to create a schematic bin, and give --profiling_level qhas during snpe-net-run execution to generate QHAS artifacts in the current working directory in a folder named profilelogs.

SNPE Workflow

snpe-dlc-graph-prepare --input_dlc inception_v3_quantized.dlc --output_dlc inception_v3_quantized_cache.dlc --htp_socs sm8750 --profiling_level qhas

From the above command we get [MODEL]_schematic.bin — this is the schematic file generated in the current working directory (required for chrometrace generation).

snpe-net-run --container inception_v3_quantized_cache.dlc --input_list input_list.txt --profiling_level qhas --use_dsp

The above command (profiling_level as qhas) will generate QHAS artifacts in the current working directory in a folder called “profilelogs”

Chrometrace Generation

To generate the chrometrace, run qnn-profile-viewer on the device with the libQnnHtpOptraceProfilingReader reader library.

qnn-profile-viewer --config [PATH_TO]/config.json --reader [SDK_PATH]/lib/[TARGET]/libQnnHtpOptraceProfilingReader.so --input_log ./profilelogs/qnn-profiling-data.log --schematic ./[MODEL]_schematic.bin --output ./chrometrace.json

Config Options

The config.json file provides parameters beyond the ones covered in the command line arguments, such as:

  • enable_input_output_flow_events - Adds flow events to chrometrace.json, showing input-output dependencies between operations. Requires using the legacy UI to open chrometrace.

  • enable_sequencer_flow_events - Adds flow events to chrometrace.json, showing ordering dependencies between operations, imposed by the sequencer. Requires using the legacy UI to open chrometrace.

  • htp_json - Dumps a [NAME]_htp.json file containing the topology and op-by-op information about the HTP graph. Default is on.

  • runtrace - Adds Runtrace execution and preemption events (if available) at the bottom of each core in the output chrometrace. Default is on.

  • memory_info - Adds memory bandwidth and allocation graphs (if available) at the bottom of each core in the output chrometrace. Default is on.

  • traceback - Adds trace back to source framework in the output chrometrace. Default is on.

  • qhas_schema - Dumps a qhas_schema.json that can be used to validate the QHAS JSON file. Default is off.

  • qhas_json - Dumps a [model]_qnn_htp_analysis_summary.json. Default is off.

Sample config.json

{
  "features": {
    "enable_input_output_flow_events": true,
    "enable_sequencer_flow_events": true,
    "htp_json": true,
    "runtrace": true,
    "memory_info": true,
    "traceback": true,
    "qhas_schema": true,
    "qhas_json": true
  }
}

References

For more information please look into HTP Optrace profiling in QNN -> Backend -> HTP and section QNN HTP Optrace Profiling.