1/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15#ifndef TENSORFLOW_LITE_KERNELS_LSTM_SHARED_H_
16#define TENSORFLOW_LITE_KERNELS_LSTM_SHARED_H_
17
18namespace tflite {
19namespace ops {
20namespace builtin {
21namespace lstm {
22// For full inputs kernel (24-inputs).
23// Please note the 20-input full kernel is deprecated and only kept
24// here for backward compatibility.
25namespace full {
26
27// Input Tensors of size {n_batch, n_input}
28constexpr int kInputTensor = 0;
29
30// Input weight tensors of size: {n_cell, n_input}
31constexpr int kInputToInputWeightsTensor = 1; // Optional
32constexpr int kInputToForgetWeightsTensor = 2;
33constexpr int kInputToCellWeightsTensor = 3;
34constexpr int kInputToOutputWeightsTensor = 4;
35
36// Recurrent weight tensors of size {n_cell, n_output}
37constexpr int kRecurrentToInputWeightsTensor = 5; // Optional
38constexpr int kRecurrentToForgetWeightsTensor = 6;
39constexpr int kRecurrentToCellWeightsTensor = 7;
40constexpr int kRecurrentToOutputWeightsTensor = 8;
41
42// Peephole weights tensors of size {n_cell}, representing a diagonal matrix.
43constexpr int kCellToInputWeightsTensor = 9; // Optional
44constexpr int kCellToForgetWeightsTensor = 10; // Optional
45constexpr int kCellToOutputWeightsTensor = 11; // Optional
46
47// Gates bias tensors of size {n_cell}
48constexpr int kInputGateBiasTensor = 12; // Optional
49constexpr int kForgetGateBiasTensor = 13;
50constexpr int kCellGateBiasTensor = 14;
51constexpr int kOutputGateBiasTensor = 15;
52
53// Projection weight tensor of size {n_output, n_cell}
54constexpr int kProjectionWeightsTensor = 16; // Optional
55// Projection bias tensor of size {n_output}
56constexpr int kProjectionBiasTensor = 17; // Optional
57
58// These state tensors are defined as variable tensors, and will be modified by
59// this op.
60constexpr int kOutputStateTensor = 18;
61constexpr int kCellStateTensor = 19;
62
63// Layer norm coefficient tensors of size {n_cell}, representing a diagonal
64// matrix.
65constexpr int kInputLayerNormCoefficientsTensor = 20; // Optional
66constexpr int kForgetLayerNormCoefficientsTensor = 21; // Optional
67constexpr int kCellLayerNormCoefficientsTensor = 22; // Optional
68constexpr int kOutputLayerNormCoefficientsTensor = 23; // Optional
69
70// Output tensors.
71constexpr int kOutputTensor = 0;
72} // namespace full
73
74} // namespace lstm
75} // namespace builtin
76} // namespace ops
77} // namespace tflite
78#endif // TENSORFLOW_LITE_KERNELS_LSTM_SHARED_H_
79