ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci_interpreter::lstm::LSTMStruct Struct Reference

#include <UnidirectionalSequenceLSTM.h>

Public Member Functions

 LSTMStruct ()=delete
 
 LSTMStruct (const LSTMStruct &)=delete
 
 LSTMStruct (const circle::Operator *cur_op, luci_interpreter::BaseRuntimeGraph *runtime_graph)
 
void validateTensorTypes ()
 
const circle::Tensor * input ()
 
const circle::Tensor * input_to_input_weights ()
 
const circle::Tensor * input_to_forget_weights ()
 
const circle::Tensor * input_to_cell_weights ()
 
const circle::Tensor * input_to_output_weights ()
 
const circle::Tensor * recurrent_to_input_weights ()
 
const circle::Tensor * recurrent_to_forget_weights ()
 
const circle::Tensor * recurrent_to_cell_weights ()
 
const circle::Tensor * recurrent_to_output_weights ()
 
const circle::Tensor * cell_to_input_weights ()
 
const circle::Tensor * cell_to_forget_weights ()
 
const circle::Tensor * cell_to_output_weights ()
 
const circle::Tensor * input_gate_bias ()
 
const circle::Tensor * forget_gate_bias ()
 
const circle::Tensor * cell_gate_bias ()
 
const circle::Tensor * output_gate_bias ()
 
const circle::Tensor * projection_weights ()
 
const circle::Tensor * projection_bias ()
 
const circle::Tensor * output_state ()
 
const circle::Tensor * cell_state ()
 
const circle::Tensor * input_layer_norm_coefficients ()
 
const circle::Tensor * forget_layer_norm_coefficients ()
 
const circle::Tensor * cell_layer_norm_coefficients ()
 
const circle::Tensor * output_layer_norm_coefficients ()
 
const circle::Tensor * output ()
 
const circle::Tensor * get_internal_tensor (int i)
 

Data Fields

const circle::UnidirectionalSequenceLSTMOptions * options
 

Detailed Description

Definition at line 27 of file UnidirectionalSequenceLSTM.h.

Constructor & Destructor Documentation

◆ LSTMStruct() [1/3]

luci_interpreter::lstm::LSTMStruct::LSTMStruct ( )
delete

◆ LSTMStruct() [2/3]

luci_interpreter::lstm::LSTMStruct::LSTMStruct ( const LSTMStruct )
delete

◆ LSTMStruct() [3/3]

luci_interpreter::lstm::LSTMStruct::LSTMStruct ( const circle::Operator *  cur_op,
luci_interpreter::BaseRuntimeGraph runtime_graph 
)
inlineexplicit

Definition at line 32 of file UnidirectionalSequenceLSTM.h.

34 {
35 const auto input_index = cur_op->inputs()->operator[](0);
36 const auto input_to_input_weights_index = cur_op->inputs()->operator[](1);
37 const auto input_to_forget_weights_index = cur_op->inputs()->operator[](2);
38 const auto input_to_cell_weights_index = cur_op->inputs()->operator[](3);
39 const auto input_to_output_weights_index = cur_op->inputs()->operator[](4);
40 assert(input_index != -1);
41 // input_to_input_weights_index - optional
42 assert(input_to_forget_weights_index != -1);
43 assert(input_to_cell_weights_index != -1);
44 assert(input_to_output_weights_index != -1);
45 internal_tensors[0] = runtime_graph->getCircleTensorByIndex(input_index);
46 internal_tensors[1] = runtime_graph->getCircleTensorByIndex(input_to_input_weights_index);
47 internal_tensors[2] = runtime_graph->getCircleTensorByIndex(input_to_forget_weights_index);
48 internal_tensors[3] = runtime_graph->getCircleTensorByIndex(input_to_cell_weights_index);
49 internal_tensors[4] = runtime_graph->getCircleTensorByIndex(input_to_output_weights_index);
50
51 const auto recurrent_to_input_weights_index = cur_op->inputs()->operator[](5);
52 const auto recurrent_to_forget_weights_index = cur_op->inputs()->operator[](6);
53 const auto recurrent_to_cell_weights_index = cur_op->inputs()->operator[](7);
54 const auto recurrent_to_output_weights_index = cur_op->inputs()->operator[](8);
55 // recurrent_to_input_weights_index - optional
56 assert(recurrent_to_forget_weights_index != -1);
57 assert(recurrent_to_cell_weights_index != -1);
58 assert(recurrent_to_output_weights_index != -1);
59 internal_tensors[5] = runtime_graph->getCircleTensorByIndex(recurrent_to_input_weights_index);
60 internal_tensors[6] = runtime_graph->getCircleTensorByIndex(recurrent_to_forget_weights_index);
61 internal_tensors[7] = runtime_graph->getCircleTensorByIndex(recurrent_to_cell_weights_index);
62 internal_tensors[8] = runtime_graph->getCircleTensorByIndex(recurrent_to_output_weights_index);
63
64 const auto cell_to_input_weights_index = cur_op->inputs()->operator[](9);
65 const auto cell_to_forget_weights_index = cur_op->inputs()->operator[](10);
66 const auto cell_to_output_weights_index = cur_op->inputs()->operator[](11);
67 // optional cell_to_input_weights_index
68 // optional cell_to_forget_weights_index
69 // optional cell_to_output_weights_index
70 internal_tensors[9] = runtime_graph->getCircleTensorByIndex(cell_to_input_weights_index);
71 internal_tensors[10] = runtime_graph->getCircleTensorByIndex(cell_to_forget_weights_index);
72 internal_tensors[11] = runtime_graph->getCircleTensorByIndex(cell_to_output_weights_index);
73
74 const auto input_gate_bias_index = cur_op->inputs()->operator[](12);
75 const auto forget_gate_bias_index = cur_op->inputs()->operator[](13);
76 const auto cell_gate_bias_index = cur_op->inputs()->operator[](14);
77 const auto output_gate_bias_index = cur_op->inputs()->operator[](15);
78 // optional input_gate_bias_index
79 assert(forget_gate_bias_index != -1);
80 assert(cell_gate_bias_index != -1);
81 assert(output_gate_bias_index != -1);
82 internal_tensors[12] = runtime_graph->getCircleTensorByIndex(input_gate_bias_index);
83 internal_tensors[13] = runtime_graph->getCircleTensorByIndex(forget_gate_bias_index);
84 internal_tensors[14] = runtime_graph->getCircleTensorByIndex(cell_gate_bias_index);
85 internal_tensors[15] = runtime_graph->getCircleTensorByIndex(output_gate_bias_index);
86
87 const auto projection_weights_index = cur_op->inputs()->operator[](16);
88 const auto projection_bias_index = cur_op->inputs()->operator[](17);
89 // optional projection_weights_index
90 // optional projection_bias_index
91 internal_tensors[16] = runtime_graph->getCircleTensorByIndex(projection_weights_index);
92 internal_tensors[17] = runtime_graph->getCircleTensorByIndex(projection_bias_index);
93
94 const auto output_state_index = cur_op->inputs()->operator[](18);
95 const auto cell_state_index = cur_op->inputs()->operator[](19);
96 assert(output_state_index != -1);
97 assert(cell_state_index != -1);
98 internal_tensors[18] = runtime_graph->getCircleTensorByIndex(output_state_index);
99 internal_tensors[19] = runtime_graph->getCircleTensorByIndex(cell_state_index);
100
101 const auto input_layer_norm_coefficients_index = cur_op->inputs()->operator[](20);
102 const auto forget_layer_norm_coefficients_index = cur_op->inputs()->operator[](21);
103 const auto cell_layer_norm_coefficients_index = cur_op->inputs()->operator[](22);
104 const auto output_layer_norm_coefficients_index = cur_op->inputs()->operator[](23);
105 // optional input_layer_norm_coefficients_index
106 // optional forget_layer_norm_coefficients_index
107 // optional cell_layer_norm_coefficients_index
108 // optional output_layer_norm_coefficients_index
109 internal_tensors[20] =
110 runtime_graph->getCircleTensorByIndex(input_layer_norm_coefficients_index);
111 internal_tensors[21] =
112 runtime_graph->getCircleTensorByIndex(forget_layer_norm_coefficients_index);
113 internal_tensors[22] =
114 runtime_graph->getCircleTensorByIndex(cell_layer_norm_coefficients_index);
115 internal_tensors[23] =
116 runtime_graph->getCircleTensorByIndex(output_layer_norm_coefficients_index);
117
118 const auto output_index = cur_op->outputs()->operator[](0);
119 assert(output_index != -1);
120 output_internal = runtime_graph->getCircleTensorByIndex(output_index);
121
122 options = cur_op->builtin_options_as_UnidirectionalSequenceLSTMOptions();
123 }
const circle::Tensor * getCircleTensorByIndex(int32_t index)
const circle::UnidirectionalSequenceLSTMOptions * options

References luci_interpreter::RuntimeGraph::getCircleTensorByIndex(), and options.

Member Function Documentation

◆ cell_gate_bias()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::cell_gate_bias ( )
inline

Definition at line 163 of file UnidirectionalSequenceLSTM.h.

163{ return internal_tensors[14]; };

Referenced by luci_interpreter_pal::lstm_internal::lstmStep().

◆ cell_layer_norm_coefficients()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::cell_layer_norm_coefficients ( )
inline

Definition at line 174 of file UnidirectionalSequenceLSTM.h.

174{ return internal_tensors[22]; };

◆ cell_state()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::cell_state ( )
inline

Definition at line 170 of file UnidirectionalSequenceLSTM.h.

170{ return internal_tensors[19]; };

◆ cell_to_forget_weights()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::cell_to_forget_weights ( )
inline

Definition at line 158 of file UnidirectionalSequenceLSTM.h.

158{ return internal_tensors[10]; };

◆ cell_to_input_weights()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::cell_to_input_weights ( )
inline

Definition at line 157 of file UnidirectionalSequenceLSTM.h.

157{ return internal_tensors[9]; };

◆ cell_to_output_weights()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::cell_to_output_weights ( )
inline

Definition at line 159 of file UnidirectionalSequenceLSTM.h.

159{ return internal_tensors[11]; };

◆ forget_gate_bias()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::forget_gate_bias ( )
inline

Definition at line 162 of file UnidirectionalSequenceLSTM.h.

162{ return internal_tensors[13]; };

Referenced by luci_interpreter_pal::lstm_internal::lstmStep(), and validateTensorTypes().

◆ forget_layer_norm_coefficients()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::forget_layer_norm_coefficients ( )
inline

Definition at line 173 of file UnidirectionalSequenceLSTM.h.

173{ return internal_tensors[21]; };

◆ get_internal_tensor()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::get_internal_tensor ( int  i)
inline

Definition at line 180 of file UnidirectionalSequenceLSTM.h.

180{ return internal_tensors[i]; }

Referenced by luci_interpreter::configure_kernel_CircleUnidirectionalSequenceLSTM().

◆ input()

◆ input_gate_bias()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::input_gate_bias ( )
inline

Definition at line 161 of file UnidirectionalSequenceLSTM.h.

161{ return internal_tensors[12]; };

Referenced by luci_interpreter_pal::lstm_internal::lstmStep().

◆ input_layer_norm_coefficients()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::input_layer_norm_coefficients ( )
inline

Definition at line 172 of file UnidirectionalSequenceLSTM.h.

172{ return internal_tensors[20]; };

◆ input_to_cell_weights()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::input_to_cell_weights ( )
inline

Definition at line 149 of file UnidirectionalSequenceLSTM.h.

149{ return internal_tensors[3]; };

Referenced by luci_interpreter_pal::lstm_internal::lstmStep().

◆ input_to_forget_weights()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::input_to_forget_weights ( )
inline

Definition at line 148 of file UnidirectionalSequenceLSTM.h.

148{ return internal_tensors[2]; };

Referenced by luci_interpreter_pal::lstm_internal::lstmStep(), and validateTensorTypes().

◆ input_to_input_weights()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::input_to_input_weights ( )
inline

Definition at line 147 of file UnidirectionalSequenceLSTM.h.

