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

Function CreateOrCheckRnnStateArray

tensorflow/lite/toco/tooling_util.cc:1478–1507  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1476}
1477
1478void CreateOrCheckRnnStateArray(const string& name, int size,
1479 int state_num_dims, Model* model) {
1480 int batch = 1;
1481 int num_dims = -1;
1482 if (state_num_dims > 0) {
1483 num_dims = state_num_dims;
1484 } else {
1485 // state_num_dims is not given. We will infer it from an input tensor.
1486 for (const auto& input_array : model->flags.input_arrays()) {
1487 // Pick 'num_dims' and 'batch' from the first input_arrays, unless we find
1488 // a better match by name.
1489 if (input_array.name() == name || num_dims == -1) {
1490 num_dims = input_array.shape().dims_size();
1491 if (num_dims > 0) {
1492 batch = input_array.shape().dims(0);
1493 }
1494 }
1495 }
1496 }
1497 Array& array = model->GetOrCreateArray(name);
1498 if (array.has_shape()) {
1499 num_dims = array.shape().dimensions_count();
1500 }
1501 if (!array.has_shape() && num_dims >= 0) {
1502 Shape* shape = array.mutable_shape();
1503 std::vector<int> dims;
1504 MakeArrayDims(num_dims, batch, 1, 1, size, &dims);
1505 *shape->mutable_dims() = dims;
1506 }
1507}
1508
1509void ResolveModelFlags(const ModelFlags& model_flags, Model* model) {
1510 // Merge info about input_arrays from model_flags into model->flags

Callers 1

ResolveModelFlagsFunction · 0.85

Calls 8

MakeArrayDimsFunction · 0.85
has_shapeMethod · 0.80
dimensions_countMethod · 0.80
mutable_dimsMethod · 0.80
nameMethod · 0.65
shapeMethod · 0.45
dimsMethod · 0.45
mutable_shapeMethod · 0.45

Tested by

no test coverage detected