- 
                Notifications
    You must be signed in to change notification settings 
- Fork 952
Adds IRFFT Op to Signal Library #2137
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
|  | ||
| auto* params = static_cast<TfLiteAudioFrontendIrfftParams*>( | ||
| context->AllocatePersistentBuffer( | ||
| context, sizeof(TfLiteAudioFrontendIrfftParams))); | 
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.
Can we add a check here to ensure params is not nullptr? Elsewhere, we found this just looked like:
if (params == nullptr) {
  return nullptr;
}
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.
Done. Is there any preference over this vs TFLITE_DCHECK()?
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 matches existing kernel Init functions. They should have an ENSURE and/or a DCHECK done later.
        
          
                signal/micro/kernels/irfft.cc
              
                Outdated
          
        
      | 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); | 
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.
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?
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.
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))); | 
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.
We should do a nullptr check here too.
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.
Done.
        
          
                signal/src/irfft_float.cc
              
                Outdated
          
        
      | } | ||
|  | ||
| void* IrfftFloatInit(int32_t fft_length, void* state, size_t state_size) { | ||
| IrfftFloatState* irfft_float_state = (IrfftFloatState*)state; | 
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.
We should switch this to a static_cast
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.
Done.
        
          
                signal/src/irfft_float.cc
              
                Outdated
          
        
      | 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); | 
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.
And this one to a reinterpret_cast
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.
Done.
        
          
                signal/src/irfft_float.cc
              
                Outdated
          
        
      | } | ||
|  | ||
| void IrfftFloatApply(void* state, const Complex<float>* input, float* output) { | ||
| IrfftFloatState* irfft_float_state = (IrfftFloatState*)state; | 
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.
And this to a static_cast
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.
Done.
| Ready for another look. | 
|  | ||
| auto* params = static_cast<TfLiteAudioFrontendIrfftParams*>( | ||
| context->AllocatePersistentBuffer( | ||
| context, sizeof(TfLiteAudioFrontendIrfftParams))); | 
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 matches existing kernel Init functions. They should have an ENSURE and/or a DCHECK done later.
Inverse-RFFT as part of Signal library ops.
Testing via current FFT Op tests.
BUG=287346710