-
Notifications
You must be signed in to change notification settings - Fork 961
Support for DECODE operator #3216
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
base: main
Are you sure you want to change the base?
Changes from all commits
59589c6
e21bf4c
704f105
2c859d8
9ac09a0
0035387
166e0e4
1933762
a5ef7b1
c84ed1c
51ffdc2
6fbb8d8
f5a3d4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,8 @@ namespace tflite { | |
| // TODO(b/149795762): kTfLiteAbort cannot be part of the tflite TfLiteStatus. | ||
| const TfLiteStatus kTfLiteAbort = static_cast<TfLiteStatus>(15); | ||
|
|
||
| class DecodeState; // can't use decode_state.h due to circular include | ||
|
|
||
| // MicroContext is eventually going to become the API between TFLM and the | ||
| // kernels, replacing all the functions in TfLiteContext. The end state is code | ||
| // kernels to have code like: | ||
|
|
@@ -136,7 +138,7 @@ class MicroContext { | |
| }; | ||
|
|
||
| // Set the alternate decompression memory regions. | ||
| // Can only be called during the MicroInterpreter kInit state. | ||
| // Can only be called during the kInit state. | ||
| virtual TfLiteStatus SetDecompressionMemory( | ||
| const std::initializer_list<AlternateMemoryRegion>& regions); | ||
|
|
||
|
|
@@ -169,12 +171,40 @@ class MicroContext { | |
| return nullptr; | ||
| } | ||
|
|
||
| struct CustomDecodeRegistration { | ||
| uint8_t type; // custom decode type | ||
| uint8_t reserved1; // reserved | ||
| uint8_t reserved2; // reserved | ||
| uint8_t reserved3; // reserved | ||
| tflite::DecodeState* (*func)(const TfLiteContext*, MicroProfilerInterface*); | ||
| }; | ||
|
|
||
| // Set the custom DECODE operator registrations. | ||
| // Can only be called during the kInit state. | ||
| virtual TfLiteStatus SetCustomDecodeRegistrations( | ||
| const std::initializer_list<CustomDecodeRegistration>& registrations) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With this change, this kind of help function would be helpful . We might want to make a similar change to |
||
| if (custom_decode_registrations_ != nullptr) { | ||
| return kTfLiteError; | ||
| } | ||
| custom_decode_registrations_ = ®istrations; | ||
| return kTfLiteOk; | ||
| } | ||
|
|
||
| // Get the custom decompression registrations. | ||
| virtual const std::initializer_list<CustomDecodeRegistration>* | ||
| GetCustomDecodeRegistrations() const { | ||
| return custom_decode_registrations_; | ||
| } | ||
|
|
||
| private: | ||
| const std::initializer_list<AlternateMemoryRegion>* decompress_regions_ = | ||
| nullptr; | ||
| // array of size_t elements with length equal to decompress_regions_.size() | ||
| size_t* decompress_regions_allocations_ = nullptr; | ||
|
|
||
| const std::initializer_list<CustomDecodeRegistration>* | ||
| custom_decode_registrations_ = nullptr; | ||
|
|
||
| TF_LITE_REMOVE_VIRTUAL_DELETE | ||
| }; | ||
|
|
||
|
|
||
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.
Instead of
func,factoryorcreate_statewould be better to describes what the function will do.