• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2019 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_DELEGATES_NNAPI_QUANT_LSTM_SUP_H_
16 #define TENSORFLOW_LITE_DELEGATES_NNAPI_QUANT_LSTM_SUP_H_
17 
18 #include <vector>
19 
20 #include "tensorflow/lite/c/common.h"
21 
22 namespace tflite {
23 namespace delegate {
24 namespace nnapi {
25 
26 void ExtractQuantLstmWeightsSubmatrix(const TfLiteIntArray* submatrix_dims,
27                                       const int32_t offset_row,
28                                       const int32_t offset_column,
29                                       const TfLiteIntArray* weight_dims,
30                                       const uint8_t* weights,
31                                       std::vector<uint8_t>* submatrix);
32 
33 void DecomposeQuantLstmWeightsTensor(const uint8_t* concat_weights,
34                                      const TfLiteIntArray* weight_dims,
35                                      std::vector<uint8_t>* recurrent_to_input,
36                                      std::vector<uint8_t>* input_to_input,
37                                      std::vector<uint8_t>* recurrent_to_cell,
38                                      std::vector<uint8_t>* input_to_cell,
39                                      std::vector<uint8_t>* recurrent_to_forget,
40                                      std::vector<uint8_t>* input_to_forget,
41                                      std::vector<uint8_t>* recurrent_to_output,
42                                      std::vector<uint8_t>* input_to_output);
43 
44 void SetWeightSubmatrixDims(const TfLiteIntArray* weight_dims,
45                             TfLiteIntArray* recurrent_submatrix_dims,
46                             TfLiteIntArray* input_submatrix_dims);
47 
48 void DecomposeBiasTensor(const int32_t* biases, int bias_size,
49                          std::vector<int32_t>* input_bias,
50                          std::vector<int32_t>* cell_bias,
51                          std::vector<int32_t>* forget_bias,
52                          std::vector<int32_t>* output_bias);
53 
54 }  // namespace nnapi
55 }  // namespace delegate
56 }  // namespace tflite
57 
58 #endif  // TENSORFLOW_LITE_DELEGATES_NNAPI_QUANT_LSTM_SUP_H_
59