pooling.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Copyright 2021 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_POOLING_H_
  13. #define TENSORFLOW_LITE_MICRO_KERNELS_POOLING_H_
  14. #include <cstdint>
  15. #include "tensorflow/lite/c/builtin_op_data.h"
  16. #include "tensorflow/lite/c/common.h"
  17. namespace tflite {
  18. extern const int kPoolingInputTensor;
  19. extern const int kPoolingOutputTensor;
  20. struct OpDataPooling {
  21. TfLitePaddingValues padding;
  22. int32_t activation_min;
  23. int32_t activation_max;
  24. float activation_min_f32;
  25. float activation_max_f32;
  26. };
  27. TfLiteStatus CalculateOpDataPooling(const TfLiteContext* context,
  28. const TfLitePoolParams* params,
  29. const TfLiteTensor* input,
  30. const TfLiteTensor* output,
  31. OpDataPooling* data);
  32. TfLiteStatus PoolingPrepare(TfLiteContext* context, TfLiteNode* node);
  33. void AveragePoolingEvalFloat(const TfLiteContext* context,
  34. const TfLiteNode* node,
  35. const TfLitePoolParams* params,
  36. const OpDataPooling* data,
  37. const TfLiteEvalTensor* input,
  38. TfLiteEvalTensor* output);
  39. void AveragePoolingEvalQuantized(TfLiteContext* context, const TfLiteNode* node,
  40. const TfLitePoolParams* params,
  41. const OpDataPooling* data,
  42. const TfLiteEvalTensor* input,
  43. TfLiteEvalTensor* output);
  44. void MaxPoolingEvalFloat(TfLiteContext* context, TfLiteNode* node,
  45. TfLitePoolParams* params, const OpDataPooling* data,
  46. const TfLiteEvalTensor* input,
  47. TfLiteEvalTensor* output);
  48. void MaxPoolingEvalQuantized(TfLiteContext* context, TfLiteNode* node,
  49. TfLitePoolParams* params,
  50. const OpDataPooling* data,
  51. const TfLiteEvalTensor* input,
  52. TfLiteEvalTensor* output);
  53. } // namespace tflite
  54. #endif // TENSORFLOW_LITE_MICRO_KERNELS_POOLING_H_