New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parse onnx model failed #346
Comments
这个问题出现的原因在于QuantizeLinear这个算子的定义并不被广泛认可。你可以查阅下面的文档内容: QuantizeLinear 这个算子需要一个 axis 属性,用来指定量化行为发生的轴。对于 per channel 量化而言这是无可厚非的,但对于激活量化(per tensor)量化而言,它们没有一个有效的 axis 属性,这个时候 onnx 对他的定义是 axis 属性可以被忽略。 然而不同的厂家推理框架写的时候压根不遵循这个标准,比如 openvino 它不管你是 per channel 的还是 per tensor 的,它都要有一个 axis 属性。但是 tensorRT,也就是你现在的这个错误,它显然不希望你有这个 axis 属性。 对于这个问题,你可以手动修改 ppq.parser.onnxruntime_exporter.py,其中函数 insert_quantize_node, insert_dequantize_node 负责插入网络中的 Quantize 与 Dequantize 节点,其中包含代码:
你可以将 else 子句直接删除,这样 PPQ 将不会对 Per tensor 的量化写入 axis 属性。 |
我把 |
所以它是 per channel 的? |
可能是这样的,但是tensorRT似乎对于QuantizeLinear只要有 axis 属性就无法解析,[还未验证] |
我发现是激活全部用per tensor,权重是用的per channel,我还不太清楚如何设置全部使用per tensor模式 |
如果你想全部设置成 per tensor,则需要进入 ppq.quantization.quantizer 文件夹,找到你所使用的 quantizer 并进行修改,它并不是很困难。 另外如果你使用 tensorRT 部署的话,新的 ppq 好像是通过 onnx+json 的方式传递量化信息的,而你似乎是使用 qdq+onnx 的方式完成部署的,这中间是发生了什么故事吗? |
problem:
The text was updated successfully, but these errors were encountered: