-
Notifications
You must be signed in to change notification settings - Fork 963
Support for DECODE operator #3132
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
Conversation
@tensorflow/micro Add initial support for DECODE operator. Add reference implementation. Add LUT decompression support. Update op resolvers. Update Makefiles and Bazel BUILD files. Add kernel unit test. bug=fixes tensorflow#3131
…em). Cleanup unit test.
veblush
left a comment
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 the PR! This looks great, I've just left a few minor suggestions.
|
|
||
| namespace tflite { | ||
|
|
||
| struct DecodeState { |
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.
Please change this to class per https://google.github.io/styleguide/cppguide.html#Structs_vs._Classes
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.
|
|
||
| namespace tflite { | ||
|
|
||
| struct DecodeStateLUT : public DecodeState { |
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.
Please rename this to DecodeStateLut per https://google.github.io/styleguide/cppguide.html#General_Naming_Rules
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.
| #include "tensorflow/lite/micro/micro_profiler_interface.h" | ||
|
|
||
| namespace tflite { | ||
|
|
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.
What do you think about converting DecodeState into an interface called IDecodeAlgorithm? This would clarify its role, and we could then reorganize the helper functions into a separate container class.
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.
Perhaps as another PR, after we refactor the DECODE code for size? I don't know yet what DecodeState will look like after the refactor.
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.
SGTM
| @@ -0,0 +1,344 @@ | |||
| /* Copyright 2025 The TensorFlow Authors. All Rights Reserved. | |||
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.
Would it be clearer if we split this into separate tests, with each one focused on a specific algorithm?
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.
This will be done starting with the next PR (pruning).
| }; | ||
|
|
||
| // Align the tensor data the same as a Buffer in the TfLite schema | ||
| alignas(16) const uint8_t kEncodedLUT[] = {0x1B, 0xE4}; |
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'd be useful to have a comment as to how this is constructed.
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.
| count -= 1; | ||
| } | ||
|
|
||
| // process elements in current channel in groups of 16 |
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.
Out of curiosity, why 16 instead of 8?
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 believe it was just copy/paste of DecompressToBufferWidth4_16 with modification of the masks/shifts. I don't remember any other reason.
| @@ -0,0 +1,344 @@ | |||
| /* Copyright 2025 The TensorFlow Authors. All Rights Reserved. | |||
|
|
|||
| Licensed under the Apache License, Version 2.0 (the "License"); | |||
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.
LUT has many combinations to cover. Then, do you have a plan to expand the coverage a bit?
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.
For the current decompression code, we have a comprehensive test of LUT decompression in tensorflow/lite/micro/kernels/decompress_test.cc
This test will be copied and made to work with DecodeState in a future PR.
|
@veblush |
|
@Mergifyio refresh |
✅ Pull request refreshed |
|
@Mergifyio requeue |
❌ Command disallowed due to command restrictions in the Mergify configuration.
|
|
@Mergifyio refresh |
✅ Pull request refreshed |
@tensorflow/micro
Add initial support for DECODE operator.
Add reference implementation.
Add LUT decompression support.
Update op resolvers.
Update Makefiles and Bazel BUILD files.
Add kernel unit test.
bug=fixes #3131