-
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
[Relay][Frontend][TFLite] Add parser support for squared difference #4652
Conversation
Could you check this PR, @kevinthesun @FrozenGene |
@@ -723,6 +723,14 @@ def _test_greater(data): | |||
""" One iteration of greater """ | |||
return _test_elemwise(math_ops.greater, data) | |||
|
|||
####################################################################### | |||
# Squared_difference | |||
# ------- |
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.
Align - the same length of squared_difference
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.
fixed
python/tvm/relay/frontend/tflite.py
Outdated
# Check if the input tensor is quantized, call QNN op | ||
if self.is_quantized(op): | ||
raise tvm.error.OpNotImplemented( | ||
'TFlite quantized greater operator is not supported yet.') |
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.
comment is wrong. Not greater op.
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.
fixed
python/tvm/relay/frontend/tflite.py
Outdated
raise tvm.error.OpNotImplemented( | ||
'TFlite quantized greater operator is not supported yet.') | ||
difference = self._convert_elemwise(_op.subtract, op) | ||
out = _op.multiply(difference, difference) |
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.
maybe could consider using power
.
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.
fixed
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. Thanks!
python/tvm/relay/frontend/tflite.py
Outdated
raise tvm.error.OpNotImplemented( | ||
'TFlite quantized squared difference operator is not supported yet.') | ||
difference = self._convert_elemwise(_op.subtract, op) | ||
out = _op.power(difference, relay.const(2, 'float32')) |
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.
It it better not make it be relay.const(2, 'float32'))
. Because let us imagine if op's data is fp16 (in the future), 2
shouldn't be float32
. So we could do like this: call get_tensor_type_str(self.get_output_tensors(op)[0].tensor.Type())
to get type, then call _op.power
. Or if you think it is complex, you could simply call _op.multiple(difference, difference)
, I think it is OK. Previously, I mention _op.power, because we could have intrinsic of power to handle it. However, I think it shouldn't be bottleneck after thinking twice.
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.
Thanks for your suggestion. I think _op.power
is more appropriate here and I have already fixed it.
Thanks @wyc-ruiker LGTM now. Let us wait CI's result. |
Thanks @wyc-ruiker This is merged. |
…pache#4652) * [Relay][Frontend][TFLite] Add parser support for squared difference * fix some error * fix exp_type * add comment
…pache#4652) * [Relay][Frontend][TFLite] Add parser support for squared difference * fix some error * fix exp_type * add comment
…pache#4652) * [Relay][Frontend][TFLite] Add parser support for squared difference * fix some error * fix exp_type * add comment
Thanks for contributing to TVM! Please refer to guideline https://docs.tvm.ai/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.