Skip to content

Conversation

@ddavis-2015
Copy link
Member

@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

@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
@ddavis-2015 ddavis-2015 requested a review from a team as a code owner July 8, 2025 18:59
@ddavis-2015 ddavis-2015 self-assigned this Jul 8, 2025
@ddavis-2015 ddavis-2015 requested a review from veblush September 9, 2025 17:47
Copy link
Collaborator

@veblush veblush left a 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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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 {

Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Collaborator

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.
Copy link
Collaborator

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?

Copy link
Member Author

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};
Copy link
Collaborator

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.

Copy link
Member Author

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
Copy link
Collaborator

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?

Copy link
Member Author

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");
Copy link
Collaborator

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?

Copy link
Member Author

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.

@ddavis-2015
Copy link
Member Author

@veblush decode_test.cc was updated to be compatible with merging into the next PR (pruning).

@ddavis-2015
Copy link
Member Author

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Oct 15, 2025

refresh

✅ Pull request refreshed

@ddavis-2015
Copy link
Member Author

@Mergifyio requeue

@mergify
Copy link
Contributor

mergify bot commented Oct 16, 2025

requeue

❌ Command disallowed due to command restrictions in the Mergify configuration.

  • sender-permission >= write

@ddavis-2015
Copy link
Member Author

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Oct 16, 2025

refresh

✅ Pull request refreshed

@veblush veblush added the ci:run label Oct 16, 2025
@TFLM-bot TFLM-bot removed the ci:run label Oct 16, 2025
@veblush veblush merged commit d96fe66 into tensorflow:main Oct 17, 2025
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for DECODE operator

3 participants