# 'hacc' Dialect Heterogeneous Async Computing Call (HACC) dialect. ## Attributes ### BlockDimAttr Syntax: `#hacc.block_dim` HACC block dimension attribute for function. ### CachedIOAttr Syntax: `#hacc.cached_io` This attribute is used to indicate the value has been cached io. ### DummyFuncAttr Syntax: `#hacc.dummy_func` HACC dummy func type. ### ExportAsDAGAttr Syntax: `#hacc.export_as_dag` Export function as DAG. ### ExternalFunctionPathAttr Syntax: `#hacc.external_function_path` This attribute is used to indicate the location of external functions. ### HACCFuncTypeAttr Syntax: ```mlir #hacc.function_kind< ::mlir::hacc::HACCFuncType # function_kind > ``` HACC function type. #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | function_kind | `::mlir::hacc::HACCFuncType` | an enum of type HACCFuncType | ### GetTilingStructSizeFunctionAttr Syntax: ```mlir #hacc.get_tiling_struct_size_function< ::mlir::FlatSymbolRefAttr # funcName > ``` HACC get tiling struct size function attribute. This is used to indicate the host get tiling struct size function of the device function. #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | funcName | `::mlir::FlatSymbolRefAttr` | function symbol name | ### HostFuncTypeAttr Syntax: ```mlir #hacc.host_func_type< ::mlir::hacc::HostFuncType # host_func_type > ``` HACC host func type. #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | host_func_type | `::mlir::hacc::HostFuncType` | an enum of type HostFuncType | ### InferOutputShapeFunctionAttr Syntax: ```mlir #hacc.infer_output_shape_function< ::mlir::FlatSymbolRefAttr # funcName > ``` HACC infer output shape function attribute. This is used to indicate the host infer output shape function of the device function. #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | funcName | `::mlir::FlatSymbolRefAttr` | function symbol name | ### InferSyncBlockLockInitFunctionAttr Syntax: ```mlir #hacc.infer_sync_block_lock_init_function< ::mlir::FlatSymbolRefAttr # funcName > ``` HACC infer sync block lock init function attribute. This is used to indicate the host get sync block lock init value for the device function. Every lock needs to be initialized before running the kernel, this function is used to infer the initial value of the lock. #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | funcName | `::mlir::FlatSymbolRefAttr` | function symbol name | ### InferSyncBlockLockNumFunctionAttr Syntax: ```mlir #hacc.infer_sync_block_lock_num_function< ::mlir::FlatSymbolRefAttr # funcName > ``` HACC infer sync block lock num function attribute. This is used to indicate the host infer sync block lock num function of the device function. For 1 atomic op, all the blocks share 1 <1xi64> type memref on gm, which is called a lock, and this function is used to infer how many locks the kernel needs. #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | funcName | `::mlir::FlatSymbolRefAttr` | function symbol name | ### InferTaskTypeFunctionAttr Syntax: ```mlir #hacc.infer_task_type_function< ::mlir::FlatSymbolRefAttr # funcName > ``` HACC infer core type and mix ratio. #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | funcName | `::mlir::FlatSymbolRefAttr` | function symbol name | ### InferWorkspaceShapeFunctionAttr Syntax: ```mlir #hacc.infer_workspace_shape_function< ::mlir::FlatSymbolRefAttr # funcName > ``` HACC infer workspace shape function attribute. This is used to indicate the host infer workspace shape function of the device function. #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | funcName | `::mlir::FlatSymbolRefAttr` | function symbol name | ### InputIdxAttr Syntax: ```mlir #hacc.input_idx< unsigned # argIdx > ``` #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | argIdx | `unsigned` | | ### KernelArgTypeAttr Syntax: ```mlir #hacc.arg_type< ::mlir::hacc::KernelArgType # arg_type > ``` HACC kernel arg type. #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | arg_type | `::mlir::hacc::KernelArgType` | an enum of type KernelArgType | ### NoIOAliasAttr Syntax: `#hacc.no_io_alias` This attribute is used to indicate the function inputs/outputs are strictly not alias. ### OutputIdxAttr Syntax: ```mlir #hacc.output_idx< unsigned # argIdx > ``` On NPU device, the kernel function's calling convention is that the output is passed in as an input parameter. This attribute is used to indicate which output value does the current function argument corresponds to. #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | argIdx | `unsigned` | | ### RenameFuncAttr Syntax: ```mlir #hacc.rename_func< ::mlir::FlatSymbolRefAttr # targetName > ``` This attribute is used to indicate that current function shall be renamed to the target function name. #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | targetName | `::mlir::FlatSymbolRefAttr` | function symbol name | ### TargetAttr Syntax: ```mlir #hacc.target< StringAttr # target > ``` This attribute is used to indicate the target device. #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | target | `StringAttr` | target device | ### TargetDeviceSpecAttr An attribute to represent NPU target device specification. Syntax: ```mlir #hacc.target_device_spec< ::llvm::ArrayRef # entries > ``` Each device specification describes a single device and its hardware properties. Each device specification can contain any number of optional hardware properties (e.g., "UB_SIZE" below). Example: ```mlir #hacc.target_device_spec< #dlti.dl_entry<"UB_SIZE", 196608 : i32>> ``` #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | entries | `::llvm::ArrayRef` | single spec entry | ### TilingFunctionAttr Syntax: ```mlir #hacc.tiling_function< ::mlir::FlatSymbolRefAttr # funcName > ``` HACC tiling function attribute. This is used to indicate the host tiling function of the device function. #### Parameters | Parameter | C++ type | Description | | :-------: | :-------: | ----------- | | funcName | `::mlir::FlatSymbolRefAttr` | function symbol name | ## Enums ### DeviceSpec HACC device spec #### Cases | Symbol | Value | String | | :----: | :---: | ------ | | AI_CORE_COUNT | `0` | AI_CORE_COUNT | | CUBE_CORE_COUNT | `1` | CUBE_CORE_COUNT | | VECTOR_CORE_COUNT | `2` | VECTOR_CORE_COUNT | | UB_SIZE | `3` | UB_SIZE | | L1_SIZE | `4` | L1_SIZE | | L0A_SIZE | `5` | L0A_SIZE | | L0B_SIZE | `6` | L0B_SIZE | | L0C_SIZE | `7` | L0C_SIZE | | UB_ALIGN_SIZE | `8` | UB_ALIGN_SIZE | | L1_ALIGN_SIZE | `9` | L1_ALIGN_SIZE | | L0C_ALIGN_SIZE | `10` | L0C_ALIGN_SIZE | ### HACCFuncType HACC Function Category #### Cases | Symbol | Value | String | | :----: | :---: | ------ | | HOST | `1` | HOST | | DEVICE | `2` | DEVICE | ### HostFuncType HACC Host function type #### Cases | Symbol | Value | String | | :----: | :---: | ------ | | kEntry | `1` | host_entry | | kTilingFunction | `2` | tiling_function | | kInferOutputShapeFunction | `3` | infer_output_shape_function | | kInferWorkspaceShapeFunction | `4` | infer_workspace_shape_function | | kInferSyncBlockLockNumFunction | `5` | infer_sync_block_lock_num_function | | kInferSyncBlockLockInitFunction | `6` | infer_sync_block_lock_init_function | | kGetTilingStructSizeFunction | `7` | get_tiling_struct_size_function | | kInferTaskTypeFunction | `8` | infer_task_type_function | ### KernelArgType HACC Kernel Arg Category #### Cases | Symbol | Value | String | | :----: | :---: | ------ | | kFFTSBaseAddr | `0` | ffts_base_address | | kInput | `1` | input | | kOutput | `2` | output | | kInputAndOutput | `3` | input_and_output | | kWorkspace | `4` | workspace | | kSyncBlockLock | `5` | sync_block_lock | | kTilingKey | `6` | tiling_key | | kTilingData | `7` | tiling_data | | kTilingStruct | `8` | tiling_struct | | kMeshArg | `9` | mesh_arg | | kSanitizerAddr | `10` | sanitizer_addr | ### HACCToLLVMIRTranslateAttr allowed 32-bit signless integer cases: 0, 1, 2 #### Cases | Symbol | Value | String | | :----: | :---: | ------ | | ENTRY | `0` | hacc.entry | | MIX_ENTRY | `1` | hacc.mix_entry | | ALWAYS_INLINE | `2` | hacc.always_inline |