mlonmcu.flow.tvm.backend package

Submodules

mlonmcu.flow.tvm.backend.backend module

class mlonmcu.flow.tvm.backend.backend.TVMBackend(target='c', executor=None, runtime='crt', fmt='mlf', system_lib=False, features=None, config=None)[source]

Bases: Backend

DEFAULTS = {'autotuned_mode': None, 'autotuned_results_file': None, 'custom_unroll': False, 'desired_layout': None, 'desired_layout_map': None, 'desired_layout_ops': None, 'disable_vectorize': 'auto', 'disabled_passes': [], 'dump': [], 'extra_pass_config': {}, 'extra_target_details': None, 'extra_targets': None, 'generate_wrapper': 'auto', 'num_threads': 4, 'opt_level': 3, 'print_outputs': False, 'refresh_model_info': False, 'relay_debug': None, 'target_device': None, 'target_keys': None, 'target_mabi': None, 'target_march': None, 'target_mattr': None, 'target_mcpu': None, 'target_model': None, 'target_mtriple': None, 'target_num_cores': None, 'tophub_url': None, 'tvmc_custom_script': None, 'tvmc_extra_args': [], 'use_tuning_results': False}
FEATURES = {'autotuned', 'cmsisnnbyoc', 'disable_legalize', 'fuse_ops', 'moiopt', 'muriscvnnbyoc', 'uma_backends'}
OPTIONAL = {'tvm.build_dir', 'tvm.configs_dir', 'tvm.pythonpath', 'tvm.use_tlcpack'}
REQUIRED = {}
property custom_unroll
property desired_layout
property desired_layout_map
property desired_layout_ops
property disable_vectorize
property disabled_passes
property dump
property extra_target_details
property extra_targets
generate() Tuple[dict, dict][source]
property generate_wrapper
get_graph_and_params_from_mlf(path)[source]
get_target_details()[source]
get_tuning_records(tuner_name=None)[source]
get_tvmc_compile_args(out, dump=None)[source]
invoke_tvmc(command, *args, cwd=None)[source]
invoke_tvmc_compile(out, dump=None, cwd=None)[source]
load_model(model, input_shapes=None, output_shapes=None, input_types=None, output_types=None)[source]
name = None
property needs_target
property num_threads
property opt_level
property pass_config
property print_outputs
property refresh_model_info
registry = {}
property relay_debug
set_tuning_records(records, tuner_name=None)[source]
property target_device
property target_keys
property target_mabi
property target_march
property target_mattr
property target_mcpu
property target_model
property target_mtriple
property target_num_cores
property tophub_url
property tvm_build_dir
property tvm_configs_dir
property tvm_pythonpath
property tvmc_custom_script
property tvmc_extra_args
property use_tlcpack
property use_tuning_results

mlonmcu.flow.tvm.backend.model_info module

class mlonmcu.flow.tvm.backend.model_info.ModelInfo(in_tensors, out_tensors, fix_names=False)[source]

Bases: object

property has_ins
property has_outs
class mlonmcu.flow.tvm.backend.model_info.ONNXModelInfo(model_file)[source]

Bases: ModelInfo

class mlonmcu.flow.tvm.backend.model_info.PBModelInfo(model_file)[source]

Bases: ModelInfo

class mlonmcu.flow.tvm.backend.model_info.PaddleModelInfo(model_file)[source]

Bases: ModelInfo

class mlonmcu.flow.tvm.backend.model_info.RelayModelInfo(mod_text, fix_names=False)[source]

Bases: ModelInfo

class mlonmcu.flow.tvm.backend.model_info.RelayTensorInfo(name, shape, dtype, fix_names=False)[source]

Bases: TensorInfo

class mlonmcu.flow.tvm.backend.model_info.TensorInfo(name, shape, dtype, fix_names=False)[source]

Bases: object

property size
class mlonmcu.flow.tvm.backend.model_info.TfLiteModelInfo(model, fix_names=False)[source]

Bases: ModelInfo

class mlonmcu.flow.tvm.backend.model_info.TfLiteTensorInfo(t, fix_names=False)[source]

Bases: TensorInfo

mlonmcu.flow.tvm.backend.model_info.get_fallback_model_info(model, input_shapes, output_shapes, input_types, output_types, backend_name='unknown')[source]
mlonmcu.flow.tvm.backend.model_info.get_model_format(model)[source]
mlonmcu.flow.tvm.backend.model_info.get_model_info(model, backend_name='unknown')[source]
mlonmcu.flow.tvm.backend.model_info.get_onnx_model_info(model_file)[source]
mlonmcu.flow.tvm.backend.model_info.get_paddle_model_info(model_file)[source]
mlonmcu.flow.tvm.backend.model_info.get_pb_model_info(model_file)[source]
mlonmcu.flow.tvm.backend.model_info.get_relay_model_info(mod_text)[source]
mlonmcu.flow.tvm.backend.model_info.get_supported_formats()[source]
mlonmcu.flow.tvm.backend.model_info.get_tfgraph_inout(graph)[source]
mlonmcu.flow.tvm.backend.model_info.get_tflite_model_info(model_buf)[source]
mlonmcu.flow.tvm.backend.model_info.parse_relay_main(line)[source]
mlonmcu.flow.tvm.backend.model_info.shape_from_str(shape_str)[source]

mlonmcu.flow.tvm.backend.python_utils module

mlonmcu.flow.tvm.backend.python_utils.prepare_python_environment(pythonpath, tvm_build_dir, tvm_configs_dir, tophub_url=None, num_threads=None, debug_cfg=None)[source]

mlonmcu.flow.tvm.backend.tuner module

mlonmcu.flow.tvm.backend.tuner.get_autoscheduler_defaults()[source]
mlonmcu.flow.tvm.backend.tuner.get_autotuning_defaults()[source]
mlonmcu.flow.tvm.backend.tuner.get_autotvm_defaults()[source]
mlonmcu.flow.tvm.backend.tuner.get_metascheduler_defaults()[source]

mlonmcu.flow.tvm.backend.tvmaot module

class mlonmcu.flow.tvm.backend.tvmaot.TVMAOTBackend(runtime='crt', fmt='mlf', system_lib=False, features=None, config=None)[source]

Bases: TVMBackend

DEFAULTS = {'alignment_bytes': 16, 'arena_size': None, 'autotuned_mode': None, 'autotuned_results_file': None, 'custom_unroll': False, 'debug_arena': False, 'desired_layout': None, 'desired_layout_map': None, 'desired_layout_ops': None, 'disable_vectorize': 'auto', 'disabled_passes': [], 'dump': [], 'extra_pass_config': {'tir.usmp.enable': False}, 'extra_target_details': None, 'extra_targets': None, 'generate_wrapper': 'auto', 'num_threads': 4, 'opt_level': 3, 'print_outputs': False, 'refresh_model_info': False, 'relay_debug': None, 'target_device': None, 'target_keys': None, 'target_mabi': None, 'target_march': None, 'target_mattr': None, 'target_mcpu': None, 'target_model': None, 'target_mtriple': None, 'target_num_cores': None, 'tophub_url': None, 'tvmc_custom_script': None, 'tvmc_extra_args': [], 'unpacked_api': False, 'use_tuning_results': False}
FEATURES = {'autotuned', 'cmsisnnbyoc', 'debug_arena', 'disable_legalize', 'fuse_ops', 'moiopt', 'muriscvnnbyoc', 'uma_backends', 'unpacked_api', 'usmp'}
property alignment_bytes
property arena_size
property debug_arena
generate() Tuple[dict, dict][source]
get_tvmc_compile_args(out, dump=None)[source]
get_workspace_size_from_metadata(metadata)[source]
name = 'tvmaot'
property unpacked_api

mlonmcu.flow.tvm.backend.tvmaotplus module

class mlonmcu.flow.tvm.backend.tvmaotplus.TVMAOTPlusBackend(runtime='crt', fmt='mlf', system_lib=False, features=None, config=None)[source]

Bases: TVMAOTBackend

