# Loading tar module using C++ API

**URL:** <https://discuss.tvm.apache.org/t/loading-tar-module-using-c-api/10258>\
**Category:** Troubleshooting\
**Created:** [June 16, 2021, 8:23am UTC](https://discuss.tvm.apache.org/t/loading-tar-module-using-c-api/10258 "2021-06-16T08:23:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kimjh12](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/kimjh12/32/2776_2.png) [@kimjh12](https://discuss.tvm.apache.org/u/kimjh12)\
**Post date:** [June 16, 2021, 8:23am UTC](https://discuss.tvm.apache.org/t/loading-tar-module-using-c-api/10258/1 "2021-06-16T08:23:40Z")

</div>

I guess `tvm.runtime.load_module(path)` is equivalent to `tvm::runtime::Module::LoadFromFile()` of C++ API. Though I cannot load module that has tar extension.

```auto
Check failed: (f != nullptr) is false: Loader of (runtime.module.loadfile_tar) is not presented.

```

I’m trying this in terms of cross compiling, without cross compiler in my local machine. Any workaround to enable this? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![mshr-h](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/mshr-h/32/5128_2.png) [@mshr-h](https://discuss.tvm.apache.org/u/mshr-h)\
**Post date:** [July 14, 2021, 4:27am UTC](https://discuss.tvm.apache.org/t/loading-tar-module-using-c-api/10258/2 "2021-07-14T04:27:43Z")

</div>

Actually, `tvm.runtime.load_module(path)` is **not** equivalent to `tvm::runtime::Module::LoadFromFile()`. `tvm.runtime.load_module(path)` is a wrapper for `tvm::runtime::Module::LoadFromFile()` to handle different model format(`.so` or `.tar`).

The implementation is here. [tvm/module.py at 5c1a1cf7289b439b0042a85b63b0007dc1d9b98a · apache/tvm](https://github.com/apache/tvm/blob/5c1a1cf7289b439b0042a85b63b0007dc1d9b98a/python/tvm/runtime/module.py#L426)

In `load_module(path)`, if the path ends with `.tar`, it extract `.so` within the tar archive to a temporary directory and load it by calling `ModuleLoadFromFile()` which is equivalent to `tvm::runtime::Module::LoadFromFile()`. So you can’t directory load `.tar` to C++. You need to untar it manually.

---

<div class="post-metadata">

**Author:** ![kimjh12](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/kimjh12/32/2776_2.png) [@kimjh12](https://discuss.tvm.apache.org/u/kimjh12)\
**Post date:** [July 19, 2021, 7:55am UTC](https://discuss.tvm.apache.org/t/loading-tar-module-using-c-api/10258/3 "2021-07-19T07:55:31Z")

</div>

Following the implementation I got how it works. Thanks for the details.
