# Deploying the tuned tflite graph with c++

**URL:** <https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744>\
**Category:** Questions\
**Created:** [February 25, 2019, 6:19am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744 "2019-02-25T06:19:20Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![yvn](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/y/b2d939/32.png) [@yvn](https://discuss.tvm.apache.org/u/yvn)\
**Post date:** [February 25, 2019, 6:19am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/1 "2019-02-25T06:19:20Z")

</div>

After tuning the tflite graph and building it, we can have the .so using export\_library. Now, to deploy it in c++, will taking this .so as an input be enough? I think some params extracted from the graph should also be sent as input for the execution, but how do we do that?

---

<div class="post-metadata">

**Author:** ![yvn](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/y/b2d939/32.png) [@yvn](https://discuss.tvm.apache.org/u/yvn)\
**Post date:** [February 26, 2019, 1:06am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/2 "2019-02-26T01:06:58Z")

</div>

@eqy you have anything here?

---

<div class="post-metadata">

**Author:** ![eqy](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/eqy/32/766_2.png) [@eqy](https://discuss.tvm.apache.org/u/eqy)\
**Post date:** [February 26, 2019, 1:08am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/3 "2019-02-26T01:08:17Z")

</div>

I don’t have much experience using the C++ API, have you tried it and checked the results? If it looks anything like the Python API the parameters are not passed again.

---

<div class="post-metadata">

**Author:** ![yvn](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/y/b2d939/32.png) [@yvn](https://discuss.tvm.apache.org/u/yvn)\
**Post date:** [February 26, 2019, 1:15am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/4 "2019-02-26T01:15:56Z")

</div>

In the example of how\_to\_deploy in the apps, there is just a simple example of vector addition i guess, in that case we have to take the tensors, because we know that there are only 3 tensors to be taken it is easy, but when it comes to the graph how should I take this step?  
Like, how many tensors to be taken, which function should I be calling for executing the inference, what should be the input params etc. Can you give me some information about that so that I may try it.

---

<div class="post-metadata">

**Author:** ![eqy](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/eqy/32/766_2.png) [@eqy](https://discuss.tvm.apache.org/u/eqy)\
**Post date:** [February 26, 2019, 1:29am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/5 "2019-02-26T01:29:18Z")

</div>

Did you compile using NNVM or relay? The NNVM example is here [https://github.com/dmlc/nnvm/blob/master/docs/how\_to/deploy.md](https://github.com/dmlc/nnvm/blob/master/docs/how_to/deploy.md) (looks like you may need to load parameters after all).

---

<div class="post-metadata">

**Author:** ![yvn](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/y/b2d939/32.png) [@yvn](https://discuss.tvm.apache.org/u/yvn)\
**Post date:** [February 26, 2019, 1:36am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/6 "2019-02-26T01:36:44Z")

</div>

I was compiling it for tflite with relay!

---

<div class="post-metadata">

**Author:** ![eqy](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/eqy/32/766_2.png) [@eqy](https://discuss.tvm.apache.org/u/eqy)\
**Post date:** [February 26, 2019, 1:46am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/7 "2019-02-26T01:46:29Z")

</div>

Looking more closely, it looks like the actual running part is using the TVM runtime, so in theory it should be interchangeable if you used Relay.

---

<div class="post-metadata">

**Author:** ![yvn](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/y/b2d939/32.png) [@yvn](https://discuss.tvm.apache.org/u/yvn)\
**Post date:** [February 26, 2019, 2:11am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/8 "2019-02-26T02:11:25Z")

</div>

Okay thanks will try that and let you know

---

<div class="post-metadata">

**Author:** ![yvn](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/y/b2d939/32.png) [@yvn](https://discuss.tvm.apache.org/u/yvn)\
**Post date:** [February 26, 2019, 5:46am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/9 "2019-02-26T05:46:53Z")

</div>

> [@eqy](#):
>
> have you tried it an

can you mention someone who has more experience using c++ api?

---

<div class="post-metadata">

**Author:** ![masahi](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/masahi/32/74_2.png) [@masahi](https://discuss.tvm.apache.org/u/masahi)\
**Post date:** [February 26, 2019, 6:31am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/10 "2019-02-26T06:31:37Z")

</div>

you can take a look at [this post](https://discuss.tvm.ai/t/deploy-nnvm-module-using-c-on-gpu-using-opencl-target/229). It doesn’t matter whether you use nnvm or relay.

---

<div class="post-metadata">

**Author:** ![yvn](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/y/b2d939/32.png) [@yvn](https://discuss.tvm.apache.org/u/yvn)\
**Post date:** [February 26, 2019, 10:53am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/11 "2019-02-26T10:53:59Z")

</div>

Like there is a way to write params in the form of string using nnvm:

> f\_params.write(nnvm.compiler.save\_param\_dict(params))

Is there a way to write params in a dictionary file in the form of a string with relay also, so that the 3 files needed for deployment (.so, .json and .params), all 3 could be obtained?

---

<div class="post-metadata">

**Author:** ![masahi](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/masahi/32/74_2.png) [@masahi](https://discuss.tvm.apache.org/u/masahi)\
**Post date:** [February 27, 2019, 6:57am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/12 "2019-02-27T06:57:38Z")

</div>

You are in luck. It is just merged [https://github.com/dmlc/tvm/pull/2620](https://github.com/dmlc/tvm/pull/2620)

---

<div class="post-metadata">

**Author:** ![yvn](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/y/b2d939/32.png) [@yvn](https://discuss.tvm.apache.org/u/yvn)\
**Post date:** [February 27, 2019, 7:13am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/13 "2019-02-27T07:13:33Z")

</div>

thanks for the update!  
seems like when I was saving the param\_dict using nnvm then also it was getting built and deployed without any error. What is the difference between the two?

---

<div class="post-metadata">

**Author:** ![yvn](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/y/b2d939/32.png) [@yvn](https://discuss.tvm.apache.org/u/yvn)\
**Post date:** [February 27, 2019, 10:53am UTC](https://discuss.tvm.apache.org/t/deploying-the-tuned-tflite-graph-with-c/1744/14 "2019-02-27T10:53:41Z")

</div>

@masahi @eqy , there are certain things that I want to know  
I want to deploy mobilenet\_v1\_224 tflite model on arm64 cpu target in c++. As discussed in the above replies I would need the,

1. graph.json
2. graph.so
3. graph.param  
the .json and the .so, I am able to generate as they don’t have dependency on relay. But graph.param has relay dependency, which seems like it has been merged in git.However, I faced some new errors while compiling the python file after pulling the latest code from git described here ([Unable to compile the tflite model with relay after pulling the latest code from remote](https://discuss.tvm.ai/t/unable-to-compile-the-tflite-model-with-relay-after-pulling-the-latest-code-from-remote/1774)). Could you share me some code or link to some patch where I can modify the code for my requirements, where any tflite model is deployed as an application, built in c++ on arm64 cpu target.  
Thanks!