DEFAULTS = {'alignment_bytes': 16, 'arena_size': 0, 'autotuned_mode': None, 'autotuned_results_file': None, 'custom_unroll': False, 'debug_arena': False, 'desired_layout': None, 'desired_layout_map': None, 'desired_layout_ops': None, 'disable_vectorize': 'auto', 'disabled_passes': [], 'dump': [], 'extra_pass_config': {'tir.usmp.algorithm': 'hill_climb', 'tir.usmp.enable': True}, 'extra_target_details': None, 'extra_targets': None, 'generate_wrapper': 'auto', 'num_threads': 4, 'opt_level': 3, 'print_outputs': False, 'refresh_model_info': False, 'relay_debug': None, 'target_device': None, 'target_keys': None, 'target_mabi': None, 'target_march': None, 'target_mattr': None, 'target_mcpu': None, 'target_model': None, 'target_mtriple': None, 'target_num_cores': None, 'tophub_url': None, 'tvmc_custom_script': None, 'tvmc_extra_args': [], 'unpacked_api': True, 'use_tuning_results': False}
name = 'tvmaotplus'

mlonmcu.flow.tvm.backend.tvmc_utils module

mlonmcu.flow.tvm.backend.tvmc_utils.check_allowed(target, name)[source]
mlonmcu.flow.tvm.backend.tvmc_utils.gen_extra_target_details_args(extra_target_details)[source]
mlonmcu.flow.tvm.backend.tvmc_utils.gen_target_details_args(target, target_details)[source]
mlonmcu.flow.tvm.backend.tvmc_utils.get_bench_tvmc_args(print_time=False, profile=False, end_to_end=False, repeat=1, number=1)[source]
mlonmcu.flow.tvm.backend.tvmc_utils.get_data_tvmc_args(mode=None, ins_file=None, outs_file=None, print_top=10)[source]
mlonmcu.flow.tvm.backend.tvmc_utils.get_desired_layout_args(layouts, ops, mapping)[source]
mlonmcu.flow.tvm.backend.tvmc_utils.get_disabled_pass_tvmc_args(disabled_passes)[source]
mlonmcu.flow.tvm.backend.tvmc_utils.get_input_shapes_tvmc_args(input_shapes)[source]
mlonmcu.flow.tvm.backend.tvmc_utils.get_pass_config_tvmc_args(pass_config)[source]
mlonmcu.flow.tvm.backend.tvmc_utils.get_rpc_tvmc_args(enabled, key, hostname, port)[source]
mlonmcu.flow.tvm.backend.tvmc_utils.get_runtime_executor_tvmc_args(runtime, executor)[source]
mlonmcu.flow.tvm.backend.tvmc_utils.get_target_tvmc_args(target='c', extra_targets=[], target_details={}, extra_target_details={})[source]
mlonmcu.flow.tvm.backend.tvmc_utils.get_tuning_records_tvmc_args(use_tuning_results, tuning_records_file)[source]
mlonmcu.flow.tvm.backend.tvmc_utils.get_tvmaot_tvmc_args(alignment_bytes, unpacked_api, runtime='crt', target='c', system_lib=False)[source]
mlonmcu.flow.tvm.backend.tvmc_utils.get_tvmrt_tvmc_args(runtime='crt', system_lib=True, link_params=True)[source]

mlonmcu.flow.tvm.backend.tvmcg module

class mlonmcu.flow.tvm.backend.tvmcg.TVMCGBackend(runtime='crt', fmt='mlf', system_lib=True, features=None, config=None)[source]

Bases: TVMRTBackend

REQUIRED = {'utvmcg.exe'}
generate() Tuple[dict, dict][source]
get_max_workspace_size_from_metadata(metadata)[source]
name = 'tvmcg'

mlonmcu.flow.tvm.backend.tvmllvm module

class mlonmcu.flow.tvm.backend.tvmllvm.TVMLLVMBackend(runtime='crt', fmt='mlf', system_lib=True, features=None, config=None)[source]

Bases: TVMBackend

DEFAULTS = {'arena_size': 1048576, 'autotuned_mode': None, 'autotuned_results_file': None, 'custom_unroll': False, 'debug_arena': False, 'desired_layout': None, 'desired_layout_map': None, 'desired_layout_ops': None, 'disable_vectorize': 'auto', 'disabled_passes': [], 'dump': [], 'extra_pass_config': {}, 'extra_target_details': None, 'extra_targets': None, 'generate_wrapper': 'auto', 'num_threads': 4, 'opt_level': 3, 'print_outputs': False, 'refresh_model_info': False, 'relay_debug': None, 'target_device': None, 'target_keys': None, 'target_mabi': None, 'target_march': None, 'target_mattr': None, 'target_mcpu': None, 'target_model': None, 'target_mtriple': None, 'target_num_cores': None, 'tophub_url': None, 'tvmc_custom_script': None, 'tvmc_extra_args': [], 'use_tuning_results': False}
FEATURES = {'autotuned', 'cmsisnnbyoc', 'debug_arena', 'disable_legalize', 'fuse_ops', 'moiopt', 'muriscvnnbyoc', 'uma_backends'}
property arena_size
property debug_arena
generate() Tuple[dict, dict][source]
get_graph_and_params_from_mlf(path)[source]
get_tvmc_compile_args(out, dump=None)[source]
name = 'tvmllvm'

mlonmcu.flow.tvm.backend.tvmrt module

class mlonmcu.flow.tvm.backend.tvmrt.TVMRTBackend(runtime='crt', fmt='mlf', system_lib=True, features=None, config=None)[source]

Bases: TVMBackend

DEFAULTS = {'arena_size': 1048576, 'autotuned_mode': None, 'autotuned_results_file': None, 'custom_unroll': False, 'debug_arena': False, 'desired_layout': None, 'desired_layout_map': None, 'desired_layout_ops': None, 'disable_vectorize': 'auto', 'disabled_passes': [], 'dump': [], 'extra_pass_config': {}, 'extra_target_details': None, 'extra_targets': None, 'generate_wrapper': 'auto', 'num_threads': 4, 'opt_level': 3, 'print_outputs': False, 'refresh_model_info': False, 'relay_debug': None, 'target_device': None, 'target_keys': None, 'target_mabi': None, 'target_march': None, 'target_mattr': None, 'target_mcpu': None, 'target_model': None, 'target_mtriple': None, 'target_num_cores': None, 'tophub_url': None, 'tvmc_custom_script': None, 'tvmc_extra_args': [], 'use_tuning_results': False}
FEATURES = {'autotuned', 'cmsisnnbyoc', 'debug_arena', 'disable_legalize', 'fuse_ops', 'moiopt', 'muriscvnnbyoc', 'uma_backends'}
property arena_size
property debug_arena
generate() Tuple[dict, dict][source]
get_tvmc_compile_args(out, dump=None)[source]
name = 'tvmrt'

mlonmcu.flow.tvm.backend.wrapper module

TODO

mlonmcu.flow.tvm.backend.wrapper.calc_pages(workspace_size, page_size=1024)[source]
mlonmcu.flow.tvm.backend.wrapper.fill(template, **kwargs)[source]
mlonmcu.flow.tvm.backend.wrapper.generate_aot_includes(allocator)[source]
mlonmcu.flow.tvm.backend.wrapper.generate_common_includes()[source]
mlonmcu.flow.tvm.backend.wrapper.generate_graph_includes()[source]
mlonmcu.flow.tvm.backend.wrapper.generate_header()[source]
mlonmcu.flow.tvm.backend.wrapper.generate_tvmaot_wrapper(model_info, workspace_size, mod_name, api='c', debug_arena=False)[source]
mlonmcu.flow.tvm.backend.wrapper.generate_tvmrt_wrapper(graph, params, model_info, workspace_size, debug_arena=False)[source]
mlonmcu.flow.tvm.backend.wrapper.generate_wrapper_header()[source]
mlonmcu.flow.tvm.backend.wrapper.getSizes(tensors)[source]
mlonmcu.flow.tvm.backend.wrapper.write_tvmaot_wrapper(path, model_info, workspace_size, mod_name, api='c')[source]
mlonmcu.flow.tvm.backend.wrapper.write_tvmrt_wrapper(path, graph, params, model_info, workspace_size)[source]

Module contents

class mlonmcu.flow.tvm.backend.TVMAOTBackend(runtime='crt', fmt='mlf', system_lib=False, features=None, config=None)[source]

Bases: TVMBackend

DEFAULTS = {'alignment_bytes': 16, 'arena_size': None, 'autotuned_mode': None, 'autotuned_results_file': None, 'custom_unroll': False, 'debug_arena': False, 'desired_layout': None, 'desired_layout_map': None, 'desired_layout_ops': None, 'disable_vectorize': 'auto', 'disabled_passes': [], 'dump': [], 'extra_pass_config': {'tir.usmp.enable': False}, 'extra_target_details': None, 'extra_targets': None, 'generate_wrapper': 'auto', 'num_threads': 4, 'opt_level': 3, 'print_outputs': False, 'refresh_model_info': False, 'relay_debug': None, 'target_device': None, 'target_keys': None, 'target_mabi': None, 'target_march': None, 'target_mattr': None, 'target_mcpu': None, 'target_model': None, 'target_mtriple': None, 'target_num_cores': None, 'tophub_url': None, 'tvmc_custom_script': None, 'tvmc_extra_args': [], 'unpacked_api': False, 'use_tuning_results': False}
FEATURES = {'autotuned', 'cmsisnnbyoc', 'debug_arena', 'disable_legalize', 'fuse_ops', 'moiopt', 'muriscvnnbyoc', 'uma_backends', 'unpacked_api', 'usmp'}
property alignment_bytes
property arena_size
property debug_arena
generate() Tuple[dict, dict][source]
get_tvmc_compile_args(out, dump=None)[source]
get_workspace_size_from_metadata(metadata)[source]
name = 'tvmaot'
property unpacked_api
class mlonmcu.flow.tvm.backend.TVMAOTPlusBackend(runtime='crt', fmt='mlf', system_lib=False, features=None, config=None)[source]

Bases: TVMAOTBackend

DEFAULTS = {'alignment_bytes': 16, 'arena_size': 0, 'autotuned_mode': None, 'autotuned_results_file': None, 'custom_unroll': False, 'debug_arena': False, 'desired_layout': None, 'desired_layout_map': None, 'desired_layout_ops': None, 'disable_vectorize': 'auto', 'disabled_passes': [], 'dump': [], 'extra_pass_config': {'tir.usmp.algorithm': 'hill_climb', 'tir.usmp.enable': True}, 'extra_target_details': None, 'extra_targets': None, 'generate_wrapper': 'auto', 'num_threads': 4, 'opt_level': 3, 'print_outputs': False, 'refresh_model_info': False, 'relay_debug': None, 'target_device': None, 'target_keys': None, 'target_mabi': None, 'target_march': None, 'target_mattr': None, 'target_mcpu': None, 'target_model': None, 'target_mtriple': None, 'target_num_cores': None, 'tophub_url': None, 'tvmc_custom_script': None, 'tvmc_extra_args': [], 'unpacked_api': True, 'use_tuning_results': False}
name = 'tvmaotplus'
class mlonmcu.flow.tvm.backend.TVMBackend(target='c', executor=None, runtime='crt', fmt='mlf', system_lib=False, features=None, config=None)[source]

Bases: Backend

DEFAULTS = {'autotuned_mode': None, 'autotuned_results_file': None, 'custom_unroll': False, 'desired_layout': None, 'desired_layout_map': None, 'desired_layout_ops': None, 'disable_vectorize': 'auto', 'disabled_passes': [], 'dump': [], 'extra_pass_config': {}, 'extra_target_details': None, 'extra_targets': None, 'generate_wrapper': 'auto', 'num_threads': 4, 'opt_level': 3, 'print_outputs': False, 'refresh_model_info': False, 'relay_debug': None, 'target_device': None, 'target_keys': None, 'target_mabi': None, 'target_march': None, 'target_mattr': None, 'target_mcpu': None, 'target_model': None, 'target_mtriple': None, 'target_num_cores': None, 'tophub_url': None, 'tvmc_custom_script': None, 'tvmc_extra_args': [], 'use_tuning_results': False}
FEATURES = {'autotuned', 'cmsisnnbyoc', 'disable_legalize', 'fuse_ops', 'moiopt', 'muriscvnnbyoc', 'uma_backends'}
OPTIONAL = {'tvm.build_dir', 'tvm.configs_dir', 'tvm.pythonpath', 'tvm.use_tlcpack'}
REQUIRED = {}
property custom_unroll
property desired_layout
property desired_layout_map
property desired_layout_ops
property disable_vectorize
property disabled_passes
property dump
property extra_target_details
property extra_targets
generate() Tuple[dict, dict][source]
property generate_wrapper
get_graph_and_params_from_mlf(path)[source]
get_target_details()[source]
get_tuning_records(tuner_name=None)[source]
get_tvmc_compile_args(out, dump=None)[source]
invoke_tvmc(command, *args, cwd=None)[source]
invoke_tvmc_compile(out, dump=None, cwd=None)[source]
load_model(model, input_shapes=None, output_shapes=None, input_types=None, output_types=None)[source]
name = None
property needs_target
property num_threads
property opt_level
property pass_config
property print_outputs
property refresh_model_info
registry = {}
property relay_debug
set_tuning_records(records, tuner_name=None)[source]
property target_device
property target_keys
property target_mabi
property target_march
property target_mattr
property target_mcpu
property target_model
property target_mtriple
property target_num_cores
property tophub_url
property tvm_build_dir
property tvm_configs_dir
property tvm_pythonpath
property tvmc_custom_script
property tvmc_extra_args
property use_tlcpack
property use_tuning_results
class mlonmcu.flow.tvm.backend.TVMCGBackend(runtime='crt', fmt='mlf', system_lib=True, features=None, config=None)[source]

