reduce.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. ==============================================================================*/
  12. #ifndef TENSORFLOW_LITE_MICRO_KERNELS_REDUCE_H_
  13. #define TENSORFLOW_LITE_MICRO_KERNELS_REDUCE_H_
  14. #include <cstdint>
  15. #include "tensorflow/lite/c/builtin_op_data.h"
  16. #include "tensorflow/lite/c/common.h"
  17. #include "tensorflow/lite/kernels/internal/types.h"
  18. namespace tflite {
  19. extern const int kMaxNumberOfAxis;
  20. extern const int kMaxNumberOfReducedAxis;
  21. struct OpDataReduce {
  22. int32_t multiplier;
  23. int shift;
  24. int temp_buffer_idx;
  25. int resolved_axis_idx;
  26. int input_zp;
  27. float input_scale;
  28. int output_zp;
  29. float output_scale;
  30. int num_output_elements;
  31. };
  32. TfLiteStatus PrepareMaxHelper(TfLiteContext* context, TfLiteNode* node,
  33. OpDataReduce* op_data);
  34. TfLiteStatus PrepareMeanOrSumHelper(TfLiteContext* context, TfLiteNode* node,
  35. OpDataReduce* op_data);
  36. TfLiteStatus EvalMaxHelper(TfLiteContext* context, TfLiteNode* node,
  37. OpDataReduce* op_data);
  38. TfLiteStatus EvalMeanHelper(TfLiteContext* context, TfLiteNode* node,
  39. OpDataReduce* op_data);
  40. void ReduceResolveAxis(const int* axis_data, int axis_count,
  41. MeanParams* op_params);
  42. TfLiteRegistration Register_MEAN();
  43. TfLiteRegistration Register_REDUCE_MAX();
  44. } // namespace tflite
  45. #endif // TENSORFLOW_LITE_MICRO_KERNELS_REDUCE_H_