Skip to content
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

[TFLM] SVDF kernel refactoring #47911

Merged
merged 9 commits into from Mar 22, 2021

Conversation

yair-ehrenwald
Copy link
Contributor

@yair-ehrenwald yair-ehrenwald commented Mar 19, 2021

In preparation for a PR for CEVA-DSP optimized SVDF kernel - moved the Prepare function into svdf_common as we did for previous kernels + since we have an optimized implementation for float32 as well, moved the reference code into svdf_common too so it can be used a fallback.

(please ignore the depthwise commit in there, was removed)

@google-ml-butler google-ml-butler bot added the size:L CL Change Size: Large label Mar 19, 2021
@google-ml-butler
Copy link

Thanks for contributing to TensorFlow Lite Micro.

To keep this process moving along, we'd like to make sure that you have completed the items on this list:

We would like to have a discussion on the Github issue first to determine the best path forward, and then proceed to the PR review.

@google-cla google-cla bot added the cla: yes label Mar 19, 2021
@yair-ehrenwald yair-ehrenwald added the comp:micro Related to TensorFlow Lite Microcontrollers label Mar 19, 2021
@gbaned gbaned self-assigned this Mar 19, 2021
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation Mar 19, 2021
Copy link
Member

@advaitjain advaitjain left a comment

Choose a reason for hiding this comment

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

small naming nits.

@@ -52,284 +41,12 @@ constexpr int kOutputTensor = 0;
* and resizes the output tensor. Micro runtime does not support tensor
* resizing.
*/
Copy link
Member

Choose a reason for hiding this comment

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

move the comment to svdf_common.cc as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 39 to 47
constexpr int kInputTensor = 0;
constexpr int kWeightsFeatureTensor = 1;
constexpr int kWeightsTimeTensor = 2;
constexpr int kBiasTensor = 3;
// This is a variable tensor, and will be modified by this op.
constexpr int kInputActivationStateTensor = 4;

// Output tensor.
constexpr int kOutputTensor = 0;
Copy link
Member

Choose a reason for hiding this comment

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

make extern const and add Svdf prefix (e.g. kSvdfInputTensor)

extern const int kFullyConnectedInputTensor;
extern const int kFullyConnectedWeightsTensor;
extern const int kFullyConnectedBiasTensor;
extern const int kFullyConnectedOutputTensor;

See section on constants in header files: https://abseil.io/tips/140

Since we are not using c++17, we can not use inline constexpr and and extern const is the way to go for us.

And add definition in svdf_common.cc:

const int kFullyConnectedInputTensor = 0;
const int kFullyConnectedWeightsTensor = 1;
const int kFullyConnectedBiasTensor = 2;
const int kFullyConnectedOutputTensor = 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -46,6 +57,16 @@ void EvalIntegerSvdfReference(TfLiteContext* context, TfLiteNode* node,
TfLiteEvalTensor* output_tensor,
const OpData& data);

void EvalFloatSVDF(TfLiteContext* context, TfLiteNode* node,
Copy link
Member

Choose a reason for hiding this comment

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

nit: change name to EvalFloatSvdfReference

note Svdf instead of SVDF.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

int scratch_tensor_index, TfLiteEvalTensor* activation_state,
TfLiteEvalTensor* output);

TfLiteStatus PrepareSVDF(TfLiteContext* context, TfLiteNode* node);
Copy link
Member

Choose a reason for hiding this comment

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

PrepareSvdf

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

PR Queue automation moved this from Assigned Reviewer to Reviewer Requested Changes Mar 19, 2021
@yair-ehrenwald yair-ehrenwald added the kokoro:force-run Tests on submitted change label Mar 19, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Mar 19, 2021
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Mar 19, 2021
PR Queue automation moved this from Reviewer Requested Changes to Approved by Reviewer Mar 19, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Mar 19, 2021
@gbaned gbaned added ready to pull PR ready for merge process and removed ready to pull PR ready for merge process labels Mar 22, 2021
@copybara-service copybara-service bot merged commit 8f3a074 into tensorflow:master Mar 22, 2021
PR Queue automation moved this from Approved by Reviewer to Merged Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes comp:micro Related to TensorFlow Lite Microcontrollers ready to pull PR ready for merge process size:L CL Change Size: Large
Projects
PR Queue
  
Merged
Development

Successfully merging this pull request may close these issues.

None yet

4 participants