147{ return internal_tensors[1]; };

Referenced by luci_interpreter_pal::lstm_internal::lstmStep().

◆ input_to_output_weights()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::input_to_output_weights ( )
inline

Definition at line 150 of file UnidirectionalSequenceLSTM.h.

150{ return internal_tensors[4]; };

Referenced by luci_interpreter_pal::lstm_internal::lstmStep().

◆ output()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::output ( )
inline

Definition at line 176 of file UnidirectionalSequenceLSTM.h.

176{ return output_internal; };

Referenced by luci_interpreter_pal::lstm_internal::lstmStep(), and validateTensorTypes().

◆ output_gate_bias()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::output_gate_bias ( )
inline

Definition at line 164 of file UnidirectionalSequenceLSTM.h.

164{ return internal_tensors[15]; };

Referenced by luci_interpreter_pal::lstm_internal::lstmStep().

◆ output_layer_norm_coefficients()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::output_layer_norm_coefficients ( )
inline

Definition at line 175 of file UnidirectionalSequenceLSTM.h.

175{ return internal_tensors[23]; };

◆ output_state()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::output_state ( )
inline

◆ projection_bias()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::projection_bias ( )
inline

Definition at line 167 of file UnidirectionalSequenceLSTM.h.

167{ return internal_tensors[17]; };

◆ projection_weights()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::projection_weights ( )
inline

Definition at line 166 of file UnidirectionalSequenceLSTM.h.

166{ return internal_tensors[16]; };

◆ recurrent_to_cell_weights()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::recurrent_to_cell_weights ( )
inline

Definition at line 154 of file UnidirectionalSequenceLSTM.h.

154{ return internal_tensors[7]; };

Referenced by luci_interpreter_pal::lstm_internal::lstmStep().

◆ recurrent_to_forget_weights()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::recurrent_to_forget_weights ( )
inline

Definition at line 153 of file UnidirectionalSequenceLSTM.h.

153{ return internal_tensors[6]; };

Referenced by luci_interpreter_pal::lstm_internal::lstmStep().

◆ recurrent_to_input_weights()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::recurrent_to_input_weights ( )
inline

Definition at line 152 of file UnidirectionalSequenceLSTM.h.

152{ return internal_tensors[5]; };

Referenced by luci_interpreter_pal::lstm_internal::lstmStep().

◆ recurrent_to_output_weights()

const circle::Tensor * luci_interpreter::lstm::LSTMStruct::recurrent_to_output_weights ( )
inline

Definition at line 155 of file UnidirectionalSequenceLSTM.h.

155{ return internal_tensors[8]; };

Referenced by luci_interpreter_pal::lstm_internal::lstmStep().

◆ validateTensorTypes()

void luci_interpreter::lstm::LSTMStruct::validateTensorTypes ( )
inline

Definition at line 125 of file UnidirectionalSequenceLSTM.h.

126 {
127 LUCI_INTERPRETER_CHECK(Tensor::element_type(input()) == Tensor::element_type(output_state()));
128 LUCI_INTERPRETER_CHECK(Tensor::element_type(output()) == Tensor::element_type(input()));
129
130 for (int32_t i = 1; i < 9; ++i)
131 {
132 LUCI_INTERPRETER_CHECK(internal_tensors[i] == nullptr or
133 Tensor::element_type(input_to_forget_weights()) ==
134 Tensor::element_type(internal_tensors[i]));
135 }
136
137 for (int32_t i = 12; i < 16; ++i)
138 {
139 LUCI_INTERPRETER_CHECK(internal_tensors[i] == nullptr or
140 Tensor::element_type(forget_gate_bias()) ==
141 Tensor::element_type(internal_tensors[i]));
142 }
143 }
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36

References forget_gate_bias(), input(), input_to_forget_weights(), LUCI_INTERPRETER_CHECK, output(), and output_state().

Referenced by luci_interpreter::configure_kernel_CircleUnidirectionalSequenceLSTM().

Field Documentation

◆ options

const circle::UnidirectionalSequenceLSTMOptions* luci_interpreter::lstm::LSTMStruct::options

The documentation for this struct was generated from the following file: