Skip to content

Conversation

@suleshahid
Copy link
Collaborator

Inverse-RFFT as part of Signal library ops.
Testing via current FFT Op tests.

BUG=287346710

@suleshahid suleshahid requested a review from a team as a code owner July 19, 2023 20:04
@TFLM-bot TFLM-bot removed the ci:run label Jul 19, 2023
@suleshahid suleshahid requested a review from rascani July 19, 2023 20:37

auto* params = static_cast<TfLiteAudioFrontendIrfftParams*>(
context->AllocatePersistentBuffer(
context, sizeof(TfLiteAudioFrontendIrfftParams)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a check here to ensure params is not nullptr? Elsewhere, we found this just looked like:

if (params == nullptr) {
  return nullptr;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. Is there any preference over this vs TFLITE_DCHECK()?

Copy link
Contributor

Choose a reason for hiding this comment

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

It matches existing kernel Init functions. They should have an ENSURE and/or a DCHECK done later.

void* Init(TfLiteContext* context, const char* buffer, size_t length) {
TFLITE_DCHECK(context->AllocatePersistentBuffer != nullptr);

const uint8_t* buffer_t = reinterpret_cast<const uint8_t*>(buffer);
Copy link
Contributor

Choose a reason for hiding this comment

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

buffer_t reads as if it is a type, since _t is a common type extension. Since this is only used once down at line 62, can we just remove this variable and put the reinterpret_cast in the call to the FlexbufferWrapper ctor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.


size_t state_size = (*get_needed_memory_func)(params->fft_length);
params->state = reinterpret_cast<int8_t*>(
context->AllocatePersistentBuffer(context, state_size * sizeof(int8_t)));
Copy link
Contributor

Choose a reason for hiding this comment

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

We should do a nullptr check here too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

}

void* IrfftFloatInit(int32_t fft_length, void* state, size_t state_size) {
IrfftFloatState* irfft_float_state = (IrfftFloatState*)state;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should switch this to a static_cast

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

void* IrfftFloatInit(int32_t fft_length, void* state, size_t state_size) {
IrfftFloatState* irfft_float_state = (IrfftFloatState*)state;
irfft_float_state->cfg =
(kiss_fft_float::kiss_fftr_cfg)(irfft_float_state + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

And this one to a reinterpret_cast

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

}

void IrfftFloatApply(void* state, const Complex<float>* input, float* output) {
IrfftFloatState* irfft_float_state = (IrfftFloatState*)state;
Copy link
Contributor

Choose a reason for hiding this comment

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

And this to a static_cast

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@suleshahid
Copy link
Collaborator Author

Ready for another look.


auto* params = static_cast<TfLiteAudioFrontendIrfftParams*>(
context->AllocatePersistentBuffer(
context, sizeof(TfLiteAudioFrontendIrfftParams)));
Copy link
Contributor

Choose a reason for hiding this comment

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

It matches existing kernel Init functions. They should have an ENSURE and/or a DCHECK done later.

@mergify mergify bot merged commit 55037d2 into tensorflow:main Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants