tvm.micro

MicroTVM module for bare-metal backends

Classes

LibType

Enumeration of library types that can be compiled and loaded onto a device

Session(config)

MicroTVM Device Session

Functions

create_micro_mod(c_mod, dev_config[, …])

Produces a micro module from a given module.

cross_compiler(dev_config, lib_type[, …])

Create a cross compile function that wraps create_lib for a Binutil instance.

get_micro_device_dir()

Get directory path for parent directory of device-specific source files

get_micro_host_driven_dir()

Get directory path for uTVM host-driven runtime source files.

class tvm.micro.Session(config)

MicroTVM Device Session

Parameters

config (dict) – configuration for this session (as generated by tvm.micro.device.host.default_config(), for example)

Example

c_mod = ...  # some module generated with "c" as the target
dev_config = micro.device.arm.stm32f746xx.default_config('127.0.0.1', 6666)
with tvm.micro.Session(dev_config) as sess:
    micro_mod = sess.create_micro_mod(c_mod)
tvm.micro.create_micro_mod(c_mod, dev_config, lib_src_paths=None, lib_headers=None, lib_include_paths=None)

Produces a micro module from a given module.

Parameters
  • c_mod (tvm.module.Module) – module with “c” as its target backend

  • lib_src_paths (TODO) – TODO

  • lib_headers (TODO) – TODO

  • lib_include_paths (TODO) – TODO

Returns

micro_mod – micro module for the target device

Return type

tvm.module.Module

tvm.micro.cross_compiler(dev_config, lib_type, lib_src_paths=None, lib_headers=None, lib_include_paths=None)

Create a cross compile function that wraps create_lib for a Binutil instance.

For use in tvm.runtime.Module.export_library.

Parameters
  • create_micro_lib (func) – function for creating MicroTVM libraries for a specific device (e.g., tvm.micro.device.get_device_funcs(‘arm.stm32f746xx’)[‘create_micro_lib’])

  • lib_type (micro.LibType) – whether to compile a MicroTVM runtime or operator library

  • lib_src_paths (TODO) – TODO

  • lib_headers (TODO) – e.g., [‘cmsis_gcc.h’, ‘arm_math.h’]

  • lib_include_paths (TODO) – TODO

Returns

func – cross compile function taking a destination path for the object file and a path for the input source file.

Return type

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

Example

c_mod = ...  # some module generated with "c" as the target
fcompile = tvm.micro.cross_compiler(dev_config, LibType.OPERATOR)
c_mod.export_library('dev_lib.obj', fcompile=fcompile)
class tvm.micro.LibType

Enumeration of library types that can be compiled and loaded onto a device

tvm.micro.get_micro_host_driven_dir()

Get directory path for uTVM host-driven runtime source files.

Returns

micro_device_dir – directory path

Return type

str

tvm.micro.get_micro_device_dir()

Get directory path for parent directory of device-specific source files

Returns

micro_device_dir – directory path

Return type

str