Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/android_camera/models/prepare_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def main(model_str, output_path):
with tvm.transform.PassContext(opt_level=3):
graph, lib, params = relay.build(net, tvm.target.Target(target, target_host), params=params)
print("dumping lib...")
lib.export_library(output_path_str + "/" + "deploy_lib_cpu.so", ndk.create_shared)
lib.export_library(output_path_str + "/" + "deploy_lib_cpu.so", fcompile=ndk.create_shared)
print("dumping graph...")
with open(output_path_str + "/" + "deploy_graph.json", "w") as f:
f.write(graph)
Expand Down
6 changes: 3 additions & 3 deletions apps/android_rpc/tests/android_rpc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_rpc_module():
s[B].pragma(xi, "parallel_barrier_when_finish")
f = tvm.build(s, [A, B], target, name="myadd_cpu")
path_dso_cpu = temp.relpath("cpu_lib.so")
f.export_library(path_dso_cpu, ndk.create_shared)
f.export_library(path_dso_cpu, fcompile=ndk.create_shared)

# Execute the portable graph on cpu target
print("Run CPU test ...")
Expand All @@ -88,7 +88,7 @@ def test_rpc_module():
# If we don't want to do metal and only use cpu, just set target to be target
f = tvm.build(s, [A, B], tvm.target.Target("opencl", host=target), name="myadd")
path_dso_cl = temp.relpath("dev_lib_cl.so")
f.export_library(path_dso_cl, ndk.create_shared)
f.export_library(path_dso_cl, fcompile=ndk.create_shared)

print("Run GPU(OpenCL Flavor) test ...")
dev = remote.cl(0)
Expand All @@ -111,7 +111,7 @@ def test_rpc_module():
# If we don't want to do metal and only use cpu, just set target to be target
f = tvm.build(s, [A, B], tvm.target.Target("vulkan", host=target), name="myadd")
path_dso_vulkan = temp.relpath("dev_lib_vulkan.so")
f.export_library(path_dso_vulkan, ndk.create_shared)
f.export_library(path_dso_vulkan, fcompile=ndk.create_shared)

print("Run GPU(Vulkan Flavor) test ...")
dev = remote.vulkan(0)
Expand Down
2 changes: 1 addition & 1 deletion apps/benchmark/adreno/adreno_gpu_bench_clml.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def evaluate_network(network, target, target_host, dtype, repeat):
tmp = tempdir()

filename = "%s.so" % network
lib.export_library(tmp.relpath(filename), ndk.create_shared)
lib.export_library(tmp.relpath(filename), fcompile=ndk.create_shared)

# upload library and params
print_progress("%-20s uploading..." % network)
Expand Down
2 changes: 1 addition & 1 deletion apps/benchmark/adreno/adreno_gpu_bench_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def evaluate_network(network, target, target_host, dtype, repeat):
tmp = tempdir()

filename = "%s.so" % network
lib.export_library(tmp.relpath(filename), ndk.create_shared)
lib.export_library(tmp.relpath(filename), fcompile=ndk.create_shared)

# upload library and params
print_progress("%-20s uploading..." % network)
Expand Down
2 changes: 1 addition & 1 deletion apps/benchmark/arm_cpu_imagenet_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def evaluate_network(network, target, target_host, repeat):
from tvm.contrib import ndk

filename = "%s.so" % network
lib.export_library(tmp.relpath(filename), ndk.create_shared)
lib.export_library(tmp.relpath(filename), fcompile=ndk.create_shared)
else:
filename = "%s.tar" % network
lib.export_library(tmp.relpath(filename))
Expand Down
2 changes: 1 addition & 1 deletion apps/benchmark/mobile_gpu_imagenet_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def evaluate_network(network, target, target_host, dtype, repeat):
from tvm.contrib import ndk