Bases: TVMRTBackend

REQUIRED = {'utvmcg.exe'}
generate() Tuple[dict, dict][source]
get_max_workspace_size_from_metadata(metadata)[source]
name = 'tvmcg'
class mlonmcu.flow.tvm.backend.TVMLLVMBackend(runtime='crt', fmt='mlf', system_lib=True, features=None, config=None)[source]

Bases: TVMBackend

DEFAULTS = {'arena_size': 1048576, 'autotuned_mode': None, 'autotuned_results_file': None, 'custom_unroll': False, 'debug_arena': False, 'desired_layout': None, 'desired_layout_map': None, 'desired_layout_ops': None, 'disable_vectorize': 'auto', 'disabled_passes': [], 'dump': [], 'extra_pass_config': {}, 'extra_target_details': None, 'extra_targets': None, 'generate_wrapper': 'auto', 'num_threads': 4, 'opt_level': 3, 'print_outputs': False, 'refresh_model_info': False, 'relay_debug': None, 'target_device': None, 'target_keys': None, 'target_mabi': None, 'target_march': None, 'target_mattr': None, 'target_mcpu': None, 'target_model': None, 'target_mtriple': None, 'target_num_cores': None, 'tophub_url': None, 'tvmc_custom_script': None, 'tvmc_extra_args': [], 'use_tuning_results': False}
FEATURES = {'autotuned', 'cmsisnnbyoc', 'debug_arena', 'disable_legalize', 'fuse_ops', 'moiopt', 'muriscvnnbyoc', 'uma_backends'}
property arena_size
property debug_arena
generate() Tuple[dict, dict][source]
get_graph_and_params_from_mlf(path)[source]
get_tvmc_compile_args(out, dump=None)[source]
name = 'tvmllvm'
class mlonmcu.flow.tvm.backend.TVMRTBackend(runtime='crt', fmt='mlf', system_lib=True, features=None, config=None)[source]

Bases: TVMBackend

DEFAULTS = {'arena_size': 1048576, 'autotuned_mode': None, 'autotuned_results_file': None, 'custom_unroll': False, 'debug_arena': False, 'desired_layout': None, 'desired_layout_map': None, 'desired_layout_ops': None, 'disable_vectorize': 'auto', 'disabled_passes': [], 'dump': [], 'extra_pass_config': {}, 'extra_target_details': None, 'extra_targets': None, 'generate_wrapper': 'auto', 'num_threads': 4, 'opt_level': 3, 'print_outputs': False, 'refresh_model_info': False, 'relay_debug': None, 'target_device': None, 'target_keys': None, 'target_mabi': None, 'target_march': None, 'target_mattr': None, 'target_mcpu': None, 'target_model': None, 'target_mtriple': None, 'target_num_cores': None, 'tophub_url': None, 'tvmc_custom_script': None, 'tvmc_extra_args': [], 'use_tuning_results': False}
FEATURES = {'autotuned', 'cmsisnnbyoc', 'debug_arena', 'disable_legalize', 'fuse_ops', 'moiopt', 'muriscvnnbyoc', 'uma_backends'}
property arena_size
property debug_arena
generate() Tuple[dict, dict][source]
get_tvmc_compile_args(out, dump=None)[source]
name = 'tvmrt'