Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
shlmregev committed Mar 9, 2024
1 parent d5ff3ba commit b982bda
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 72 deletions.
4 changes: 2 additions & 2 deletions signal/micro/kernels/delay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ void DelayReset(TfLiteContext* context, void* buffer) {

namespace tflm_signal {
TFLMRegistration* Register_DELAY() {
static TFLMRegistration r =
micro::RegisterOp(DelayInit, DelayPrepare, DelayEval, nullptr, DelayReset);
static TFLMRegistration r = micro::RegisterOp(DelayInit, DelayPrepare,
DelayEval, nullptr, DelayReset);
return &r;
}
} // namespace tflm_signal
Expand Down
4 changes: 2 additions & 2 deletions signal/micro/kernels/energy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ TfLiteStatus EnergyEval(TfLiteContext* context, TfLiteNode* node) {

namespace tflm_signal {
TFLMRegistration* Register_ENERGY() {
static TFLMRegistration r = tflite::micro::RegisterOp(
EnergyInit, EnergyPrepare, EnergyEval);
static TFLMRegistration r =
tflite::micro::RegisterOp(EnergyInit, EnergyPrepare, EnergyEval);
return &r;
}
} // namespace tflm_signal
Expand Down
6 changes: 3 additions & 3 deletions signal/micro/kernels/filter_bank.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ struct TFLMSignalFilterBankParams {
uint64_t* work_area;
};

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

auto* params = static_cast<TFLMSignalFilterBankParams*>(
Expand Down Expand Up @@ -168,7 +168,7 @@ namespace tflm_signal {

TFLMRegistration* Register_FILTER_BANK() {
static TFLMRegistration r = tflite::micro::RegisterOp(
FilterBankInit, FilterBankPrepare, FilterBankEval);
FilterBankInit, FilterBankPrepare, FilterBankEval);
return &r;
}

Expand Down
6 changes: 3 additions & 3 deletions signal/micro/kernels/filter_bank_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ struct TFLMSignalLogParams {
int output_scale;
};

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

auto* params = static_cast<TFLMSignalLogParams*>(
Expand Down Expand Up @@ -105,7 +105,7 @@ namespace tflm_signal {

TFLMRegistration* Register_FILTER_BANK_LOG() {
static TFLMRegistration r = tflite::micro::RegisterOp(
FilterBankLogInit, FilterBankLogPrepare, FilterBankLogEval);
FilterBankLogInit, FilterBankLogPrepare, FilterBankLogEval);
return &r;
}

Expand Down
27 changes: 12 additions & 15 deletions signal/micro/kernels/filter_bank_spectral_subtraction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ struct TFLMSignalSpectralSubtractionParams {
};

void FilterBankSpectralSubtractionResetState(
TFLMSignalSpectralSubtractionParams* params) {
TFLMSignalSpectralSubtractionParams* params) {
memset(params->noise_estimate, 0,
sizeof(uint32_t) * params->config.num_channels);
}

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

auto* params = static_cast<TFLMSignalSpectralSubtractionParams*>(
Expand Down Expand Up @@ -98,8 +98,8 @@ void* FilterBankSpectralSubtractionInit(
return params;
}

TfLiteStatus FilterBankSpectralSubtractionPrepare(
TfLiteContext* context, TfLiteNode* node) {
TfLiteStatus FilterBankSpectralSubtractionPrepare(TfLiteContext* context,
TfLiteNode* node) {
TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);
TF_LITE_ENSURE_EQ(context, NumOutputs(node), 2);

Expand Down Expand Up @@ -136,8 +136,8 @@ TfLiteStatus FilterBankSpectralSubtractionPrepare(
return kTfLiteOk;
}

TfLiteStatus FilterBankSpectralSubtractionEval(
TfLiteContext* context, TfLiteNode* node) {
TfLiteStatus FilterBankSpectralSubtractionEval(TfLiteContext* context,
TfLiteNode* node) {
auto* params =
reinterpret_cast<TFLMSignalSpectralSubtractionParams*>(node->user_data);

Expand All @@ -164,21 +164,18 @@ TfLiteStatus FilterBankSpectralSubtractionEval(

void FilterBankSpectralSubtractionReset(TfLiteContext* context, void* buffer) {
FilterBankSpectralSubtractionResetState(
static_cast<TFLMSignalSpectralSubtractionParams*>(buffer));
static_cast<TFLMSignalSpectralSubtractionParams*>(buffer));
}

} // namespace

namespace tflm_signal {

TFLMRegistration* Register_FILTER_BANK_SPECTRAL_SUBTRACTION() {
static TFLMRegistration r =
tflite::micro::RegisterOp(
FilterBankSpectralSubtractionInit,
FilterBankSpectralSubtractionPrepare,
FilterBankSpectralSubtractionEval,
/*Free*/ nullptr,
FilterBankSpectralSubtractionReset);
static TFLMRegistration r = tflite::micro::RegisterOp(
FilterBankSpectralSubtractionInit, FilterBankSpectralSubtractionPrepare,
FilterBankSpectralSubtractionEval,
/*Free*/ nullptr, FilterBankSpectralSubtractionReset);
return &r;
}

Expand Down
9 changes: 4 additions & 5 deletions signal/micro/kernels/filter_bank_square_root.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ constexpr int kInputTensor = 0;
constexpr int kScaleBitsTensor = 1;
constexpr int kOutputTensor = 0;

TfLiteStatus FilterBankSquareRootEval(
TfLiteContext* context, TfLiteNode* node) {
TfLiteStatus FilterBankSquareRootEval(TfLiteContext* context,
TfLiteNode* node) {
const TfLiteEvalTensor* input =
tflite::micro::GetEvalInput(context, node, kInputTensor);
const TfLiteEvalTensor* scale_bits =
Expand All @@ -55,9 +55,8 @@ TfLiteStatus FilterBankSquareRootEval(
namespace tflm_signal {

TFLMRegistration* Register_FILTER_BANK_SQUARE_ROOT() {
static TFLMRegistration r =
tflite::micro::RegisterOp(
nullptr, FilterBankSquareRootPrepare, FilterBankSquareRootEval);
static TFLMRegistration r = tflite::micro::RegisterOp(
nullptr, FilterBankSquareRootPrepare, FilterBankSquareRootEval);
return &r;
}

Expand Down
5 changes: 2 additions & 3 deletions signal/micro/kernels/framer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ void FramerReset(TfLiteContext* context, void* buffer) {
namespace tflm_signal {
// TODO(b/286250473): remove namespace once de-duped libraries above
TFLMRegistration* Register_FRAMER() {
static TFLMRegistration r =
tflite::micro::RegisterOp(
FramerInit, FramerPrepare, FramerEval, nullptr, FramerReset);
static TFLMRegistration r = tflite::micro::RegisterOp(
FramerInit, FramerPrepare, FramerEval, nullptr, FramerReset);
return &r;
}
} // namespace tflm_signal
Expand Down
6 changes: 3 additions & 3 deletions signal/micro/kernels/irfft.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ void* IrfftInitAll(TfLiteContext* context, const char* buffer, size_t length) {
switch (tensor_type) {
case TensorType_INT16: {
return IrfftInit<int16_t, tflm_signal::IrfftInt16GetNeededMemory,
tflm_signal::IrfftInt16Init>(context, buffer, length);
tflm_signal::IrfftInt16Init>(context, buffer, length);
}
case TensorType_INT32: {
return IrfftInit<int32_t, tflm_signal::IrfftInt32GetNeededMemory,
tflm_signal::IrfftInt32Init>(context, buffer, length);
tflm_signal::IrfftInt32Init>(context, buffer, length);
}
case TensorType_FLOAT32: {
return IrfftInit<float, tflm_signal::IrfftFloatGetNeededMemory,
tflm_signal::IrfftFloatInit>(context, buffer, length);
tflm_signal::IrfftFloatInit>(context, buffer, length);
}
default:
return nullptr;
Expand Down
36 changes: 12 additions & 24 deletions signal/micro/kernels/overlap_add.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ void OverlapAddResetState(TFLMSignalOverlapAddParams<T>* params) {
}

template <typename T>
void* OverlapAddInit(
TfLiteContext* context, const char* buffer, size_t length) {
void* OverlapAddInit(TfLiteContext* context, const char* buffer,
size_t length) {
const uint8_t* buffer_t = reinterpret_cast<const uint8_t*>(buffer);

auto* params = static_cast<TFLMSignalOverlapAddParams<T>*>(
Expand Down Expand Up @@ -149,8 +149,8 @@ void OverlapAddReset(TfLiteContext* context, void* buffer) {
OverlapAddResetState(static_cast<TFLMSignalOverlapAddParams<T>*>(buffer));
}

void* OverlapAddInitAll(
TfLiteContext* context, const char* buffer, size_t length) {
void* OverlapAddInitAll(TfLiteContext* context, const char* buffer,
size_t length) {
const uint8_t* buffer_t = reinterpret_cast<const uint8_t*>(buffer);
const flexbuffers::Map& m = flexbuffers::GetRoot(buffer_t, length).AsMap();
auto tensor_type = static_cast<tflite::TensorType>(m["T"].AsInt32());
Expand Down Expand Up @@ -221,34 +221,22 @@ void OverlapAddResetAll(TfLiteContext* context, void* buffer) {
namespace tflm_signal {
TFLMRegistration* Register_OVERLAP_ADD() {
static TFLMRegistration r =
tflite::micro::RegisterOp(
OverlapAddInitAll,
OverlapAddPrepareAll,
OverlapAddEvalAll,
nullptr,
OverlapAddResetAll);
tflite::micro::RegisterOp(OverlapAddInitAll, OverlapAddPrepareAll,
OverlapAddEvalAll, nullptr, OverlapAddResetAll);
return &r;
}

TFLMRegistration* Register_OVERLAP_ADD_FLOAT() {
static TFLMRegistration r =
tflite::micro::RegisterOp(
OverlapAddInit<float>,
OverlapAddPrepare<float, kTfLiteFloat32>,
OverlapAddEval<float>,
nullptr,
OverlapAddReset<float>);
static TFLMRegistration r = tflite::micro::RegisterOp(
OverlapAddInit<float>, OverlapAddPrepare<float, kTfLiteFloat32>,
OverlapAddEval<float>, nullptr, OverlapAddReset<float>);
return &r;
}

TFLMRegistration* Register_OVERLAP_ADD_INT16() {
static TFLMRegistration r =
tflite::micro::RegisterOp(
OverlapAddInit<int16_t>,
OverlapAddPrepare<int16_t, kTfLiteInt16>,
OverlapAddEval<int16_t>,
nullptr,
OverlapAddReset<int16_t>);
static TFLMRegistration r = tflite::micro::RegisterOp(
OverlapAddInit<int16_t>, OverlapAddPrepare<int16_t, kTfLiteInt16>,
OverlapAddEval<int16_t>, nullptr, OverlapAddReset<int16_t>);
return &r;
}
} // namespace tflm_signal
Expand Down
4 changes: 2 additions & 2 deletions signal/micro/kernels/pcan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ TfLiteStatus PcanEval(TfLiteContext* context, TfLiteNode* node) {
}

TFLMRegistration* Register_PCAN() {
static TFLMRegistration r = tflite::micro::RegisterOp(
PcanInit, PcanPrepare, PcanEval);
static TFLMRegistration r =
tflite::micro::RegisterOp(PcanInit, PcanPrepare, PcanEval);
return &r;
}

Expand Down
12 changes: 6 additions & 6 deletions signal/micro/kernels/rfft.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ void* RfftInitAll(TfLiteContext* context, const char* buffer, size_t length) {
switch (tensor_type) {
case TensorType_INT16: {
return RfftInit<int16_t, ::tflm_signal::RfftInt16GetNeededMemory,
::tflm_signal::RfftInt16Init>(context, buffer, length);
::tflm_signal::RfftInt16Init>(context, buffer, length);
}
case TensorType_INT32: {
return RfftInit<int32_t, ::tflm_signal::RfftInt32GetNeededMemory,
::tflm_signal::RfftInt32Init>(context, buffer, length);
::tflm_signal::RfftInt32Init>(context, buffer, length);
}
case TensorType_FLOAT32: {
return RfftInit<float, ::tflm_signal::RfftFloatGetNeededMemory,
::tflm_signal::RfftFloatInit>(context, buffer, length);
::tflm_signal::RfftFloatInit>(context, buffer, length);
}
default:
return nullptr;
Expand Down Expand Up @@ -209,7 +209,7 @@ TFLMRegistration* Register_RFFT() {
TFLMRegistration* Register_RFFT_FLOAT() {
static TFLMRegistration r = tflite::micro::RegisterOp(
RfftInit<float, ::tflm_signal::RfftFloatGetNeededMemory,
::tflm_signal::RfftFloatInit>,
::tflm_signal::RfftFloatInit>,
RfftPrepare<float, kTfLiteFloat32>,
RfftEval<float, ::tflm_signal::RfftFloatApply>);
return &r;
Expand All @@ -218,7 +218,7 @@ TFLMRegistration* Register_RFFT_FLOAT() {
TFLMRegistration* Register_RFFT_INT16() {
static TFLMRegistration r = tflite::micro::RegisterOp(
RfftInit<int16_t, ::tflm_signal::RfftInt16GetNeededMemory,
::tflm_signal::RfftInt16Init>,
::tflm_signal::RfftInt16Init>,
RfftPrepare<int16_t, kTfLiteInt16>,
RfftEval<int16_t, ::tflm_signal::RfftInt16Apply>);
return &r;
Expand All @@ -227,7 +227,7 @@ TFLMRegistration* Register_RFFT_INT16() {
TFLMRegistration* Register_RFFT_INT32() {
static TFLMRegistration r = tflite::micro::RegisterOp(
RfftInit<int32_t, ::tflm_signal::RfftInt32GetNeededMemory,
::tflm_signal::RfftInt32Init>,
::tflm_signal::RfftInt32Init>,
RfftPrepare<int32_t, kTfLiteInt32>,
RfftEval<int32_t, ::tflm_signal::RfftInt32Apply>);
return &r;
Expand Down
3 changes: 1 addition & 2 deletions signal/micro/kernels/stacker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ void StackerReset(TfLiteContext* context, void* buffer) {

namespace tflm_signal {
TFLMRegistration* Register_STACKER() {
static TFLMRegistration r =
tflite::micro::RegisterOp(
static TFLMRegistration r = tflite::micro::RegisterOp(
StackerInit, StackerPrepare, StackerEval, /*Free*/ nullptr, StackerReset);
return &r;
}
Expand Down
4 changes: 2 additions & 2 deletions signal/micro/kernels/window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ TfLiteStatus WindowEval(TfLiteContext* context, TfLiteNode* node) {
namespace tflm_signal {

TFLMRegistration* Register_WINDOW() {
static TFLMRegistration r = tflite::micro::RegisterOp(
WindowInit, WindowPrepare, WindowEval);
static TFLMRegistration r =
tflite::micro::RegisterOp(WindowInit, WindowPrepare, WindowEval);
return &r;
}

Expand Down

0 comments on commit b982bda

Please sign in to comment.