FrozenGene commented on issue #4828: [QNN][TFLite] TFLite rounding mode support
URL: https://github.com/apache/incubator-tvm/pull/4828#issuecomment-596615575
 
 
   > > > > CI's LLVM is LLVM 4.0. I think we should supply `quantized add` so 
that we avoid it is just a lucky.
   > > > 
   > > > 
   > > > Just tested, it's a lucky case indeed.
   > > > BTW, is it possible to follow tensorflow to have a specific llvm 
version for each tvm release to avoid
   > > > certain problems like this?
   > > 
   > > 
   > > To avoid lucky case, when we support TFLite rounding, we could change 
the `data = get_real_image(224, 224)` to
   > > ```python
   > > np.random.seed(0) 
   > > data = np.random.random_integers(low=0, high=128, size=(1, 224, 224, 
3)).astype('uint8')
   > > ```
   > > 
   > > 
   > > back.
   > 
   > Update:I made a mistake for the unit test that I still compare the labels 
instead of numerical predictions, so rtol and atol set to zero does not make 
any sense. Now that I changed to compare numerical prediction vector, the 
results begin to differ for mobilenetV2. And further, changing qnn.add rounding 
mode to TFLITE does not lead to bit exact execution. I have to reimplement the 
whole algorithm again in TFLITE add op to see it works. But I'm bothered by the 
segfault problem to get any reasonable test results.
   > 
   > > For LLVM version, I think we can not at least currently. We support 
different LLVM versions on TVM. We have the check in `FindLLVM.cmake` to make 
sure the minimal requirement is 4.0.
   > > Could you dig it more? If we can make sure it is the bug of LLVM, we 
then can discuss how to deal with this case.
   > 
   > I digged a little bit on this, but it seems to be not related with llvm 
but rather with tflite conversion from tensorflow graph to tflite (not even 
related to tvm). I'm using tf 1.15 for my test. And I find it's related to this 
test `_test_forward_elemwise(partial(_test_add, 
fused_activation_function="RELU6"))`, specifically `RELU6` will cause the 
error, if I change it to `RELU`, no segfault will be triggered. @FrozenGene 
Please help , or maybe I should just for now switch back to an older version of 
tensorflow.
   
    don’t worry. Let us break down the problem.
   
   Firstly, CI’s tflite version is 1.13. We could keep your tf version as the 
same firstly.
   
   Second, as I suggested before, you could use tflite_convert tool to convert 
quantized model layer by layer
   `tflite_convert --input_format=TENSORFLOW_GRAPHDEF --graph_def_file="xx.pb" 
--output_file=xx.tflite --output_format=TFLITE --input_arrays=input 
--input_shapes=1,224,224,3 --std_dev_values=127 --mean_values=127 
--inference_type=QUANTIZED_UINT8 --inference_input_type=QUANTIZED_UINT8 
--default_ranges_min=0 --default_ranges_max=6 --output_arrays=xx`
   
   replace the output arrays args to your target layer name. Like the first 
layer name / second layer name until you find the issue layer. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to