cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
coreyhahn
Contributor
Contributor
957 Views
Registered: ‎09-13-2018

quantize error "Cannot find quantize info for relu: ReLU1"

Jump to solution

Pulling my model through the tools (2019.2).  Came across an error when I ran the function 

# quantize
vai_q_tensorflow quantize \
--input_frozen_graph test.pb \
--input_fn input.calib_input \
--output_dir ./ \
--input_nodes 'Input_Layer' \
--output_nodes 'SoftMax' \
--input_shapes 1,2,32,32 \
--calib_iter 100

 

100% (100 of 100) |#############################################################################| Elapsed Time: 0:00:59 Time: 0:00:59
INFO: Calibration Done.
INFO: Generating Deploy Model...
2020-06-12 11:27:17.192789: F tensorflow/contrib/decent_q/utils/deploy_quantized_graph.cc:928] Check failed: relu_node.attr().count("opos") [DEPLOY ERROR] Cannot find quantize info for relu: ReLU1
Fatal Python error: Aborted

Current thread 0x00007f8345afa740 (most recent call first):
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/contrib/decent_q/python/quantize_graph.py", line 232 in CreateQuantizeDeployGraphDef
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/contrib/decent_q/python/decent_q.py", line 293 in deploy_frozen
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/contrib/decent_q/python/decent_q.py", line 327 in quantize_frozen
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/contrib/decent_q/python/decent_q.py", line 576 in main
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/contrib/decent_q/python/decent_q.py", line 780 in <lambda>
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/absl/app.py", line 250 in _run_main
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/absl/app.py", line 299 in run
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/python/platform/app.py", line 40 in run
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/contrib/decent_q/python/decent_q.py", line 781 in run_main
File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/bin/vai_q_tensorflow", line 11 in <module>
./quant_graph.sh: line 19: 1077 Aborted (core dumped) vai_q_tensorflow quantize --input_frozen_graph test.pb --input_fn rf_input.calib_input --output_dir ./ --input_nodes 'Input_Layer' --output_nodes 'SoftMax' --input_shapes 1,2,32,32 --calib_iter 100
-----------------------------------------
QUANTIZED COMPLETED
-----------------------------------------

0 Kudos
1 Solution

Accepted Solutions
jasonwu
Moderator
Moderator
764 Views
Registered: ‎03-27-2013

Hi @coreyhahn ,

 

Just got feedback and suggestion from dev team:

The pb file has utilized lots of TF math APIs in construction like mul, add and sqrt which may not be supported by the quantizer.

The suggestion could be design the model with high level APIs like tf.nn or tf.keras.

 

So too many unsupported math APIs are used. You need to modify your model using high level APIs like tf.nn or tf.keras.

 

Hi @Ambobio-Bob ,

 

Hope this suggestion can also help with the issue you met.

Best Regards,
Jason
-----------------------------------------------------------------------------------------------
Please mark the Answer as "Accept as solution" if the information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
-----------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
4 Replies
jasonwu
Moderator
Moderator
851 Views
Registered: ‎03-27-2013

Hi @coreyhahn ,

 

Seems like associated with your model arch.

Would you please send me your pb file?

You can send me your email by private message.

I can send a EZMOVE request to you so that you can transfer your pb to be via it.

Best Regards,
Jason
-----------------------------------------------------------------------------------------------
Please mark the Answer as "Accept as solution" if the information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
-----------------------------------------------------------------------------------------------
0 Kudos
Ambobio-Bob
Visitor
Visitor
800 Views
Registered: ‎07-10-2020

Hi @jasonwu ,

I also have the same problem as @coreyhahn when quantizing the model. I used Resnet50 Model from Tensorflow(1.15.2) and adding an output layer. Can you help me in this matter?

Here is the link of the pb file: https://drive.google.com/file/d/1Mgmm8Vk9MSnSCGnt3Ye3zhqYxSDFdO2H/view?usp=sharing

Below is the command I used for quantizing:

vai_q_tensorflow quantize \
--input_frozen_graph=testModel1.pb \
--input_nodes=resnet50_input \
--input_shapes=?,250,250,3 \
--output_nodes=dense/Softmax \
--input_fn=image_input_fn.calib_input \
--output_dir=method2 \
--calib_iter=100
 
2020-07-14 21:41:30.202371: F tensorflow/contrib/decent_q/utils/deploy_quantized_graph.cc:928] Check failed: relu_node.attr().count("opos") [DEPLOY ERROR] Cannot find quantize info for relu: resnet50/conv1_relu/Relu
Fatal Python error: Aborted
0 Kudos
jasonwu
Moderator
Moderator
765 Views
Registered: ‎03-27-2013

Hi @coreyhahn ,

 

Just got feedback and suggestion from dev team:

The pb file has utilized lots of TF math APIs in construction like mul, add and sqrt which may not be supported by the quantizer.

The suggestion could be design the model with high level APIs like tf.nn or tf.keras.

 

So too many unsupported math APIs are used. You need to modify your model using high level APIs like tf.nn or tf.keras.

 

Hi @Ambobio-Bob ,

 

Hope this suggestion can also help with the issue you met.

Best Regards,
Jason
-----------------------------------------------------------------------------------------------
Please mark the Answer as "Accept as solution" if the information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
-----------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
xinj
Visitor
Visitor
474 Views
Registered: ‎12-03-2020

Hi @jasonwu ,

I also have the same problem as @coreyhahn when quantizing the model. Can you help me in this matter?

Here is the link of the pb file: https://drive.google.com/file/d/1Mgmm8Vk9MSnSCGnt3Ye3zhqYxSDFdO2H/view?usp=sharing

Below is the command I used for quantizing:

vai_q_tensorflow quantize \
--input_frozen_graph model_data/yolov5s_sinda.pb \
--input_nodes img_input \
--input_shapes ?,640,480,3 \
--output_nodes model.24.m.0/BiasAdd,model.24.m.1/BiasAdd,model.24.m.2/BiasAdd \
--input_fn input_fn_yolov5.calib_input \
--method 1 \
--gpu 0 \
--calib_iter 100
 
 
 2020-12-03 21:02:25.932060: W tensorflow/contrib/decent_q/utils/deploy_quantized_graph.cc:1152] [DECENT_WARNING] Batchnorm Node (model.23.bn/FusedBatchNormV3/add + model.23.bn/FusedBatchNormV3/mul) is not folded. It will be converted to a Scale node (model.23.bn/FusedBatchNormV3/add) to deploy on DPU. This may cause accuracy decrease and error for DPU compiler.
2020-12-03 21:02:25.932208: F tensorflow/contrib/decent_q/utils/deploy_quantized_graph.cc:1457] Check failed: relu_node.attr().count("opos") [DEPLOY ERROR] Cannot find quantize info for relu: re_lu/Relu6
Fatal Python error: Aborted
0 Kudos