# \[VTA\]AutoTVM tutorial error with pynq - export\_library

**URL:** <https://discuss.tvm.apache.org/t/vta-autotvm-tutorial-error-with-pynq-export-library/8634>\
**Category:** Questions\
**Created:** [December 11, 2020, 5:26am UTC](https://discuss.tvm.apache.org/t/vta-autotvm-tutorial-error-with-pynq-export-library/8634 "2020-12-11T05:26:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![woojinnn](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/w/9dc877/32.png) [@woojinnn](https://discuss.tvm.apache.org/u/woojinnn)\
**Post date:** [December 11, 2020, 5:26am UTC](https://discuss.tvm.apache.org/t/vta-autotvm-tutorial-error-with-pynq-export-library/8634/1 "2020-12-11T05:26:26Z")

</div>

Hi, I’m following [AutoTVM w/ vta tutorial](https://tvm.apache.org/docs/vta/tutorials/autotvm/tune_relay_vta.html#sphx-glr-vta-tutorials-autotvm-tune-relay-vta-py) with pynq-z1 board and I got the error message like this:

 ![Screen Shot 2020-12-11 at 2.25.53 PM](https://discuss.tvm.apache.org/uploads/default/original/2X/5/5bbe2c49ca94fc703efba302fc81f3f1d939c9c3.png)

Why did this error occured? I found this [discussion](https://discuss.tvm.apache.org/t/tutorial-errors/7962/8), and wondering whether it suits for pynq(vta) because this discussion is for cpu device and mine is pynq FPGA(vta) board.

---

<div class="post-metadata">

**Author:** ![isong](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@isong](https://discuss.tvm.apache.org/u/isong)\
**Post date:** [December 13, 2020, 10:46am UTC](https://discuss.tvm.apache.org/t/vta-autotvm-tutorial-error-with-pynq-export-library/8634/2 "2020-12-13T10:46:59Z")

</div>

It seems that the compile command is failing at [this function](https://github.com/apache/tvm/blob/28647f2e7a65146724b143098422229346b5db44/python/tvm/contrib/cc.py#L191).

The failed command is at the end of your screen capture.

It could be some of your binary is built for different target? I would double check vta config [file](https://github.com/apache/tvm-vta/blob/57db5a718c74a788c98120ebbe1230797be698c8/config/vta_config.json). Make sure your `TARGET` is correct, some cases I’ve seen was actual target was 64 bit, but config file was 32 bit target, which caused an issue.

```auto

def _linux_compile(output, objects, options, compile_cmd="g++", compile_shared=False):
    cmd = [compile_cmd]
    if compile_shared or output.endswith(".so") or output.endswith(".dylib"):
        cmd += ["-shared", "-fPIC"]
        if sys.platform == "darwin":
            cmd += ["-undefined", "dynamic_lookup"]
    elif output.endswith(".obj"):
        cmd += ["-c"]
    cmd += ["-o", output]
    if isinstance(objects, str):
        cmd += [objects]
    else:
        cmd += objects
    if options:
        cmd += options
    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    (out, _) = proc.communicate()
    if proc.returncode != 0:
        msg = "Compilation error:\n"
        msg += py_str(out)
        msg += "\nCommand line: " + " ".join(cmd)
        raise RuntimeError(msg)

```

---

<div class="post-metadata">

**Author:** ![woojinnn](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/w/9dc877/32.png) [@woojinnn](https://discuss.tvm.apache.org/u/woojinnn)\
**Post date:** [December 13, 2020, 1:26pm UTC](https://discuss.tvm.apache.org/t/vta-autotvm-tutorial-error-with-pynq-export-library/8634/3 "2020-12-13T13:26:01Z")

</div>

Hi, isong! Thank you for response!

My current vta config file at host side(tvm/3rdparty/vta-hw/config/vta\_config.json) is

 ![Screen Shot 2020-12-13 at 10.19.55 PM](https://discuss.tvm.apache.org/uploads/default/original/2X/9/9a798524e19c16e49b56e2b4bf933902cec9a3fb.jpeg)

and I’m using pynq-z1 board now.

The vta\_config.json file at pynq side is like below: (Do I have to check this file too??)

 ![Screen Shot 2020-12-13 at 10.22.53 PM](https://discuss.tvm.apache.org/uploads/default/original/2X/8/8eca12de5782c203992ed7160ca045f167688d8f.png)

Also, I’m also confused whether vta contains CPU+FPGA combination or just FPGA.

---

<div class="post-metadata">

**Author:** ![woojinnn](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/w/9dc877/32.png) [@woojinnn](https://discuss.tvm.apache.org/u/woojinnn)\
**Post date:** [December 13, 2020, 1:51pm UTC](https://discuss.tvm.apache.org/t/vta-autotvm-tutorial-error-with-pynq-export-library/8634/4 "2020-12-13T13:51:55Z")

</div>

I solved, but I don’t know why it works. I checked your git commit, [[Fix][Tutorial][VTA] Update tune\_relay\_vta.py to support single board by insop · Pull Request #7100 · apache/tvm · GitHub](https://github.com/apache/tvm/pull/7100/files#diff-eebeea4138edef860d9fbecfca6d83ebdfa750527b53b15f76d989668d81e065L343-L354)

I changed `lib.export_library(temp.relpath("graphlib.o"))` this code to `lib.export_library(temp.relpath("graphlib.tar"))`

Why does this work? The only thing I did is changing graphlib.o file to graphlib.tar file.

* * *

Also, when executing code, it found some warning message like this:

> [Task 8/10] Current/Best: 0.00/ 1.58 GFLOPS | Progress: (10/10) | 5.36 s Done.  
> [Task 9/10] Current/Best: 0.00/ 0.00 GFLOPS | Progress: (10/10) | 1.31 sWARNING:root:Could not find any valid schedule for task Task(func\_name=conv2d\_packed.vta, args=((‘TENSOR’, (1, 8, 28, 28, 1, 16), ‘int8’), (‘TENSOR’, (16, 8, 1, 1, 16, 16), ‘int8’), (2, 2), (0, 0, 0, 0), (1, 1), ‘NCHW1n16c’, ‘int32’), kwargs={}, workload=(‘conv2d\_packed.vta’, (‘TENSOR’, (1, 8, 28, 28, 1, 16), ‘int8’), (‘TENSOR’, (16, 8, 1, 1, 16, 16), ‘int8’), (2, 2), (0, 0, 0, 0), (1, 1), ‘NCHW1n16c’, ‘int32’)). A file containing the errors has been written to /tmp/tvm\_tuning\_errors\_rjrt44ra.log.  
> Done.  
> [Task 10/10] Current/Best: 0.00/ 11.05 GFLOPS | Progress: (10/10) | 21.55 s Done.  
> Compile…  
> Upload…  
> Evaluate inference time cost…  
> Mean inference time (std dev): 755.27 ms (11.72 ms).

Is this negligible error?

---

<div class="post-metadata">

**Author:** ![isong](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@isong](https://discuss.tvm.apache.org/u/isong)\
**Post date:** [December 14, 2020, 10:12am UTC](https://discuss.tvm.apache.org/t/vta-autotvm-tutorial-error-with-pynq-export-library/8634/5 "2020-12-14T10:12:05Z")

</div>

@woojinnn

They need to be the same for the same hw. The below warning could be due to the limited operator definition. The warning just saying that with certain operator for Tensor size cannot be fit to your currently defined vta.

---

<div class="post-metadata">

**Author:** ![woojinnn](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/w/9dc877/32.png) [@woojinnn](https://discuss.tvm.apache.org/u/woojinnn)\
**Post date:** [December 15, 2020, 1:12am UTC](https://discuss.tvm.apache.org/t/vta-autotvm-tutorial-error-with-pynq-export-library/8634/7 "2020-12-15T01:12:20Z")

</div>

Doesn’t AutoTVM automatically fit it? Like massaging tensor size to fit vta spec. Is there any workaround to solve that warning message? Actually, I think I didn’t got the concept of AutoTVM… 🤔

* * *

My ultimate goal is to solve cart-pole problem with reinforcement learning(DQN), and I made a fully-connected layer model whose layer’s shape is 4(input) \* 64 \* 2(output). When I run the code, it showed the similar error like that. Again, is there any workaround?

---

<div class="post-metadata">

**Author:** ![isong](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@isong](https://discuss.tvm.apache.org/u/isong)\
**Post date:** [December 15, 2020, 7:45am UTC](https://discuss.tvm.apache.org/t/vta-autotvm-tutorial-error-with-pynq-export-library/8634/8 "2020-12-15T07:45:26Z")

</div>

AutoTVM is template based searching method that searches to find a better inference by using different implementations for certain operators. I think the warning indicates that the vta you have cannot run certain type sof kernel natively because of it is built with different vta config or loaded limited vta config either on host or run time, as you loaded different files.

To use vta for dens operator, your inputs needs to be _quantized_ and _packed_. As in this example, vta dense expects the input to be packed

- [https://github.com/apache/tvm/blob/main/vta/tests/python/integration/test\_benchmark\_topi\_dense.py](https://github.com/apache/tvm/blob/main/vta/tests/python/integration/test_benchmark_topi_dense.py)

I think you need to have a way to modify your network to add input pack layer before your dense operator, something like in this [file](https://github.com/apache/tvm/blob/main/vta/python/vta/top/graphpack.py).

There could be few other ways, but I think adding a way to modify your network would seems to be more favorable way.

HIH
