api_check_support

Description

Checks whether an API is supported by Ascend AI Processor. With the optional parameter dtype configured, this API checks whether the API of the dtype type is supported by Ascend AI Processor.

Prototype

def api_check_support(intrinsic, dtype="")

Parameters

Parameter

Type

Description

intrinsic

(Required) String

The API to check.

  • DSL API, for example, tbe.dsl.vmax
  • TIK API, for example, tik.vec_add

dtype

(Optional) String

Data type supported by the API to check.

If this parameter is left empty, data type check is not performed.

  • The supported data types are:

    float16, float32, int8, int16, int32, int64, uint8, uint16, uint32, and uint64.

  • If the API inputs and output support different data types, enumerate the supported data types of the output, input0, input1, ..., and inputn in sequence.

    For example, if the output is of type float32 and the two inputs are of type float16, set dtype to f32f16f16.

  • For data type cast instructions such as TIK API vconv, use the following format: <abbreviated input data type>2<abbreviated output data type><(optional) abbreviated cast mode>.
    See the following example:
    • If the input is of type float16 and the output is of type float32, set dtype to f162f32.
    • If the input is of type float16, the output is of type int32, and the rounding mode is floor, set dtype to f162s32f.

Returns

True if supported; False otherwise.

Restrictions

Before calling this API, you need to call set_current_compile_soc_info to set the Ascend AI Processor type. If the type is not set, Ascend310 is used by default.

Examples

  • Example of checking DSL API support
    Before calling, replace soc_version with the actual Ascend AI Processor version.
    import tbe
    soc_version="xxx"
    tbe.common.platform.set_current_compile_soc_info(soc_version)
    tbe.common.platform.api_check_support("tbe.dsl.vmax", dtype="float16")
  • Example of checking TIK API support
    Before calling, replace soc_version with the actual Ascend AI Processor version.
    import tbe
    soc_version="xxx"
    tbe.common.platform.set_current_compile_soc_info(soc_version)
    tbe.common.platform.api_check_support("tik.vec_add", dtype="float16")