tvm_tirx.support.cc.cross_compiler

Contents

tvm_tirx.support.cc.cross_compiler#

tvm_tirx.support.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.

Parameters:
  • 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.

Returns:

fcompile (Callable[[str, str, Optional[str]], None]) – A compilation function that can be passed to export_library.

Examples

from tvm_tirx.support import cc, ndk
# export using arm gcc
from tvm_tirx.codegen import Executable

mod = build_runtime_module()
Executable(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"])
Executable(mod).export_library(path_dso, fcompile=specialized_ndk)