1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_PACKAGES_MODULES_NEURALNETWORKS_COMMON_TYPES_OPERATIONS_UNIDIRECTIONAL_SEQUENCE_LSTM_H 18 #define ANDROID_PACKAGES_MODULES_NEURALNETWORKS_COMMON_TYPES_OPERATIONS_UNIDIRECTIONAL_SEQUENCE_LSTM_H 19 20 #include "OperationsValidationUtils.h" 21 22 namespace android::nn::unidirectional_sequence_lstm { 23 24 // Inputs 25 constexpr uint32_t kNumInputs = 28; 26 27 // Input tensor of size {max_time, n_batch, n_input} 28 constexpr uint32_t kInputTensor = 0; 29 30 // Input weight tensors of size: {n_cell, n_input} 31 constexpr uint32_t kInputToInputWeightsTensor = 1; // Optional 32 constexpr uint32_t kInputToForgetWeightsTensor = 2; 33 constexpr uint32_t kInputToCellWeightsTensor = 3; 34 constexpr uint32_t kInputToOutputWeightsTensor = 4; 35 36 // Recurrent weight tensors of size {n_cell, n_output} 37 constexpr uint32_t kRecurrentToInputWeightsTensor = 5; // Optional 38 constexpr uint32_t kRecurrentToForgetWeightsTensor = 6; 39 constexpr uint32_t kRecurrentToCellWeightsTensor = 7; 40 constexpr uint32_t kRecurrentToOutputWeightsTensor = 8; 41 42 // Peephole weights tensors of size {n_cell}, representing a diagonal matrix. 43 constexpr uint32_t kCellToInputWeightsTensor = 9; // Optional 44 constexpr uint32_t kCellToForgetWeightsTensor = 10; // Optional 45 constexpr uint32_t kCellToOutputWeightsTensor = 11; // Optional 46 47 // Gates bias tensors of size {n_cell} 48 constexpr uint32_t kInputGateBiasTensor = 12; // Optional 49 constexpr uint32_t kForgetGateBiasTensor = 13; 50 constexpr uint32_t kCellGateBiasTensor = 14; 51 constexpr uint32_t kOutputGateBiasTensor = 15; 52 53 // Projection weight tensor of size {n_output, n_cell} 54 constexpr uint32_t kProjectionWeightsTensor = 16; // Optional 55 // Projection bias tensor of size {n_output} 56 constexpr uint32_t kProjectionBiasTensor = 17; // Optional 57 58 // Input from the output of the previous step, tensor of size {batch_size, n_output} 59 constexpr uint32_t kOutputStateInTensor = 18; 60 // Input from the cell state of the previous step, tensor of size {batch_size, n_cell} 61 constexpr uint32_t kCellStateInTensor = 19; 62 63 constexpr uint32_t kActivationParam = 20; 64 constexpr uint32_t kCellClipParam = 21; 65 constexpr uint32_t kProjClipParam = 22; 66 constexpr uint32_t kTimeMajorParam = 23; 67 68 // Layer norm weights tensors of size {n_cell}, representing a diagonal matrix. 69 constexpr uint32_t kInputLayerNormWeightsTensor = 24; // Optional 70 constexpr uint32_t kForgetLayerNormWeightsTensor = 25; // Optional 71 constexpr uint32_t kCellLayerNormWeightsTensor = 26; // Optional 72 constexpr uint32_t kOutputLayerNormWeightsTensor = 27; // Optional 73 74 // Output tensors. 75 constexpr uint32_t kNumOutputs = 1; 76 constexpr uint32_t kNumOutputsWithState = 3; 77 78 constexpr uint32_t kOutputTensor = 0; 79 constexpr uint32_t kOutputStateOutTensor = 1; 80 constexpr uint32_t kCellStateOutTensor = 2; 81 82 } // namespace android::nn::unidirectional_sequence_lstm 83 84 #endif // ANDROID_PACKAGES_MODULES_NEURALNETWORKS_COMMON_TYPES_OPERATIONS_UNIDIRECTIONAL_SEQUENCE_LSTM_H 85