mul.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_MUL_H_
  13. #define TENSORFLOW_LITE_MICRO_KERNELS_MUL_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 kMulInput1Tensor;
  19. extern const int kMulInput2Tensor;
  20. extern const int kMulOutputTensor;
  21. struct OpDataMul {
  22. int32_t input1_zero_point;
  23. int32_t input2_zero_point;
  24. int32_t output_activation_min;
  25. int32_t output_activation_max;
  26. int32_t output_zero_point;
  27. int32_t output_multiplier;
  28. int output_shift;
  29. float output_activation_min_f32;
  30. float output_activation_max_f32;
  31. };
  32. void* MulInit(TfLiteContext* context, const char* buffer, size_t length);
  33. TfLiteStatus CalculateOpDataMul(TfLiteContext* context, TfLiteNode* node,
  34. TfLiteMulParams* params, OpDataMul* data);
  35. TfLiteStatus MulPrepare(TfLiteContext* context, TfLiteNode* node);
  36. void EvalMulQuantizedReference(TfLiteContext* context, TfLiteNode* node,
  37. const OpDataMul* data,
  38. const TfLiteEvalTensor* input1,
  39. const TfLiteEvalTensor* input2,
  40. TfLiteEvalTensor* output);
  41. void EvalMulFloatReference(TfLiteContext* context, TfLiteNode* node,
  42. TfLiteMulParams* params, const OpDataMul* data,
  43. const TfLiteEvalTensor* input1,
  44. const TfLiteEvalTensor* input2,
  45. TfLiteEvalTensor* output);
  46. } // namespace tflite
  47. #endif // TENSORFLOW_LITE_MICRO_KERNELS_MUL_H_