-
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
[Frontend][TFLite] L2_POOL_2D operator #5452
Conversation
in_data = tf.placeholder( | ||
dtype=tf.float32, name="input", shape=input_shape) | ||
out = tf.sqrt(tf.nn.avg_pool( | ||
tf.square(in_data), ksize=ksize, strides=strides, | ||
padding=padding, data_format=data_format)) | ||
out = with_fused_activation_function(out, fused_func_name) | ||
|
||
compare_tflite_with_tvm(x, 'input', [in_data], [out]) |
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.
Very quick drive-by review :
Don't we need a qnn test here ? I haven't managed to read up L2_POOL_2D in the tflite documentation 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.
TFLite doesn't have support for quantized L2_POOL_2D 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.
Thanks , possibly worth a belts and braces check to ensure we catch this in the frontend to ensure we think through qnn support rather than getting an unknown failure.
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.
added check.
python/tvm/relay/frontend/tflite.py
Outdated
@@ -1770,6 +1775,12 @@ def convert_pool2d(self, op, pool_type): | |||
assert self.has_same_qnn_params(input_tensor, output_tensor), \ | |||
"qnn.op.max_pool2d requires input and output qnn params to be same" | |||
out = _op.nn.max_pool2d(in_expr, **params) | |||
elif pool_type == "l2": | |||
# l2_pool_2d is equivalent to square_root(avg_pool(square(in_data))) |
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.
Add a protection check to throw error if you receive quantized inputs.
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.
TFLite does not support quantized L2_POOL_2D. That's why the check is not added. Now I have added a comment for the same.
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.
Putting in the check has the following benefits:
- Better user experience as the rest of the stack doesn't get basically undefined behaviour because of random input..
- A signal to us as a community in the form of a bug report that this is appearing.
Ramana
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.
ok, make sense. I have added the check.
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
@u99127, @siju-samuel, @FrozenGene, Thanks. The review comments are addressed. Could you please help in merging the PR. |
Thanks @maheshambule @siju-samuel @u99127 merged now |
* TFLITE fill and splitv ops * l2_pool_2d op changes in comment * TFLite l2_pool_2d op added test case in main * TFLite L2_POOL_2D added check for quantized input
* TFLITE fill and splitv ops * l2_pool_2d op changes in comment * TFLite l2_pool_2d op added test case in main * TFLite L2_POOL_2D added check for quantized input
* TFLITE fill and splitv ops * l2_pool_2d op changes in comment * TFLite l2_pool_2d op added test case in main * TFLite L2_POOL_2D added check for quantized input
Adds support for L2_POOL_2D operator in TFLITE frontened.
Ref:
https://www.tensorflow.org/lite/guide/ops_compatibility
@u99127, @siju-samuel, @FrozenGene Please review.