Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/tensorflow/lite/kernels/internal/reference/reduce.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,22 @@ inline bool QuantizedMeanOrSum(const T* input_data, int32_t input_zero_point,
return true;
}

template <typename T, typename U>
inline bool QuantizedMeanOrSumExtraArgs(
const T* input_data, int32_t input_zero_point, float input_scale,
const int* input_dims, const int input_num_dims, T* output_data,
float output_scale, int32_t output_multiplier, int output_shift,
int32_t output_zero_point, const int* output_dims,
const int output_num_dims, const int* axis, const int num_axis_dimensions,
bool keep_dims, int* temp_index, int* resolved_axis, U* temp_sum,
bool compute_sum) {
return QuantizedMeanOrSum<T, U>(
input_data, input_zero_point, input_scale, input_dims, input_num_dims,
output_data, output_zero_point, output_scale, output_dims,
output_num_dims, axis, num_axis_dimensions, keep_dims, temp_index,
resolved_axis, temp_sum, compute_sum);
}

template <typename T>
inline bool QuantizedReduceProd(const T* input_data, int32_t input_zero_point,
const RuntimeShape& input_shape, T* output_data,
Expand Down
4 changes: 2 additions & 2 deletions src/tensorflow/lite/micro/kernels/micro_ops.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -67,6 +67,7 @@ TfLiteRegistration Register_LOGICAL_OR();
TfLiteRegistration Register_LOGISTIC();
TfLiteRegistration Register_MAX_POOL_2D();
TfLiteRegistration Register_MIRROR_PAD();
TfLiteRegistration Register_NEG();
TfLiteRegistration Register_PRELU();
TfLiteRegistration Register_MUL();
TfLiteRegistration Register_PAD();
Expand Down Expand Up @@ -111,7 +112,6 @@ TfLiteRegistration Register_LOG();
TfLiteRegistration Register_LOGICAL_NOT();
TfLiteRegistration Register_MAXIMUM();
TfLiteRegistration Register_MINIMUM();
TfLiteRegistration Register_NEG();
TfLiteRegistration Register_NOT_EQUAL();
TfLiteRegistration Register_PACK();
TfLiteRegistration Register_RESHAPE();
Expand Down
13 changes: 5 additions & 8 deletions src/tensorflow/lite/micro/kernels/neg.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -21,9 +21,8 @@ limitations under the License.
#include "tensorflow/lite/micro/micro_log.h"

namespace tflite {
namespace ops {
namespace micro {
namespace neg {

namespace {

constexpr int kInputTensor = 0;
constexpr int kOutputTensor = 0;
Expand All @@ -49,12 +48,10 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
return kTfLiteOk;
}

} // namespace neg
} // namespace

TfLiteRegistration Register_NEG() {
return tflite::micro::RegisterOp(nullptr, nullptr, neg::Eval);
return tflite::micro::RegisterOp(nullptr, nullptr, Eval);
}

} // namespace micro
} // namespace ops
} // namespace tflite
7 changes: 4 additions & 3 deletions src/tensorflow/lite/micro/kernels/reduce_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,12 @@ TfLiteStatus QuantizedMeanOrSum(TfLiteContext* context, TfLiteNode* node,
TfLiteReducerParams* params =
static_cast<TfLiteReducerParams*>(node->builtin_data);

bool result = reference_ops::QuantizedMeanOrSum<T, int32_t>(
bool result = reference_ops::QuantizedMeanOrSumExtraArgs<T, int32_t>(
tflite::micro::GetTensorData<T>(input), op_data->input_zp,
op_data->input_scale, &input->dims->data[0], input->dims->size,
tflite::micro::GetTensorData<T>(output), op_data->output_zp,
op_data->output_scale, &output->dims->data[0], output->dims->size,
tflite::micro::GetTensorData<T>(output), op_data->output_scale,
op_data->multiplier, op_data->shift, op_data->output_zp,
&output->dims->data[0], output->dims->size,
tflite::micro::GetTensorData<int>(axis), op_data->num_axis,
params->keep_dims, temp_index, resolved_axis, temp_sum, compute_sum);
TF_LITE_ENSURE(context, result);
Expand Down
3 changes: 1 addition & 2 deletions src/tensorflow/lite/micro/micro_mutable_op_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,7 @@ class MicroMutableOpResolver : public MicroOpResolver {
}

TfLiteStatus AddNeg() {
return AddBuiltin(BuiltinOperator_NEG, tflite::ops::micro::Register_NEG(),
ParseNeg);
return AddBuiltin(BuiltinOperator_NEG, Register_NEG(), ParseNeg);
}

TfLiteStatus AddNotEqual() {
Expand Down