tilelang.contrib.cc

Util to invoke C/C++ compilers in the system.

函式

get_cc()

Return the path to the default C/C++ compiler.

get_cplus_compiler()

Return the path to the default C/C++ compiler.

is_darwin()

create_shared(output, objects[, options, cc, cwd, ...])

Create shared library.

create_staticlib(output, inputs[, ar])

Create static library.

create_executable(output, objects[, options, cc, cwd, ...])

Create executable binary.

get_global_symbol_section_map(path, *[, nm])

Get global symbols from a library via nm -g

get_target_by_dump_machine(compiler)

Functor of get_target_triple that can get the target triple using compiler.

cross_compiler(compile_func[, options, output_format, ...])

Create a cross compiler function by specializing compile_func with options.

Module Contents

tilelang.contrib.cc.get_cc()

Return the path to the default C/C++ compiler.

回傳:

out -- The path to the default C/C++ compiler, or None if none was found.

回傳型別:

Optional[str]

tilelang.contrib.cc.get_cplus_compiler()

Return the path to the default C/C++ compiler.

回傳:

out -- The path to the default C/C++ compiler, or None if none was found.

回傳型別:

Optional[str]

tilelang.contrib.cc.is_darwin()
tilelang.contrib.cc.create_shared(output, objects, options=None, cc=None, cwd=None, ccache_env=None)

Create shared library.

參數:
  • output (str) -- The target shared library.

  • objects (List[str]) -- List of object files.

  • options (List[str]) -- The list of additional options string.

  • cc (Optional[str]) -- The compiler command.

  • cwd (Optional[str]) -- The current working directory.

  • ccache_env (Optional[Dict[str, str]]) -- The environment variable for ccache. Set None to disable ccache by default.

tilelang.contrib.cc.create_staticlib(output, inputs, ar=None)

Create static library.

參數:
  • output (str) -- The target shared library.

  • inputs (List[str]) -- List of inputs files. Each input file can be a tarball of objects or an object file.

  • ar (Optional[str]) -- Path to the ar command to be used

tilelang.contrib.cc.create_executable(output, objects, options=None, cc=None, cwd=None, ccache_env=None)

Create executable binary.

參數:
  • output (str) -- The target executable.

  • objects (List[str]) -- List of object files.

  • options (List[str]) -- The list of additional options string.

  • cc (Optional[str]) -- The compiler command.

  • cwd (Optional[str]) -- The urrent working directory.

  • ccache_env (Optional[Dict[str, str]]) -- The environment variable for ccache. Set None to disable ccache by default.

tilelang.contrib.cc.get_global_symbol_section_map(path, *, nm=None)

Get global symbols from a library via nm -g

參數:
  • path (str) -- The library path

  • nm (str) -- The path to nm command

回傳:

symbol_section_map -- A map from defined global symbol to their sections

回傳型別:

Dict[str, str]

tilelang.contrib.cc.get_target_by_dump_machine(compiler)

Functor of get_target_triple that can get the target triple using compiler.

參數:

compiler (Optional[str]) -- The compiler.

回傳:

out -- A function that can get target triple according to dumpmachine option of compiler.

回傳型別:

Callable

tilelang.contrib.cc.cross_compiler(compile_func, options=None, output_format=None, get_target_triple=None, add_files=None)

Create a cross compiler function by specializing compile_func with options.

This function can be used to construct compile functions that can be passed to AutoTVM measure or export_library.

參數:
  • compile_func (Union[str, Callable[[str, str, Optional[str]], None]]) -- Function that performs the actual compilation

  • options (Optional[List[str]]) -- List of additional optional string.

  • output_format (Optional[str]) -- Library output format.

  • get_target_triple (Optional[Callable]) -- Function that can target triple according to dumpmachine option of compiler.

  • add_files (Optional[List[str]]) -- List of paths to additional object, source, library files to pass as part of the compilation.

回傳:

fcompile -- A compilation function that can be passed to export_library.

回傳型別:

Callable[[str, str, Optional[str]], None]

範例

from tvm.contrib import cc, ndk
# export using arm gcc
mod = build_runtime_module()
mod.export_library(path_dso,
                   fcompile=cc.cross_compiler("arm-linux-gnueabihf-gcc"))
# specialize ndk compilation options.
specialized_ndk = cc.cross_compiler(
    ndk.create_shared,
    ["--sysroot=/path/to/sysroot", "-shared", "-fPIC", "-lm"])
mod.export_library(path_dso, fcompile=specialized_ndk)