ONE - On-device Neural Engine
Loading...
Searching...
No Matches
UnidirectionalSequenceLSTM.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved
3 * Copyright 2017 The TensorFlow Authors. All Rights Reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef LUCI_INTERPRETER_KERNELS_UNIDIRECTIONALSEQUENCELSTM_H
19#define LUCI_INTERPRETER_KERNELS_UNIDIRECTIONALSEQUENCELSTM_H
20
21#include "core/Kernel.h"
22#include "core/KernelParams.h"
23
24namespace luci_interpreter
25{
26namespace kernels
27{
28
29class UnidirectionalSequenceLSTM : public KernelWithParams<UnidirectionalSequenceLSTMParams>
30{
31public:
33 const Tensor *input,
34
37
40
43
46
48
49 const Tensor *output_state, const Tensor *cell_state,
50
53
54 Tensor *output, Tensor *scratchpad_1, Tensor *scratchpad_2, Tensor *scratchpad_3,
56
57 const Tensor *input() const { return _inputs[0]; }
58
59 const Tensor *input_to_input_weights() const { return _inputs[1]; }
60 const Tensor *input_to_forget_weights() const { return _inputs[2]; }
61 const Tensor *input_to_cell_weights() const { return _inputs[3]; }
62 const Tensor *input_to_output_weights() const { return _inputs[4]; }
63
64 const Tensor *recurrent_to_input_weights() const { return _inputs[5]; }
65 const Tensor *recurrent_to_forget_weights() const { return _inputs[6]; }
66 const Tensor *recurrent_to_cell_weights() const { return _inputs[7]; }
67 const Tensor *recurrent_to_output_weights() const { return _inputs[8]; }
68
69 const Tensor *cell_to_input_weights() const { return _inputs[9]; }
70 const Tensor *cell_to_forget_weights() const { return _inputs[10]; }
71 const Tensor *cell_to_output_weights() const { return _inputs[11]; }
72
73 const Tensor *input_gate_bias() const { return _inputs[12]; }
74 const Tensor *forget_gate_bias() const { return _inputs[13]; }
75 const Tensor *cell_gate_bias() const { return _inputs[14]; }
76 const Tensor *output_gate_bias() const { return _inputs[15]; }
77
78 const Tensor *projection_weights() const { return _inputs[16]; }
79 const Tensor *projection_bias() const { return _inputs[17]; }
80
81 const Tensor *output_state() const { return _inputs[18]; }
82 const Tensor *cell_state() const { return _inputs[19]; }
83
84 const Tensor *input_layer_norm_coefficients() const { return _inputs[20]; }
85 const Tensor *forget_layer_norm_coefficients() const { return _inputs[21]; }
86 const Tensor *cell_layer_norm_coefficients() const { return _inputs[22]; }
87 const Tensor *output_layer_norm_coefficients() const { return _inputs[23]; }
88
89 Tensor *output() const { return _outputs[0]; }
90
91 void configure() override;
92 void execute() const override;
93
94private:
95 void evalFloat() const;
96
97private:
98 void check_input_tensor_dimensions(int n_input, int n_output, int n_cell, bool use_layer_norm,
99 bool is_integer);
100};
101
102} // namespace kernels
103} // namespace luci_interpreter
104
105#endif // LUCI_INTERPRETER_KERNELS_UNIDIRECTIONALSEQUENCELSTM_H
const std::vector< const Tensor * > _inputs
Definition Kernel.h:52
const std::vector< Tensor * > _outputs
Definition Kernel.h:53
const UnidirectionalSequenceLSTMParams & params() const
Definition Kernel.h:67