diff --git a/python/tvm/driver/tvmc/compiler.py b/python/tvm/driver/tvmc/compiler.py index 6884c30049d19..7498bf7838b54 100644 --- a/python/tvm/driver/tvmc/compiler.py +++ b/python/tvm/driver/tvmc/compiler.py @@ -48,6 +48,11 @@ def add_compile_parser(subparsers): default="", help="the cross compiler to generate target libraries, e.g. 'aarch64-linux-gnu-gcc'", ) + parser.add_argument( + "--cross-compiler-options", + default="", + help="the cross compiler options to generate target libraries, e.g. '-mthumb -mfpu=neon-vfpv4'", + ) parser.add_argument( "--desired-layout", choices=["NCHW", "NHWC"], @@ -133,7 +138,7 @@ def drive_compile(args): if dumps: save_dumps(args.output, dumps) - save_module(args.output, graph, lib, params, args.cross_compiler) + save_module(args.output, graph, lib, params, args.cross_compiler, args.cross_compiler_options) return 0 @@ -253,7 +258,8 @@ def compile_model( return graph_module.get_json(), graph_module.get_lib(), graph_module.get_params(), dumps -def save_module(module_path, graph, lib, params, cross=None): +def save_module(module_path, graph, lib, params, cross=None, + cross_options=None): """ Create a tarball containing the generated TVM graph, exported library and parameters @@ -271,7 +277,7 @@ def save_module(module_path, graph, lib, params, cross=None): The parameters (weights) for the TVM module. cross : str or callable object, optional Function that performs the actual compilation - + cross_options : sst of cross compilation options """ lib_name = "mod.so" graph_name = "mod.json" @@ -283,7 +289,7 @@ def save_module(module_path, graph, lib, params, cross=None): lib.export_library(path_lib) else: logger.debug("exporting library to %s , using cross compiler %s", path_lib, cross) - lib.export_library(path_lib, cc.cross_compiler(cross)) + lib.export_library(path_lib, cc.cross_compiler(cross, options=cross_options.split(' '))) with open(temp.relpath(graph_name), "w") as graph_file: logger.debug("writing graph to file to %s", graph_file.name)