-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[ONNX] QLinearConv Support #8007
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it needs a rebase? I'm not sure I understand the issue with the onnx tests, is that something we can work around?
# For QLinearConv tests in ONNX, scale and zero_point input are placeholders, | ||
# but qnn.conv2d requires scale and zero_point input to be scalar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this comment more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried to work around this issue but failed. For ONNX test model of QLinearConv, y_scale is input node and will be parsed to free_var in relay. It will cause an error while lowering requantize because it requires output_scale (y_scale) to be constant expr:
E 1: tvm::relay::qnn::RequantizeLower(tvm::RelayExpr const&, tvm::RelayExpr const&, tvm::RelayExpr const&, tvm::RelayExpr const&, tvm::RelayExpr const&, tvm::relay::qnn::RequantizeAttrs const*, tvm::r
untime::Array<tvm::PrimExpr, void> const&, tvm::runtime::DataType const&)
E at /home/liuliang/Desktop/tvms/tvm/src/relay/qnn/op/requantize.cc:148
E 0: float tvm::relay::GetScalarFromConstant<float>(tvm::RelayExpr)
E at /home/liuliang/Desktop/tvms/tvm/src/relay/qnn/op/../../transforms/pattern_utils.h:514
E File "/home/liuliang/Desktop/tvms/tvm/src/relay/quantize/../transforms/pattern_utils.h", line 514
E TVMError:
E ---------------------------------------------------------------
E An error occurred during the execution of TVM.
E For more information, please see: https://tvm.apache.org/docs/errors.html
E ---------------------------------------------------------------
E Check failed: (n) is false: Expr must be a constant expr - #[version = "0.0.5"]
E free_var %y_scale: float32;
E cast(%y_scale, dtype="float32") /* ty=float32 */
Do you have some suggestions to solve it?
Hmm, what do you think about checking to see if the scale is constant, and if it's not, doing dequantize -> quantize instead of requantize? |
@mbrookhart, thanks! The idea looks good, it could solve the issue! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Looks like we had a CI outage, can you rebase to kick off a new job?
Thanks @huochaitiantang ! |
* Add QLinearConv for onnx frontend * Reformat * Squeeze 1D tensor for weight_scale & weight_zero_point * Doing dequatize -> quantize if y_scale is not constant
* Add QLinearConv for onnx frontend * Reformat * Squeeze 1D tensor for weight_scale & weight_zero_point * Doing dequatize -> quantize if y_scale is not constant
* Add QLinearConv for onnx frontend * Reformat * Squeeze 1D tensor for weight_scale & weight_zero_point * Doing dequatize -> quantize if y_scale is not constant
Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.