HTP Core Headers for Op Packages

HTP core exposes over 70 headers externally for usage in QNN op packages. This set of headers provides data types, structs, macros, functions, classes and more for the purposes of op implementation, optimization rule definition and their registration. Op package implementers can utilize these data structures and functionalities supported by HTP core. This document provides a general guideline on how to use these headers.

Typically, only four headers need to be included in op package source files: constraints.h, op_package_feature_support.h, simple_reg.h, and optimize.h. These headers directly and indirectly include other headers from this header set.

These headers can be found in released QNN SDK, under directory include/HTP/core. Please note that these headers may change in future QNN SDK releases, and HTP op packages are required to be recompiled when new headers are released. In order to minimize code changes, header contents in namespace hnnx should not be directly used in op packages, as they are considered HTP core internal and may change without announcement.

HTP Core Headers Usage

Please use the following categories as a guideline for finding the symbols you need.

Data Type

  • dtype.h : info and traits of data types

  • dtype_enum.h : data types

Tensor

  • allocator.h : memory class of tensor

  • dtype_enum.h : data type of tensor

  • memory_layout.h : memory layout of tensor

  • padding.h : padding of tensor

  • shape.h : shape of tensor

  • template_help.h : tensor layout helpers

  • template_help_tensor_ext.h : tensor layout helpers

  • tensor.h : types of tensor, accessor functions of tensor

  • tensor_info.h : tensor properties about TCM memory and stored format

Op Implementation

  • data type (listed above) : access info about data types used in tensors

  • tensors (listed above) : access info and data of input and output tensors

  • afuncs.h : auxiliary functions

  • builtin_intrinsics.h : HVX built-in functions

  • check_hvx.h : check if HVX is available

  • conversions.h : data type conversion, comparison and arithmetic functions

  • float16.h : float16 helper functions

  • graph_status.h : enum as return value from op execute functions

  • hvx_mathops.h : HVX math helper functions

  • intrinsics.h : HVX functions

  • tile_extract.h : tile read and write

Optimization Rule

  • constraints.h : constraint rules in macros

  • dtype_enum.h : data types

  • interface_defs.h : access OutputDef in external replacement functions

  • match_op.h : functions used in match code part of optimization

  • oexpr.h : functions for constraint and replacement

  • oexpr_post.h : functions for constraint and replacement

  • optimize.h : external replacement function interface, functions for generating shape op and const op, functions for generating Quickshape, various pre-defined replacement functions

  • optimize_defs.h : constraint rules in macros

  • optimize_flags.h : constraints flags

  • op_def.h : access OpDef in external replacement functions

Cost Function

  • cost.h : cost function in macros

  • cost_funcs.h : cost function infrastructure

  • op.h : Op accessor for cost function usage

Registration

  • flags.h : registration flag macros

  • op.h : standard cost values

  • opname_tag.h : utils for op names

  • optimize.h : macros for optimization registration

  • ops_opts_registration.h : registration infrastructure for Ops and Optimization rules

  • ops_opts_registration_defs.h : consolidates all Ops and Optimization rule information

  • op_extra_info.h : op extra information interface

  • op_info.h : op information interface

  • op_package_name.h: current op package name as a string from compile flag

  • op_register.h : macros for registering ops

  • op_register_ext.h: macros for op, flag and cost registration

  • op_register_types.h : generation of op registration params for op construction

  • op_registry.h : op factory interface, to register or generate ops

  • op_utils.h : various op util functions

  • typical_op.h : op’s infrastructure

  • simple_reg.h : external op registration headers

Logging

  • log.h : for logging info, warning and error messages

Performance Measurement

  • perf_timing.h : for measuring pcycles

Op Parameter Order, Axis Parameter Adjustment, and Per-channel Scale Op

  • op_package_feature_support.h : for listing op parameter orders and default values, and for listing parameters needed axis adjustment, and for listing per-channel scale ops