MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / LstmCell

Function LstmCell

tensorflow/lite/kernels/internal/reference/reference_ops.h:1350–1465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1348}
1349
1350inline void LstmCell(
1351 const LstmCellParams& params, const RuntimeShape& unextended_input_shape,
1352 const float* input_data, const RuntimeShape& unextended_prev_activ_shape,
1353 const float* prev_activ_data, const RuntimeShape& weights_shape,
1354 const float* weights_data, const RuntimeShape& unextended_bias_shape,
1355 const float* bias_data, const RuntimeShape& unextended_prev_state_shape,
1356 const float* prev_state_data,
1357 const RuntimeShape& unextended_output_state_shape, float* output_state_data,
1358 const RuntimeShape& unextended_output_activ_shape, float* output_activ_data,
1359 const RuntimeShape& unextended_concat_temp_shape, float* concat_temp_data,
1360 const RuntimeShape& unextended_activ_temp_shape, float* activ_temp_data) {
1361 TFLITE_DCHECK_LE(unextended_input_shape.DimensionsCount(), 4);
1362 TFLITE_DCHECK_LE(unextended_prev_activ_shape.DimensionsCount(), 4);
1363 TFLITE_DCHECK_LE(unextended_bias_shape.DimensionsCount(), 4);
1364 TFLITE_DCHECK_LE(unextended_prev_state_shape.DimensionsCount(), 4);
1365 TFLITE_DCHECK_LE(unextended_output_state_shape.DimensionsCount(), 4);
1366 TFLITE_DCHECK_LE(unextended_output_activ_shape.DimensionsCount(), 4);
1367 TFLITE_DCHECK_LE(unextended_concat_temp_shape.DimensionsCount(), 4);
1368 TFLITE_DCHECK_LE(unextended_activ_temp_shape.DimensionsCount(), 4);
1369 const RuntimeShape input_shape =
1370 RuntimeShape::ExtendedShape(4, unextended_input_shape);
1371 const RuntimeShape prev_activ_shape =
1372 RuntimeShape::ExtendedShape(4, unextended_prev_activ_shape);
1373 const RuntimeShape bias_shape =
1374 RuntimeShape::ExtendedShape(4, unextended_bias_shape);
1375 const RuntimeShape prev_state_shape =
1376 RuntimeShape::ExtendedShape(4, unextended_prev_state_shape);
1377 const RuntimeShape output_state_shape =
1378 RuntimeShape::ExtendedShape(4, unextended_output_state_shape);
1379 const RuntimeShape output_activ_shape =
1380 RuntimeShape::ExtendedShape(4, unextended_output_activ_shape);
1381 const RuntimeShape concat_temp_shape =
1382 RuntimeShape::ExtendedShape(4, unextended_concat_temp_shape);
1383 const RuntimeShape activ_temp_shape =
1384 RuntimeShape::ExtendedShape(4, unextended_activ_temp_shape);
1385 TFLITE_DCHECK_GE(weights_shape.DimensionsCount(), 2);
1386
1387 const int weights_dim_count = weights_shape.DimensionsCount();
1388 const int batches =
1389 MatchingDim(input_shape, 0, prev_activ_shape, 0, prev_state_shape, 0,
1390 output_state_shape, 0, output_activ_shape, 0);
1391 const int height =
1392 MatchingDim(input_shape, 1, prev_activ_shape, 1, prev_state_shape, 1,
1393 output_state_shape, 1, output_activ_shape, 1);
1394 const int width =
1395 MatchingDim(input_shape, 2, prev_activ_shape, 2, prev_state_shape, 2,
1396 output_state_shape, 2, output_activ_shape, 2);
1397 const int input_depth = input_shape.Dims(3);
1398 const int prev_activ_depth = prev_activ_shape.Dims(3);
1399 const int total_input_depth = prev_activ_depth + input_depth;
1400 TFLITE_DCHECK_EQ(weights_shape.Dims(weights_dim_count - 1),
1401 total_input_depth);
1402 TFLITE_DCHECK_EQ(FlatSizeSkipDim(bias_shape, 3), 1);
1403 const int intern_activ_depth =
1404 MatchingDim(weights_shape, weights_dim_count - 2, bias_shape, 3);
1405 TFLITE_DCHECK_EQ(weights_shape.FlatSize(),
1406 intern_activ_depth * total_input_depth);
1407 TFLITE_DCHECK_EQ(intern_activ_depth % 4, 0);

Callers

nothing calls this directly

Calls 15

MatchingDimFunction · 0.85
FlatSizeSkipDimFunction · 0.85
MatchingFlatSizeSkipDimFunction · 0.85
DimensionsCountMethod · 0.80
DimsMethod · 0.80
FlatSizeMethod · 0.80
ConcatenationFunction · 0.70
FullyConnectedFunction · 0.70
maxFunction · 0.50
expFunction · 0.50
OffsetFunction · 0.50
tanhFunction · 0.50

Tested by

no test coverage detected