Load module from remote side.
(file_name)
| 84 | |
| 85 | @tvm_ffi.register_global_func("tvm.rpc.server.download_linked_module", override=True) |
| 86 | def download_linked_module(file_name): |
| 87 | """Load module from remote side.""" |
| 88 | # pylint: disable=import-outside-toplevel |
| 89 | path = temp.relpath(file_name) |
| 90 | |
| 91 | if path.endswith(".o"): |
| 92 | # Extra dependencies during runtime. |
| 93 | from tvm.support import cc as _cc |
| 94 | |
| 95 | _cc.create_shared(path + ".so", path) |
| 96 | path += ".so" |
| 97 | elif path.endswith(".tar"): |
| 98 | # Extra dependencies during runtime. |
| 99 | from tvm.support import cc as _cc |
| 100 | from tvm.support import tar as _tar |
| 101 | |
| 102 | tar_temp = utils.tempdir(custom_path=path.replace(".tar", "")) |
| 103 | _tar.untar(path, tar_temp.temp_dir) |
| 104 | files = [tar_temp.relpath(x) for x in tar_temp.listdir()] |
| 105 | _cc.create_shared(path + ".so", files) |
| 106 | path += ".so" |
| 107 | elif path.endswith(".dylib") or path.endswith(".so"): |
| 108 | pass |
| 109 | else: |
| 110 | raise RuntimeError(f"Do not know how to link {file_name}") |
| 111 | logger.info("Send linked module %s to client", path) |
| 112 | return bytearray(open(path, "rb").read()) |
| 113 | |
| 114 | libs = [] |
| 115 | load_library = load_library.split(":") if load_library else [] |