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

Function CheckNoOrphanedArray

tensorflow/lite/toco/tooling_util.cc:993–1018  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

991}
992
993void CheckNoOrphanedArray(const Model& model) {
994 std::unordered_set<string> arrays_without_known_use;
995 for (const auto& array : model.GetArrayMap()) {
996 if (IsDiscardableArray(model, array.first)) {
997 arrays_without_known_use.insert(array.first);
998 }
999 }
1000 for (const auto& op : model.operators) {
1001 for (const auto& input : op->inputs) {
1002 arrays_without_known_use.erase(input);
1003 }
1004 for (const auto& output : op->outputs) {
1005 arrays_without_known_use.erase(output);
1006 }
1007 }
1008 for (const auto& rnn_state : model.flags.rnn_states()) {
1009 arrays_without_known_use.erase(rnn_state.state_array());
1010 arrays_without_known_use.erase(rnn_state.back_edge_source_array());
1011 }
1012 if (!arrays_without_known_use.empty()) {
1013 for (const auto& array : arrays_without_known_use) {
1014 LOG(INFO) << "Error: Orphaned array: " << array;
1015 }
1016 }
1017 CHECK(arrays_without_known_use.empty());
1018}
1019
1020void FixNoOrphanedArray(Model* model) {
1021 std::unordered_set<string> arrays_without_known_use;

Callers 1

CheckInvariantsFunction · 0.85

Calls 4

IsDiscardableArrayFunction · 0.85
insertMethod · 0.45
eraseMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected