-
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
[Tracking Issue] TFLite operator support #15148
Comments
hi--if no one has taken this yet, can I give this a shot? |
Absolutely @p3achyjr. Each operator can be submitted individually, so we have self contained, easier to review PRs. Let us know if you need any help. Thanks! |
@leandron I see that the code has changed a lot from the example#9165. All tests are all combined to one function, so if I just need to remove the conditional block and test it? Besides, because I am totally new to it, I find it a little bit tough to have a test, can you offer me some simple ways? |
@tlopex if you're working on this too, would you like to divide up the operators so we don't do redundant work? |
@p3achyjr I'm glad to do that. What operators tasks have you doing now? |
I won't be able to work on this for the next couple weeks, so feel free to take anything :) |
Maybe #14667 can be an updated version of the way to support new operators? Have a look on this one and let me know. |
@p3achyjr So am I. I think I won't have time to do this work until the first few days of September. If you start to work on it, just inform me. Thanks. |
I'm back now. I can take a look at FLOOR_DIV. |
@p3achyjr Okay, got it. I am now trying to work on SQUARE. |
Finally getting around to this--a draft PR is at #15724 |
Got it. Actually I don't know clearly how to write a test for unary element operation... And I will try again in following days. |
As per #15148, we are adding support for quantized operations one by one. This PR adds support for floor_div.
@tlopex maybe you can try something like this first? tvm/tests/python/frontend/tflite/test_forward.py Lines 2249 to 2251 in e3055c1
I'm happy to keep working on the elemwise ones :) |
@p3achyjr Thanks. You set me a really great example. I'll try it again. |
As part of #15148, this PR adds support for floor_mod.
As per #15148, adding support for div.
Support GREATER_EQUAL quantization operation as part of #15148
Confirmed, when running |
I'm not able to create a revert--has one already been created? |
@Lunderberg what error messages do you see when the tests fail? I wonder if the range should be (0,150) since mod can't be negative, and whether that's causing the failures. |
The error message is below (full test output here). Unfortunately, this doesn't indicate a clear location where it occurs, only that the final result was mismatched.
|
Between the mismatches having suspicious My current guess is that there's something going on with the data generation. Currently, |
I see what you're saying--maybe we can add min/max overrides for May I ask how you're running these tests multiple times? This seems to just tell you how to run it one time. |
That's what I'm thinking as well. It looks like it currently uses the same range for both quantization and for data generation. I think it will need to override the data generation range to exclude zero from the denominator, but to keep zero in the quantization range as zero may occur in the output.
Agreed, as I would expect the same problem to effect any operator with a restricted domain. My guess is that there's some optimization that assumes the inputs to be valid (a legal assumption, as the output is typically undefined when the denominator is zero), and that that optimization is affecting floormod differently from floordiv. It probably would be good to track that optimization down at some point, if it occurs at the TVM level, but I don't think that should delay the re-enabling of the unit test.
It's a bit of a hacky way to do so. I commented out everything in import pytest
@pytest.fixture(params=list(range(100)), autouse=True)
def repeat_all_tests(request):
return request.param I suppose I could have just made a for loop, but I was lazy and this let me use pytest's pass/fail counter instead of making my own :P. |
I ran some tests--it looks like
so at the index where the elements diverge (-5), the input data is My question is whether |
Here, if the range is symmetrical, the zero point will always be 128. |
Thanks @tlopex! I'm working on a draft PR to regenerate the input values if any of them are at the zero point. Hopefully I can have it up soon. |
@p3achyjr Rather than regenerating, would it be easier to alter the generated values? That would avoid potentially regenerating data over and over. # Assuming we know that the operator is mod/div/floormod/floordiv,
# and the generated denominator is in a np.ndarray named "denominator".
denominator[denominator==0] += 1 |
Thanks for that! sorry not a numpy guy. |
@p3achyjr May I ask you how did you run the tests. Why I use some commands like |
@tlopex @Lunderberg had a comment above^^
put that at the bottom of the test file and then run the docker script as usual. |
@p3achyjr Thanks. |
Support POW quantization operation as part of #15148
In #9187 we implemented quantised version of operators in TFLite frontend. Recently, I just noticed a few more operators (with varying priorities) that can be taken as beginner friendly tasks, for someone who's starting in TVM.
I'm creating this as a tracking issue to mark those operators that need to have quantization support implemented and tested:
FLOOR_DIV
([TFLite][Frontend] Support quantized floor_div #15724)FLOOR_MOD
([TFLite][Frontend] Support quantized floor_mod #15733)DIV
([TFLite][Frontend] Support quantized div #15768)POW
([TFLite][Frontend] Support quantized Pow #15798)REVERSE_SEQUENCE
([TFLite][Frontend] Support quantized Reverse sequence #15915)SQUARE
([TFLite][Frontend] Support quantized SQUARE #15914)ELU
([TFLite][Frontend] Support quantized ELU #15821)LOCAL_RESPONSE_NORMALIZATION
(LRN)L2_NORMALIZATION
MIRROR_PAD
([TFLite] Add support for quantized mirror pad #16243)ARG_MIN
([TFLite][Frontend] Support quantized ARG_MIN #15922)NOT_EQUAL
([TFLite][Frontend] Support quantized NOT_EQUAL #15769)LESS
([TFLite][Frontend] Support quantized LESS #15746)LESS_EQUAL
([TFLite][Frontend] Support quantized LESS_EQUAL #15790)GREATER_EQUAL
([TFLite][Frontend] Support quantized GREATER_EQUAL #15775)For each operator above, there are actions to be taken:
if self.is_quantized(op): ...
#9165 can be used as an example.
In case you're interested, a good starting point is the TFLite frontend:
tvm/python/tvm/relay/frontend/tflite.py
Lines 78 to 185 in bee073b
The text was updated successfully, but these errors were encountered: