tilelang.contrib.bisheng¶

Utility to invoke bisheng compiler for Ascend NPU targets.

Functions¶

find_bisheng_path()

Find the bisheng compiler binary.

find_ld_lld_path()

Find the CCE-capable ld.lld shipped with the Ascend toolkit.

normalize_options(options)

Normalize shell-like compiler options into individual argv tokens.

get_npu_arch([npu_arch])

Resolve the Bisheng NPU architecture option.

get_target_npu_arch(target)

Resolve the Bisheng NPU architecture from an Ascend target.

get_bisheng_compile_options([npu_arch, options])

Return common Bisheng options shared by tvm-ffi and Cython paths.

get_aibin_linker_options()

Return options used to turn relocatable CCE code into executable ELF.

compile_ascend(code[, target_format, npu_arch, ...])

Compile Ascend source code with the bisheng compiler.

Module Contents¶

tilelang.contrib.bisheng.find_bisheng_path()¶

Find the bisheng compiler binary.

Searches BISHENG_HOME/bin/bisheng, then PATH.

Returns:

path – Full path to the bisheng executable.

Return type:

str

Raises:

RuntimeError – If the compiler cannot be found.

tilelang.contrib.bisheng.find_ld_lld_path()¶

Find the CCE-capable ld.lld shipped with the Ascend toolkit.

Return type:

str

tilelang.contrib.bisheng.normalize_options(options)¶

Normalize shell-like compiler options into individual argv tokens.

Parameters:

options (str | collections.abc.Sequence[str] | None)

Return type:

list[str]

tilelang.contrib.bisheng.get_npu_arch(npu_arch=None)¶

Resolve the Bisheng NPU architecture option.

Parameters:

npu_arch (str | None)

Return type:

str

tilelang.contrib.bisheng.get_target_npu_arch(target)¶

Resolve the Bisheng NPU architecture from an Ascend target.

Parameters:

target (tvm.target.Target)

Return type:

str

tilelang.contrib.bisheng.get_bisheng_compile_options(npu_arch=None, options=None)¶

Return common Bisheng options shared by tvm-ffi and Cython paths.

Parameters:
  • npu_arch (str | None)

  • options (str | collections.abc.Sequence[str] | None)

Return type:

list[str]

tilelang.contrib.bisheng.get_aibin_linker_options()¶

Return options used to turn relocatable CCE code into executable ELF.

Return type:

list[str]

tilelang.contrib.bisheng.compile_ascend(code, target_format='o', npu_arch=None, options=None, path_target=None, verbose=False)¶

Compile Ascend source code with the bisheng compiler.

Parameters:
  • code (str) – The Ascend kernel source code.

  • target_format (str) – Output format: "o" for a relocatable host object, "so" for a host shared library, or "aibin" for an executable CCE ELF suitable for aclrtBinaryLoadFromData.

  • npu_arch (str, optional) – NPU architecture string passed via --npu-arch=<arch> (e.g. "dav-3510"). If None, ASCEND_NPU_ARCH env-var is used.

  • options (str or list of str, optional) – Extra flags forwarded to bisheng.

  • path_target (str, optional) – Explicit output path. A temporary file is used when not given.

  • verbose (bool) – Print compiler output.

Returns:

data – Contents of the compiled output file.

Return type:

bytearray