filename = "%s.so" % network
lib.export_library(tmp.relpath(filename), ndk.create_shared)
lib.export_library(tmp.relpath(filename), fcompile=ndk.create_shared)
else:
filename = "%s.tar" % network
lib.export_library(tmp.relpath(filename))
Expand Down
2 changes: 1 addition & 1 deletion apps/hexagon_launcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ lowered = tvm.relay.build(
executor=Executor("aot", {"unpacked-api": False, "interface-api": "packed"}),
)
lowered.export_library("model-aot.so", tvm.contrib.hexagon.link_shared)
lowered.export_library("model-aot.so", fcompile=tvm.contrib.hexagon.link_shared)
```


Expand Down
2 changes: 1 addition & 1 deletion apps/ios_rpc/tests/ios_rpc_mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def run(mod, target):
mod, target=tvm.target.Target(target, host=target_host), params=params
)
path_dso = temp.relpath("deploy.dylib")
lib.export_library(path_dso, xcode.create_dylib, arch=arch, sdk=sdk)
lib.export_library(path_dso, fcompile=xcode.create_dylib, arch=arch, sdk=sdk)

# connect to the proxy
if mode == "tracker":
Expand Down
4 changes: 2 additions & 2 deletions apps/ios_rpc/tests/ios_rpc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_rpc_module(host, port, key, mode):
# If we don't want to do metal and only use cpu, just set target to be target
f = tvm.build(s, [A, B], tvm.target.Target("metal", host=target), name="myadd")
path_dso1 = temp.relpath("dev_lib.dylib")
f.export_library(path_dso1, xcode.create_dylib, arch=arch, sdk=sdk)
f.export_library(path_dso1, fcompile=xcode.create_dylib, arch=arch, sdk=sdk)

s = te.create_schedule(B.op)
xo, xi = s[B].split(B.op.axis[0], factor=64)
Expand All @@ -67,7 +67,7 @@ def test_rpc_module(host, port, key, mode):
s[B].pragma(xi, "parallel_barrier_when_finish")
f = tvm.build(s, [A, B], target, name="myadd_cpu")
path_dso2 = temp.relpath("cpu_lib.dylib")
f.export_library(path_dso2, xcode.create_dylib, arch=arch, sdk=sdk)
f.export_library(path_dso2, fcompile=xcode.create_dylib, arch=arch, sdk=sdk)

# connect to the proxy
if mode == "tracker":
Expand Down
2 changes: 1 addition & 1 deletion apps/topi_recipe/gemm/android_gemm_square.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_gemm_gpu(N, times, bn, num_block, num_thread):
f = tvm.build(s, [A, B, C], tvm.target.Target("opencl", host=target), name="gemm_gpu")
temp = utils.tempdir()
path_dso = temp.relpath("gemm_gpu.so")
f.export_library(path_dso, ndk.create_shared)
f.export_library(path_dso, fcompile=ndk.create_shared)

# connect to the proxy
remote = rpc.connect(proxy_host, proxy_port, key=key)
Expand Down
2 changes: 1 addition & 1 deletion docs/how_to/deploy/android.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The code below will save the compilation output which is required on android tar

.. code:: python

lib.export_library("deploy_lib.so", ndk.create_shared)
lib.export_library("deploy_lib.so", fcompile=ndk.create_shared)
with open("deploy_graph.json", "w") as fo:
fo.write(graph.json())
with open("deploy_param.params", "wb") as fo:
Expand Down
2 changes: 1 addition & 1 deletion gallery/how_to/deploy_models/deploy_model_on_adreno.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@
dso_binary = "dev_lib_cl.so"
dso_binary_path = temp.relpath(dso_binary)
fcompile = ndk.create_shared if not local_demo else None
lib.export_library(dso_binary_path, fcompile)
lib.export_library(dso_binary_path, fcompile=fcompile)
remote_path = "/data/local/tmp/" + dso_binary
remote.upload(dso_binary_path)
rlib = remote.load_module(dso_binary)
Expand Down
2 changes: 1 addition & 1 deletion gallery/how_to/deploy_models/deploy_model_on_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def transform_image(image):
tmp = utils.tempdir()
lib_fname = tmp.relpath("net.so")
fcompile = ndk.create_shared if not local_demo else None
lib.export_library(lib_fname, fcompile)
lib.export_library(lib_fname, fcompile=fcompile)

######################################################################
# Deploy the Model Remotely by RPC
Expand Down
2 changes: 1 addition & 1 deletion gallery/how_to/tune_with_autoscheduler/tune_network_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def tune_and_evaluate():
from tvm.contrib import ndk

filename = "net.so"
lib.export_library(tmp.relpath(filename), ndk.create_shared)
lib.export_library(tmp.relpath(filename), fcompile=ndk.create_shared)
else:
filename = "net.tar"
lib.export_library(tmp.relpath(filename))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def tune_and_evaluate():
temp = utils.tempdir()
filename = "deploy_lib.so"
path_lib = temp.relpath(filename)
lib.export_library(path_lib, ndk.create_shared)
lib.export_library(path_lib, fcompile=ndk.create_shared)
remote.upload(path_lib)
loaded_lib = remote.load_module(filename)
module = graph_executor.GraphModule(loaded_lib["default"](dev))
Expand Down
2 changes: 1 addition & 1 deletion gallery/how_to/tune_with_autotvm/tune_relay_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def tune_and_evaluate(tuning_opt):
from tvm.contrib import ndk

filename = "net.so"
lib.export_library(tmp.relpath(filename), ndk.create_shared)
lib.export_library(tmp.relpath(filename), fcompile=ndk.create_shared)
else:
filename = "net.tar"
lib.export_library(tmp.relpath(filename))
Expand Down
2 changes: 1 addition & 1 deletion gallery/how_to/tune_with_autotvm/tune_relay_mobile_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def tune_and_evaluate(tuning_opt):
from tvm.contrib import ndk

filename = "net.so"
lib.export_library(tmp.relpath(filename), ndk.create_shared)
lib.export_library(tmp.relpath(filename), fcompile=ndk.create_shared)
else:
filename = "net.tar"
lib.export_library(tmp.relpath(filename))
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/auto_scheduler/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def _local_build_worker(inp_serialized, build_func, verbose):
try:
with transform.PassContext().current():
func = build_module.build(sch, args, target=task.target)
func.export_library(filename, build_func)
func.export_library(filename, fcompile=build_func)
# pylint: disable=broad-except
except Exception:
error_no = MeasureErrorNo.COMPILE_HOST
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/autotvm/measure/measure_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def __call__(self, measure_input, tmp_dir, **kwargs):
raise ImportError("Requires USE_MICRO")
micro.export_model_library_format(func, filename)
else:
func.export_library(filename, self.build_func)
func.export_library(filename, fcompile=self.build_func)
except Exception as e: # pylint: disable=broad-except
tb = traceback.format_exc()
return BuildResult(None, None, (tb, e), time.time() - tic)
Expand Down
4 changes: 2 additions & 2 deletions python/tvm/contrib/cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ def cross_compiler(
# export using arm gcc
mod = build_runtime_module()
mod.export_library(path_dso,
cc.cross_compiler("arm-linux-gnueabihf-gcc"))
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, specialized_ndk)
mod.export_library(path_dso, fcompile=specialized_ndk)
"""
base_options = [] if options is None else options
kwargs = {}
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/contrib/pipeline_executor_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def export_library(factory, directory_path):
# Get the graph, lib, and parameters from GraphExecutorFactoryModule.
lib = factory.pipeline_mods[lib_index]["lib"]
# Export the lib, graph, and parameters to disk.
lib.export_library(mconfig["lib_name"], fcompile)
lib.export_library(mconfig["lib_name"], fcompile=fcompile)
with open(mconfig["json_name"], "w") as file_handle:
file_handle.write(lib.graph_json)
with open(mconfig["params_name"], "wb") as file_handle:
Expand Down
5 changes: 3 additions & 2 deletions python/tvm/driver/tvmc/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,12 @@ def export_classic_format(
else:
if not cross_options:
executor_factory.get_lib().export_library(
path_lib, tvm.contrib.cc.cross_compiler(cross)
path_lib, fcompile=tvm.contrib.cc.cross_compiler(cross)
)
else:
executor_factory.get_lib().export_library(
path_lib, tvm.contrib.cc.cross_compiler(cross, options=cross_options.split(" "))
path_lib,
fcompile=tvm.contrib.cc.cross_compiler(cross, options=cross_options.split(" ")),
)
self.lib_path = path_lib

Expand Down
2 changes: 1 addition & 1 deletion python/tvm/meta_schedule/builder/local_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,5 @@ def default_export(mod: Module) -> str:
from tvm.contrib.tar import tar # pylint: disable=import-outside-toplevel

artifact_path = os.path.join(tempfile.mkdtemp(), "tvm_tmp_mod." + tar.output_format)
mod.export_library(artifact_path, tar)
mod.export_library(artifact_path, fcompile=tar)
return artifact_path
2 changes: 1 addition & 1 deletion python/tvm/meta_schedule/testing/custom_builder_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def run_module_via_rpc(
filename = os.path.join(tmp_dir, "tvm_tmp_mod." + tar.output_format)
if backend == "vm":
code, lib = lib.save()
lib.export_library(filename, tar)
lib.export_library(filename, fcompile=tar)
session = rpc_config.connect_server()
session.upload(filename)
_, filename = os.path.split(filename)
Expand Down
4 changes: 2 additions & 2 deletions python/tvm/relay/backend/executor_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def get_lib(self):
return self.lib

def export_library(self, file_name, fcompile=None, addons=None, **kwargs):
return self.module.export_library(file_name, fcompile, addons, **kwargs)
return self.module.export_library(file_name, fcompile=fcompile, addons=addons, **kwargs)


class GraphExecutorFactoryModule(ExecutorFactoryModule):
Expand Down Expand Up @@ -200,7 +200,7 @@ def __init__(
self.function_metadata = function_metadata

def export_library(self, file_name, fcompile=None, addons=None, **kwargs):
return self.module.export_library(file_name, fcompile, addons, **kwargs)
return self.module.export_library(file_name, fcompile=fcompile, addons=addons, **kwargs)

def get_devices(self):
return []
Expand Down
4 changes: 3 additions & 1 deletion python/tvm/runtime/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ def _collect_from_import_tree(self, filter_func):
def _collect_dso_modules(self):
return self._collect_from_import_tree(lambda m: m.is_dso_exportable)

def export_library(self, file_name, fcompile=None, addons=None, workspace_dir=None, **kwargs):
def export_library(
self, file_name, *, fcompile=None, addons=None, workspace_dir=None, **kwargs
):
"""
Export the module and all imported modules into a single device library.

Expand Down
2 changes: 1 addition & 1 deletion python/tvm/testing/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _normalize_export_func(export_func, output_format) -> Tuple[Callable, str]:
from tvm.contrib import ndk, tar

def export_with(func):
return lambda mod, path: mod.export_library(path, func)
return lambda mod, path: mod.export_library(path, fcompile=func)

if export_func == "tar":
export_func = export_with(tar.tar)
Expand Down
4 changes: 2 additions & 2 deletions tests/python/relay/opencl_texture/utils/adreno_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def build_run_compare(
dso_binary = "dev_lib_cl.so"
dso_binary_path = temp.relpath(dso_binary)
ctx = remote.cl(0)
lib.export_library(dso_binary_path, ndk.create_shared)
lib.export_library(dso_binary_path, fcompile=ndk.create_shared)
remote.upload(dso_binary_path)
rlib = remote.load_module(dso_binary)
m = graph_runtime.create(graph, rlib, ctx)
Expand Down Expand Up @@ -183,7 +183,7 @@ def build_run_compare_vm(
dso_binary = "dev_lib_cl.so"
dso_binary_path = temp.relpath(dso_binary)
dev = remote.cl(0)
vmc.mod.export_library(dso_binary_path, ndk.create_shared)
vmc.mod.export_library(dso_binary_path, fcompile=ndk.create_shared)
remote.upload(dso_binary_path)
rlib = remote.load_module(dso_binary)
vm = VirtualMachine(rlib, dev, "naive")
Expand Down
2 changes: 1 addition & 1 deletion tests/python/unittest/test_runtime_module_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def check_device(device):

path_dso = temp.relpath("dev_lib.so")
# test cross compiler function
f.export_library(path_dso, cc.cross_compiler("g++"))
f.export_library(path_dso, fcompile=cc.cross_compiler("g++"))

def popen_check():
import tvm
Expand Down
2 changes: 1 addition & 1 deletion tests/python/unittest/test_runtime_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def check_minrpc():
runtime = Runtime("cpp", {"system-lib": True})
f = tvm.build(s, [A, B], "llvm", name="myadd", runtime=runtime)
path_minrpc = temp.relpath("dev_lib.minrpc")
f.export_library(path_minrpc, rpc.with_minrpc(cc.create_executable))
f.export_library(path_minrpc, fcompile=rpc.with_minrpc(cc.create_executable))

with pytest.raises(RuntimeError):
rpc.PopenSession("filenotexist")
Expand Down
4 changes: 2 additions & 2 deletions tests/python/unittest/test_target_codegen_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def my_inplace_update(x: T.Buffer((12), "float32")) -> None:
pathAll = temp.relpath("libAll.a")

path_dso = temp.relpath("mylib.so")
libA.export_library(pathA, tar.tar)
libB.export_library(pathB, tar.tar)
libA.export_library(pathA, fcompile=tar.tar)
libB.export_library(pathB, fcompile=tar.tar)
cc.create_staticlib(pathAll, [pathA, pathB])
# package two static libs together
cc.create_shared(path_dso, ["-Wl,--whole-archive", pathAll, "-Wl,--no-whole-archive"])
Expand Down
2 changes: 1 addition & 1 deletion web/tests/python/prepare_test_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def prepare_test_libs(base_path):
fadd = tvm.build(s, [A, B], target, runtime=runtime, name="add_one")

wasm_path = os.path.join(base_path, "test_addone.wasm")
fadd.export_library(wasm_path, emcc.create_tvmjs_wasm)
fadd.export_library(wasm_path, fcompile=emcc.create_tvmjs_wasm)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion web/tests/python/webgpu_rpc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_rpc():
temp = utils.tempdir()

wasm_path = temp.relpath("addone_gpu.wasm")
fadd.export_library(wasm_path, emcc.create_tvmjs_wasm)
fadd.export_library(wasm_path, fcompile=emcc.create_tvmjs_wasm)

wasm_binary = open(wasm_path, "rb").read()
remote = rpc.connect(
Expand Down
2 changes: 1 addition & 1 deletion web/tests/python/websock_rpc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_rpc():
temp = utils.tempdir()

wasm_path = temp.relpath("addone.wasm")
fadd.export_library(wasm_path, emcc.create_tvmjs_wasm)
fadd.export_library(wasm_path, fcompile=emcc.create_tvmjs_wasm)

wasm_binary = open(wasm_path, "rb").read()

Expand Down