Trying to port RetinaFace on zcu104 using TVM-Vitis workflow

Hi @mak, @jtuyls

I am trying port face detector(Retinaface) on zcu104 platform and I am seeing exception at Vitis-ai Compilation stage, please have a look at the below error message and from the error log its look like the vitis-ai compiler not able to find the network output names. I have debug further and I have noticed that the TVM graph generation is fine and from module = graph_runtime.GraphModule(lib"default") Module is showing three outputs and its sizes as expected. I also attached tvm graph json file as a reference.

Error log:

2020-12-04 05:49:12.550036: W tensorflow/contrib/decent_q/utils/quantize_utils.cc:848] [DECENT_WARNING] Cannot find quantize info file: /tmp/t mpb23g97c2//temp/Pad_18_aquant. Use default quantize info. 2020-12-04 05:49:12.550064: W tensorflow/contrib/decent_q/utils/quantize_utils.cc:848] [DECENT_WARNING] Cannot find quantize info file: /tmp/t mpb23g97c2//temp/Pad_16_aquant. Use default quantize info. INFO: Generating Deploy Model… INFO: Deploy Model Generated. ********************* Quantization Summary *********************
INFO: Output:
quantize_eval_model: /tmp/tmpb23g97c2/quantize_eval_model.pb
deploy_model: /tmp/tmpb23g97c2/deploy_model.pb /workspace/.local/lib/python3.6/site-packages/pyxir-0.1.3-py3.6-linux-x86_64.egg/pyxir/contrib/target/components/DPUCZDX8G/vai_c.py:61: UserWa rning: This compilation only works with one network configuration at the moment!! warnings.warn("This compilation only works with one network" [VAI_C-BACKEND][Check Failed: dptconv_param->get_nonlinear_type() == 0 || dptconv_param->get_nonlinear_type() == 1 || dptconv_param->get_nonli **near_type() == 4][/home/xbuild/conda-**bld/dnnc_1592904456005/work/submodules/asicv2com/src/SlNode/SlNodeDptConv.cpp:46][TYPE_UNMATCH][Unmatched type!] *** Check failure stack trace: *** Traceback (most recent call last): File “/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/pdb.py”, line 1667, in main pdb._runscript(mainpyfile) File “/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/pdb.py”, line 1548, in _runscript self.run(statement) File “/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/bdb.py”, line 434, in run exec(cmd, globals, locals) File “”, line 1, in File “/workspace/test_mobilenet.py”, line 157, in module.run() File “/workspace/tvm/python/tvm/contrib/graph_runtime.py”, line 206, in run self._run() File “tvm/_ffi/_cython/./packed_func.pxi”, line 322, in tvm._ffi._cy3.core.PackedFuncBase.call File “tvm/_ffi/_cython/./packed_func.pxi”, line 257, in tvm._ffi._cy3.core.FuncCall File “tvm/_ffi/_cython/./packed_func.pxi”, line 246, in tvm._ffi._cy3.core.FuncCall3 File “tvm/_ffi/_cython/./base.pxi”, line 160, in tvm._ffi._cy3.core.CALL tvm._ffi.base.TVMError: AssertionError: Can’t retrieve right out tensor names from DNNC compiler output

TVM Graph:

“{\n “nodes”: [\n {\n “op”: “null”, \n “name”: “input.1”, \n “inputs”: []\n }, \n {\n “op”: “tvm_op”, \n “name”: “vitis_ai_0”, \n “attrs”: {\n “num_outputs”: “9”, \n “num_inputs”: “1”, \n “func_name”: “vitis_ai_0”, \n “flatten_data”: “0”\n }, \n “inputs”: [\n [\n 0, \n 0, \n 0\n ]\n ]\n }, \n {\n “op”: “tvm_op”, \n “name”: “fused_transpose_reshape_cast_transpose_reshape_cast_transpose_reshape_cast_conca_5331883896003102944_”, \n “attrs”: {\n “num_outputs”: “1”, \n “num_inputs”: “9”, \n “func_name”: “fused_transpose_reshape_cast_transpose_reshape_cast_transpose_reshape_cast_conca_5331883896003102944_”, \n “flatten_data”: “0”\n }, \n “inputs”: [\n [\n 1, \n 0, \n 0\n ], \n [\n 1, \n 1, \n 0\n ], \n [\n 1, \n 2, \n 0\n ], \n [\n 1, \n 3, \n 0\n ], \n [\n 1, \n 4, \n 0\n ], \n [\n 1, \n 5, \n 0\n ], \n [\n 1, \n 6, \n 0\n ], \n [\n 1, \n 7, \n 0\n ], \n [\n 1, \n 8, \n 0\n ]\n ]\n }, \n {\n “op”: “tvm_op”, \n “name”: “fused_transpose_reshape_cast_transpose_reshape_cast_transpose_reshape_cast_conca_5331883896003102944__1”, \n “attrs”: {\n “num_outputs”: “1”, \n “num_inputs”: “9”, \n “func_name”: “fused_transpose_reshape_cast_transpose_reshape_cast_transpose_reshape_cast_conca_5331883896003102944__1”, \n “flatten_data”: “0”\n }, \n “inputs”: [\n [\n 1, \n 0, \n 0\n ], \n [\n 1, \n 1, \n 0\n ], \n [\n 1, \n 2, \n 0\n ], \n [\n 1, \n 3, \n 0\n ], \n [\n 1, \n 4, \n 0\n ], \n [\n 1, \n 5, \n 0\n ], \n [\n 1, \n 6, \n 0\n ], \n [\n 1, \n 7, \n 0\n ], \n [\n 1, \n 8, \n 0\n ]\n ]\n }, \n {\n “op”: “tvm_op”, \n “name”: “fused_nn_softmax”, \n “attrs”: {\n “num_outputs”: “1”, \n “num_inputs”: “1”, \n “func_name”: “fused_nn_softmax”, \n “flatten_data”: “0”\n }, \n “inputs”: [\n [\n 3, \n 0, \n 0\n ]\n ]\n }, \n {\n “op”: “tvm_op”, \n “name”: “fused_transpose_reshape_cast_transpose_reshape_cast_transpose_reshape_cast_conca_5331883896003102944__2”, \n “attrs”: {\n “num_outputs”: “1”, \n “num_inputs”: “9”, \n “func_name”: “fused_transpose_reshape_cast_transpose_reshape_cast_transpose_reshape_cast_conca_5331883896003102944__2”, \n “flatten_data”: “0”\n }, \n “inputs”: [\n [\n 1, \n 0, \n 0\n ], \n [\n 1, \n 1, \n 0\n ], \n [\n 1, \n 2, \n 0\n ], \n [\n 1, \n 3, \n 0\n ], \n [\n 1, \n 4, \n 0\n ], \n [\n 1, \n 5, \n 0\n ], \n [\n 1, \n 6, \n 0\n ], \n [\n 1, \n 7, \n 0\n ], \n [\n 1, \n 8, \n 0\n ]\n ]\n }\n ], \n “arg_nodes”: [0], \n “heads”: [\n [\n 2, \n 0, \n 0\n ], \n [\n 4, \n 0, \n 0\n ], \n [\n 5, \n 0, \n 0\n ]\n ], \n “attrs”: {\n “dltype”: [\n “list_str”, \n [\n “float32”, \n “float32”, \n “float32”, \n “float32”, \n “float32”, \n “float32”, \n “float32”, \n “float32”, \n “float32”, \n “float32”, \n “float32”, \n “float32”, \n “float32”, \n “float32”\n ]\n ], \n “shape”: [\n “list_shape”, \n [\n [1, 3, 480, 640], \n [1, 8, 60, 80], \n [1, 8, 30, 40], \n [1, 8, 15, 20], \n [1, 4, 60, 80], \n [1, 4, 30, 40], \n [1, 4, 15, 20], \n [1, 20, 60, 80], \n [1, 20, 30, 40], \n [1, 20, 15, 20], \n [1, 12600, 4], \n [1, 12600, 2], \n [1, 12600, 2], \n [1, 12600, 10]\n ]\n ], \n “storage_id”: [\n “list_int”, \n [\n 0, \n 1, \n 2, \n 3, \n 4, \n 5, \n 6, \n 7, \n 8, \n 9, \n 10, \n 11, \n 12, \n 11\n ]\n ]\n }, \n “node_row_ptr”: [0, 1, 10, 11, 12, 13, 14]\n}”

Also I have attached vitis and ONNX through TVM compilers graphs to anaylize it further.

Please kindly help us on this.

Hi @mak, @jtuyls,

I am not able to processed further on this and please let me know if you have any updates on it?

Thanks, and Regards, Raju

@kvaju.454 Yes, this looks like there is a mismatch between the output tensor names of the DPU compiler and what we are expecting. Could you use the latest PyXIR dev branch (https://github.com/Xilinx/pyxir/tree/dev) and enable logging through

import logging
logging.basicConfig()
logger = logging.getLogger('pyxir')
logger.setLevel(logging.INFO)

and then please send us the output of the DPU compiler just before failing?

Hi @jtuyls,

Firstly thanks for your reply on this.

Please find the details here:

INFO:pyxir:----------------------
INFO:pyxir:Idx: 168, Name: nn_conv2d-94564965852032 INFO:pyxir:botttom Ps: [‘nn.relu-94564969199552’] INFO:pyxir:top Ps: [‘nn_bias_add-94564967724368’] INFO:pyxir:new_Ps [‘nn_conv2d-94564965852032_bottom_NCHW>NHWC’, ‘nn_conv2d-94564965852032’, ‘nn_conv2d-94564965852032_top_NHWC>NCHW’] INFO:pyxir:new_Ps bottoms [StrVector[nn.relu-94564969199552], StrVector[nn_conv2d-94564965852032_bottom_NCHW>NHWC], StrVector[nn_conv2d-945649 65852032]] INFO:pyxir:---------------------- INFO:pyxir:Idx: 169, Name: nn_bias_add-94564967724368 INFO:pyxir:botttom Ps: [‘nn_conv2d-94564965852032’] INFO:pyxir:top Ps: [‘tuple-94564967724496’] INFO:pyxir:new_Ps [‘nn_bias_add-94564967724368’] INFO:pyxir:new_Ps bottoms [StrVector[nn_conv2d-94564965852032_top_NHWC>NCHW]] INFO:pyxir:---------------------- INFO:pyxir:Idx: 170, Name: tuple-94564967724496 INFO:pyxir:botttom Ps: [‘nn_bias_add-94564965568816’, ‘nn_bias_add-94564967952144’, ‘nn_bias_add-94564968282800’, ‘nn_bias_add-94564968283568’ , ‘nn_bias_add-94564968284336’, ‘nn_bias_add-94564965850112’, ‘nn_bias_add-94564965850880’, ‘nn_bias_add-94564965851648’, ‘nn_bias_add-9456496 7724368’] INFO:pyxir:top Ps: [] INFO:pyxir:new_Ps [‘tuple-94564967724496’] INFO:pyxir:new_Ps bottoms [StrVector[nn_bias_add-94564965568816, nn_bias_add-94564967952144, nn_bias_add-94564968282800, nn_bias_add-945649682 83568, nn_bias_add-94564968284336, nn_bias_add-94564965850112, nn_bias_add-94564965850880, nn_bias_add-94564965851648, nn_bias_add-94564967724 368]] INFO:pyxir:---------------------- INFO:pyxir:Net: old # elems: 171 INFO:pyxir:Net: new # elems: 287 INFO:pyxir:Add MergeTransposes pass INFO:pyxir:Add SweepTransposesFlow pass INFO:pyxir:Optimization pass: 0 level: 10: nb: 1 INFO:pyxir:–name: BasicOptimizationPass-1 INFO:pyxir:Optimization pass: 1 level: 20: nb: 1 INFO:pyxir:–name: TransposesOptimizationPass-2 INFO:pyxir:Add RemoveScalingBy1Layers pass INFO:pyxir:Add RemoveDropoutLayers pass INFO:pyxir:Add RemoveCastLayers pass INFO:pyxir:Add MergePaddingIntoConvPool pass INFO:pyxir:Add MergeBiasIntoConvDense pass INFO:pyxir:Add MergeBiasIntoConvDense pass INFO:pyxir:Add MergeBNIntoConv pass INFO:pyxir:Add MergeScaleIntoConvBN pass INFO:pyxir:Optimization pass: 0 level: 10: nb: 1 INFO:pyxir:–name: BasicOptimizationPass-1 INFO:pyxir:Optimization pass: 1 level: 20: nb: 1 INFO:pyxir:–name: XDNN-OptimizationPass-2-Merge_Conv_Bias_BN_Scale INFO:pyxir:


  • START GRAPH COMPILATION FOR TARGET: DPUCZDX8G-zcu104

INFO:pyxir:Command: vai_c_tensorflow --frozen_pb /tmp/tmp8cwn31f_/deploy_model.pb --arch /opt/vitis_ai/compiler/arch/DPUCZDX8G/ZCU 104/arch.json --output_dir /tmp/tmp8cwn31f_/ --net_name xp0 --options “{}”

[VAI_C-BACKEND][Check Failed: dptconv_param->get_nonlinear_type() == 0 || dptconv_param->get_nonlinear_type() == 1 || dptconv_param->get_nonli near_type() == 4][/home/xbuild/conda-bld/dnnc_1592904456005/work/submodules/asicv2com/src/SlNode/SlNodeDptConv.cpp:46][TYPE_UNMATCH][Unmatched type!] *** Check failure stack trace: *** INFO:pyxir:Output: **************************************************

  • VITIS_AI Compilation - Xilinx Inc.

INFO:pyxir:Output names: [‘nn_conv2d-94564968284720’, ‘nn_conv2d-94564958333008’, ‘nn_conv2d-94564965852032’, ‘nn_conv2d-94564958659728’, ‘nn_ conv2d-94564965851264’, ‘nn_conv2d-94564965850496’, ‘nn_conv2d-94564969199936’, ‘nn_conv2d-94564968283184’, ‘nn_conv2d-94564968283952’] Traceback (most recent call last): File “/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/pdb.py”, line 1667, in main pdb._runscript(mainpyfile) File “/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/pdb.py”, line 1548, in _runscript self.run(statement) File “/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/bdb.py”, line 434, in run exec(cmd, globals, locals) File “”, line 1, in File “/workspace/test_mobilenet.py”, line 1, in import pyxir File “/workspace/tvm/python/tvm/contrib/graph_runtime.py”, line 206, in run self._run() File “tvm/_ffi/_cython/./packed_func.pxi”, line 322, in tvm._ffi._cy3.core.PackedFuncBase.call File “tvm/_ffi/_cython/./packed_func.pxi”, line 257, in tvm._ffi._cy3.core.FuncCall File “tvm/_ffi/_cython/./packed_func.pxi”, line 246, in tvm._ffi._cy3.core.FuncCall3 File “tvm/_ffi/_cython/./base.pxi”, line 160, in tvm._ffi._cy3.core.CALL tvm._ffi.base.TVMError: AssertionError: Can’t retrieve right out tensor names from DNNC compiler output At: /workspace/.local/lib/python3.6/site-packages/pyxir-0.1.3-py3.6-linux-x86_64.egg/pyxir/contrib/target/components/DPUCZDX8G/vai_c.py(149): compile /workspace/.local/lib/python3.6/site-packages/pyxir-0.1.3-py3.6-linux-x86_64.egg/pyxir/contrib/target/components/DPUCZDX8G/zcu104.py(67): xgraph_dpu_zcu104_compiler /workspace/.local/lib/python3.6/site-packages/pyxir-0.1.3-py3.6-linux-x86_64.egg/pyxir/base.py(159): compile /workspace/.local/lib/python3.6/site-packages/pyxir-0.1.3-py3.6-linux-x86_64.egg/pyxir/base.py(211): compile_opaque_func /workspace/.local/lib/python3.6/site-packages/pyxir-0.1.3-py3.6-linux-x86_64.egg/pyxir/opaque_func.py(113): opaque_func_wrapper /workspace/tvm/python/tvm/contrib/graph_runtime.py(206): run /workspace/test_mobilenet.py(1): (1): /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/bdb.py(434): run /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/pdb.py(1548): _runscript /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/pdb.py(1667): main /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/pdb.py(1694): /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/runpy.py(85): _run_code /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/runpy.py(193): _run_module_as_main

Thanks and Regards, Raju

Hi @jtuyls,

One more point I want add, here is that. Initially when I want to verify the resnet50 and resnet34 models in this workflow I have faced following issue and hence manually I have applied following pull request and the my resnet50 and resnet34 model started working.

Before this pull request:

nvert_variables_to_constants (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.[2/1907] Instructions for updating: Use tf.compat.v1.graph_util.convert_variables_to_constants WARNING:tensorflow:From /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/python/framework/graph_util_impl.py:277: extract_sub_graph (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version. Instructions for updating: Use tf.compat.v1.graph_util.extract_sub_graph Traceback (most recent call last): File “test_resnet34.py”, line 150, in module.run() File “/workspace/tvm/python/tvm/contrib/graph_runtime.py”, line 206, in run self._run() File “tvm/_ffi/_cython/./packed_func.pxi”, line 322, in tvm._ffi._cy3.core.PackedFuncBase.call File “tvm/_ffi/_cython/./packed_func.pxi”, line 257, in tvm._ffi._cy3.core.FuncCall File “tvm/_ffi/_cython/./packed_func.pxi”, line 246, in tvm._ffi._cy3.core.FuncCall3 File “tvm/_ffi/_cython/./base.pxi”, line 160, in tvm._ffi._cy3.core.CALL tvm._ffi.base.TVMError: AssertionError: nn_conv2d-94315635025696 is not in graph At: ** /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/python/framework/graph_util_impl.py(152): _assert_nodes_are_present** ** /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/python/framework/graph_util_impl.py(197): extract_sub_graph** /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/python/util/deprecation.py(324): new_func /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/python/framework/graph_util_impl.py(277): convert_v ariables_to_constants /opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/python/util/deprecation.py(324): new_func /workspace/.local/lib/python3.6/site-packages/pyxir-0.1.3-py3.6-linux-x86_64.egg/pyxir/generator/tensorflow.py(131): generate /workspace/.local/lib/python3.6/site-packages/pyxir-0.1.3-py3.6-linux-x86_64.egg/pyxir/quantization/decent_quantizer.py(142): quantize /workspace/.local/lib/python3.6/site-packages/pyxir-0.1.3-py3.6-linux-x86_64.egg/pyxir/contrib/target/components/DPUCZDX8G/common.py(38): xg raph_dpu_quantizer /workspace/.local/lib/python3.6/site-packages/pyxir-0.1.3-py3.6-linux-x86_64.egg/pyxir/base.py(260): _quantize /workspace/.local/lib/python3.6/site-packages/pyxir-0.1.3-py3.6-linux-x86_64.egg/pyxir/base.py(484): quant_func /workspace/.local/lib/python3.6/site-packages/pyxir-0.1.3-py3.6-linux-x86_64.egg/pyxir/opaque_func.py(113): opaque_func_wrapper /workspace/tvm/python/tvm/contrib/graph_runtime.py(206): run test_resnet34.py(150): (vitis-ai-tensorflow) kvraju@nnserver1-Precision-5820-Tower:~$ ^Cf_l2_convolutions.py pyxir/python/pyxir/runtime/tensorflow/ops/tf_l2_convolu$

Pull Request:

Now, I am using your dev branch only. In this case also my old models resnet50 and renset34 are not working, and I am seeing same old error, which I have mentioned here.

Any suggestion why I need this patch when I want to verify resnet34 and resnet50 models?

Thanks and Regards, Raju

This error happens internally in the DPU compiler. Is this a public model that I can download somewhere? I followed your link but didn’t immediately find a downloadable file for this model. Also, the nonlinearities are just LeakyReLU right?

Yes, this PR solves an issue that occurs in some models where the partition ends on Conv + Bias. This PR needed some small changes still but has now been merged into dev.

Thanks, @jtuyls,

Yes, in this model we have LeakyReLU. Here I have uploaded the [model], please check it, if you are able to access this link or not .(https://drive.google.com/file/d/1nmPkaPEAZm0Wzxzs6iMFnOfv7IzIHXsg/view?usp=sharing)

Please let me know if you need any other information on this.

Thanks and Regards, Raju

Hi @jtuyls,

Thanks for the update and now I have everything in dev branch. Thanks again for your quick response.

Thanks and Regards, Raju

Hi @jtuyls/ @mak ,

Any updates on this?

Thanks and Regards, Raju

@kvaju.454 I could reproduce the same issue you are seeing and checked with the DPU compiler team and apparently Depthwise Conv2D followed by LeakyRelu is not supported on this accelerator. We will update the partitioning rules to reflect that, however this means that a large part of this specific model would be offloaded to CPU instead. If you train the model yourself you can try using Relu6 after the Depthwise Conv2D layers (as in mobilenet) which should allow you to offload a larger part to the DPU.

Hi @jtuyls,

Thanks for the confirmation and regarding retraining the model I will discuss internally and update you further on this.

apparently Depthwise Conv2D followed by LeakyRelu is not supported on this accelerator

–> Coming DPU releases does the “Depthwise Conv2d followed by LeakRelu” pattern will be adding or not? If yes, what is the tentative time for this release?

Thanks and Regards, Raju

Hi @kvaju.454, I checked and there is no timeline for adding this pattern. I will let you know if this would change.

Hi @jtuyls,

Thanks for the information. Still we are working on it and also I am trying with standalone Vitis-ai workflow as well.

Thanks and Regards, Raju