Common TIK Compile Errors

Error Messages

When a TIK compile error occurs, the error message, code line of the operator when the error occurs, context of the operator source code, and operator call stack are printed to the screen. The following describes the error messages and the corresponding solutions.

Table 1 TIK compile error messages

Error Message

Description

Solution

Compile Error: The parameter type may be wrong, please check the api document

Compile error: The parameter type is incorrect. For details, see the API document.

The TIK API call argument has an invalid data type. Check the API parameter description and restrictions in TBE TIK API Reference. Try again with a valid argument.

Compile Error: Scalar operation may be wrong

Compile error: The Scalar operation is incorrect.

The Scalar operand has an invalid data type. For example, Scalar addition does not support the float type. Try again with a valid operand.

Compile Error: The compile command may be wrong

Compile error: The compilation command is incorrect.

The possible causes are that your compiler version is incompatible and the compile parameters are not supported. Check your compiler version and compile parameters.

Compile Error: Instruction selection may be wrong

Compile error: The internal instruction mapping is incorrect.

The possible cause is that your compiler version is incompatible. Check your compiler version.

Compile Error: Unknown errors

Compile error: Unknown error.

Unknown type error. The possible cause is that your compiler version is incompatible. Check your compiler version.

Error: Check failed: !invalid_vars.count(op): j is used out of scope

Compile error: The variable is out of its defined scope.

Check the error statement to locate the variable that exceeds the defined scope.

In the error message, j is the defined variable name. If the variable named j is not defined in the operator implementation code, j might be the index of a for_range() statement. For details, see Example 2.

Restrictions

  1. For compile command errors and some unknown errors, the error code lines and contexts are not printed. For other compile errors, specific code lines can be located.
  2. Set tbe_debug_level to 2 in the BuildCCE call.
    tik_instance.BuildCCE(..., config = {"tbe_debug_level": 2})

Example 1

Error message: "Scalar operation may be wrong"

The following figure shows the error message.

Based on the error message in the first line, find the error cause in the preceding table. Based on the error code line in the context of the TIK operator file, it is the value assignment statement of Scalar b in line 16 that goes wrong. According to the restrictions described in Scalar, if the initial value is an Expr or a list or tuple of Exprs, the constituent immediates must be of type int, instead of float.

Example 2

Error message: "xxx is used out of scope"

  • Sample 1
    The sample code is as follows.
    from tbe import tik
    tik_instance = tik.Tik()
    b = tik_instance.Scalar(dtype="int32", init_value=2, name="b")
    dup_value = tik_instance.Scalar(dtype="int32", init_value=3, name="dup_value")
    a_ub = tik_instance.Tensor(shape=(192,), name="a_ub", scope=tik.scope_ubuf, dtype="int32")
    with tik_instance.for_range(0, 2) as index:
    dup_value.set_as(b * dup_value)
    tik_instance.vec_dup(64, a_ub[index*64:], dup_value, 1, 8)
    
    tik_instance.vec_dup(64, a_ub[index*64:], dup_value, 1, 8)  # The index is out of the scope.
    tik_instance.BuildCCE("test_for_range", inputs=[], outputs=[])

    The following figure shows the error message displayed during compilation.

  • Sample 2
    The sample code is as follows.
    from tbe import tik
    tik_instance = tik.Tik()
    b = tik_instance.Scalar(dtype="int32", init_value=2, name="b")
    dup_value = tik_instance.Scalar(dtype="int32", init_value=3, name="dup_value")
    a_ub = tik_instance.Tensor(shape=(192,), name="a_ub", scope=tik.scope_ubuf, dtype="int32")
    with tik_instance.for_range(0, 2) as index:
    dup_value.set_as(b * dup_value)
    tik_instance.vec_dup(64, a_ub[index*64:], dup_value, 1, 8)
    
    with tik_instance.for_range(0, 2) as index:
    dup_value.set_as(b * dup_value)
    tik_instance.vec_dup(64, a_ub[index*64:], dup_value, 1, 8)
    
    tik_instance.vec_dup(64, a_ub[index*64:], dup_value, 1, 8)  # The index is out of the scope.
    tik_instance.BuildCCE("test_for_range", inputs=[], outputs=[])

    The following figure shows the error message displayed during compilation.

  • Sample 3

    The sample code is as follows.

    from tbe import tik
    tik_instance = tik.Tik()
    b = tik_instance.Scalar(dtype="int32", init_value=2, name="b")
    dup_value = tik_instance.Scalar(dtype="int32", init_value=3, name="dup_value")
    a_ub = tik_instance.Tensor(shape=(192,), name="a_ub", scope=tik.scope_ubuf, dtype="int32")
    with tik_instance.for_range(0, 2, name="index1") as index:  # Specify the variable name of the index.
    dup_value.set_as(b * dup_value)
    tik_instance.vec_dup(64, a_ub[index*64:], dup_value, 1, 8)
    
    with tik_instance.for_range(0, 2, name="index2") as index:  # Specify the variable name of the index.
    dup_value.set_as(b * dup_value)
    tik_instance.vec_dup(64, a_ub[index*64:], dup_value, 1, 8)
    
    tik_instance.vec_dup(64, a_ub[index*64:], dup_value, 1, 8)  # The index is out of the scope.
    tik_instance.BuildCCE("test_for_range", inputs=[], outputs=[])

    The following figure shows the error message displayed during compilation.

Notes:

In Sample 1 and Sample 2, the error cause is that the index exceeds the defined scope and it is defined in the for_range statement. However, the variable names in the two error messages are different. In the for_range() statement, the indexes are automatically named i, j, k, ... if the index names are not specified.

The difference between the implementation code of Sample 3 and Sample 2 is that the index of the for_range() statement in sample 3 is named. Seeing from the error message in Sample 3, we can quickly locate which variable exceeds the scope after the index of the for_range() statement is named.