build
Description
Builds a schedule object to generate an operator binary file and an operator description file.
Prototype
build(sch, config_map=None)
Parameters
- sch: a schedule object to be computed.
- config_map: a dictionary of build configuration parameters. Defaults to None. The keys include:
- print_ir: If it is True, lower IR code is printed. Defaults to False.
- need_build: If it is True, build is performed. Defaults to True.
- name: operator name. Defaults to cce_op.
The value can contain a maximum of 200 characters, which allows a combination of letters, digits, and underscores (_), and must start with a letter or underscore (_).
- tensor_list: (required) a list of input and output tensors. The input is the tensor object returned by the placeholder API. The output is the result tensor object. Otherwise, an error is reported. In addition, this list determines the sequence of the parameters of the kernel function for generating an operator, which is the same as the sequence of the input and output on the list.
- bool_storage_as_1bit: a bool specifying whether to store bools in 1-bit format.
- True: 1-bit storage
- False: 8-bit storage
Defaults to True.
- kernel_meta_parent_dir: parent path of the kernel_meta folder that stores debugging files at operator build time. The debugging files include the operator .o (operator binary), .json (operator description), and .cce files.
The value is a path string relative to the path where the build command is executed.
Defaults to a dot (.) indicating that the debugging files are stored in the ./kernel_meta folder in path where the compile command is run.
- tbe_debug_level: debug level.Selected from:
- 0 (default): disables debug. Only the .o (operator binary) and .json (operator description) files are generated in the kernel_meta folder.
- 1: enables debug during single-operator debugging. TBE instruction mapping files, including an operator CCE file (.cce), a Python-CCE mapping file (*_loc.json), and operator .o and .json files, are generated in the kernel_meta folder. As AI Core instructions are executed in serial, performance may deteriorate.
- 2: enables debug during single-operator debugging. TBE instruction mapping files, including an operator CCE file (.cce), a Python-CCE mapping file (*_loc.json), and operator .o and .json files, are generated in the kernel_meta folder. Build optimization is disabled while CCE compiler debug is enabled (by setting -O0-g). As AI Core instructions are executed in serial, performance may deteriorate.
- The op_debug_level parameter in the ATC command line (if any) takes precedence over tbe_debug_level.
- If tbe_debug_level is set to 2, the CCE compiler is enabled, and the size of the operator kernel file (*.o file) increases. In dynamic shape scenarios, all possible scenarios are traversed during operator building, which may cause operator building failure due to large operator kernel file. In this case, 2 is not recommended.
If the build failure is caused by the large operator kernel file, the following log is displayed:
message:link error ld.lld: error: InputSection too large for range extension thunk ./kernel_meta_xxxxx.o:(xxxx)
Returns
None
Applicability
Example
from tbe import tvm
from tbe import dsl
# Define an input placeholder.
data = tvm.placeholder(shape, name="data", dtype=dtype)
with tvm.target.cce():
# Describe the compute process of the operator.
res = tbe.vabs(data)
# Generate a schedule object.
sch = dsl.auto_schedule(res)
# Define build parameters.
config = {"print_ir" : True,
"need_build" : True,
"name" : "abs_28_28_float16",
"tensor_list" : [data,res]
}
# Build the operator.
dsl.build(sch, config)
Parent topic: Build APIs