BuildCCE
Description
Generates a TIK description language defined on the target machine and builds the TIK description language into a binary that is executable on Ascend AI Processor and the corresponding configuration file.
Prototype
BuildCCE(kernel_name, inputs, outputs, output_files_path=None, enable_l2=False, config=None, flowtable=None, evaluates=None, extend_params=None)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
kernel_name |
Input |
|
inputs |
Input |
|
outputs |
Input |
|
output_files_path |
Input |
A string specifying the build output path.
|
enable_l2 |
Input |
A bool specifying whether L2 is set as the external memory. Defaults to False. This parameter does not take effect. |
config |
Input |
A dictionary of key-value pairs, used to configure the operator build properties. key is of type string. Format: config = {"key":value}
Example: config = {"tbe_debug_level":2,"enable_const_fold":True,"double_buffer_non_reuse":True}
The following keys are supported:
|
flowtable |
Input |
A list or tuple of Tensors or InputScalars. Must be in the scope_gm scope. A flowtable of tiling parameters (computed by the operator selector in the dynamic-shape scenario). The flowtable length and inputs length adds up to less than or equal to 64. |
evaluates |
Input |
Debug parameters, used to assign a value to a defined global Scalar variable at build time. A dictionary of key-value pairs, with Scalar variable names as the keys. The values are of type Python int or float. Format: evaluates = {key : value}
Example: a = tik_instance.Scalar(dtype="float16")
a.set_as(1)
tik_instance.BuildCCE(..., evaluates = {a : 2})
|
extend_params |
Input |
A dictionary of key-value pairs for extended parameters. key: The data type is string. value: The data type is key-specific. Example: extend_params = {"param1": value1,
"param2": value2}
For details, see Table 2. |
Extended Parameter |
Description |
|---|---|
build_multi_kernels |
Builds a kernel for each tiling policy. Kernels are named according to the index of each tiling policy. The kernels are encapsulated in one .o file. The runtime framework automatically calls the corresponding functions based on the tiling policy. Example: tik_instance.BuildCCE(...,
extend_params={"build_multi_kernels":{
"tiling_key":[Scalar1, Scalar2],
"tiling_key_value":
[[Scalar1_val_1,Scalar2_val_1],
[Scalar1_val_2,Scalar2_val_2]]}})
In the preceding code: tiling_key is the keyword of the tiling policy:
tiling_key_value is the value corresponding to the keyword of the tiling policy:
|
Applicability
Restrictions
- inputs and outputs must have different tensors. Otherwise, a TIK error is reported.
- All tensors in scope_gm must be in inputs or outputs (except tensors in the workspace or tensors with init_value assigned). Otherwise, a compilation error is reported.
- When there is no output, BuildCCE specifies a length 1 array with data 0: If outputs=[], [[0]] is returned.
- In inputs, Tensors must be placed before InputScalars.
- flowtable allows only one Tensor, which must be placed before InputScalars.
- evaluates only changes the initial value of a Scalar. The dictionary length is up to 16.
Returns
None
Example
from tbe import tik
tik_instance = tik.Tik()
data_A = tik_instance.Tensor("float16", (128,), name="data_A", scope=tik.scope_gm)
data_B = tik_instance.Tensor("float16", (128,), name="data_B", scope=tik.scope_gm)
data_C = tik_instance.Tensor("float16", (128,), name="data_C", scope=tik.scope_gm)
tik_instance.BuildCCE(kernel_name="simple_add",inputs=[data_A,data_B],outputs=[data_C])