1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 #ifndef TENSORFLOW_LITE_MICRO_KERNELS_SVDF_H_
16 #define TENSORFLOW_LITE_MICRO_KERNELS_SVDF_H_
17 
18 #include "tensorflow/lite/c/builtin_op_data.h"
19 #include "tensorflow/lite/c/common.h"
20 
21 namespace tflite {
22 
23 struct OpData {
24   int32_t effective_scale_1_a;
25   int32_t effective_scale_2_a;
26   // b versions of each scale are kept at int since the numbers are just the
27   // shift value - typically between [-32, 32].
28   int effective_scale_1_b;
29   int effective_scale_2_b;
30   int scratch_tensor_index;
31   int scratch_output_tensor_index;
32 
33   // Cached tensor zero point values for quantized operations.
34   int input_zero_point;
35   int output_zero_point;
36 };
37 
38 // TensorflowLite Micro-specific reference implementation for Integer SVDF.
39 void EvalIntegerSvdfReference(TfLiteContext* context, TfLiteNode* node,
40                               const TfLiteEvalTensor* input_tensor,
41                               const TfLiteEvalTensor* weights_feature_tensor,
42                               const TfLiteEvalTensor* weights_time_tensor,
43                               const TfLiteEvalTensor* bias_tensor,
44                               const TfLiteSVDFParams* params,
45                               TfLiteEvalTensor* activation_state_tensor,
46                               TfLiteEvalTensor* output_tensor,
47                               const OpData& data);
48 
49 }  // namespace tflite
50 
51 #endif  // TENSORFLOW_LITE_MICRO_KERNELS_SVDF_H_
52