brevitas
brevitas copied to clipboard
QuantRelu's forward reasoning process
Hello author, I am still trying to use pytorch to simulate the quantization and dequantization forward reasoning process of brevitas. I have the following two questions to ask you:
- When I observed the pth file, I found that QuantRelu corresponds to a value: branch1.0.act_quant.fused_activation_quant_proxy.tensor_quant.scaling_impl.value What is this value?
- What is the forward reasoning process of QuantRelu? Can you give me a description like this? https://github.com/Xilinx/brevitas/issues/327#issue-900975345
Looking forward to your reply, thank you very much !
Hello, QuantReLU first applies a relu and then performs quantization on the output. The value of the scale factor in the pth is not necessarily the value used for relu. You check the value at runtime call the .quant_act_scale(), or export the model to ONNX with BrevitasONNXManager.export .
Hello, QuantReLU first applies a relu and then performs quantization on the output. The value of the scale factor in the pth is not necessarily the value used for relu. You check the value at runtime call the .quant_act_scale(), or export the model to ONNX with BrevitasONNXManager.export .
Thank goodness you are here, hello author, please give me some time to add my questions, very grateful!
Taking this node as an example, I did not quantize the input, so if I use pytorch to simulate the quantization and inverse quantization operation here, it is:
1.int_weight() Get the convolutional layer weight of int
2.conv_result = nn.Conv2d(int_weight(),input)
3.conv_result*weight_scale() dequantize the output value
Is that right?
Look at this example again. If I still want to use pytorch to implement this process, are the following steps correct?
1.int_weight() Get the convolutional layer weight of int
2.input(int) = input(float)/0.1322 (scale in the Quant node) quantized input
2.conv_result = nn.Conv2d(int_weight(),input(int))
3.conv_result*weight_scale()*0.1322 dequantize the output value
At the same time, I have a very special example here. Two Quant nodes are connected together. How can I solve this situation?
Looking forward to your answers to my questions, I would like to extend my sincerest thanks to the author!