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

Function FixNoOrphanedArray

tensorflow/lite/toco/tooling_util.cc:1020–1042  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1018}
1019
1020void FixNoOrphanedArray(Model* model) {
1021 std::unordered_set<string> arrays_without_known_use;
1022 for (const auto& array : model->GetArrayMap()) {
1023 arrays_without_known_use.insert(array.first);
1024 }
1025 for (const auto& op : model->operators) {
1026 for (const auto& input : op->inputs) {
1027 arrays_without_known_use.erase(input);
1028 }
1029 for (const auto& output : op->outputs) {
1030 arrays_without_known_use.erase(output);
1031 }
1032 }
1033 for (const auto& rnn_state : model->flags.rnn_states()) {
1034 arrays_without_known_use.erase(rnn_state.state_array());
1035 arrays_without_known_use.erase(rnn_state.back_edge_source_array());
1036 }
1037 for (const auto& array : arrays_without_known_use) {
1038 if (IsDiscardableArray(*model, array)) {
1039 model->EraseArray(array);
1040 }
1041 }
1042}
1043
1044// Apply checks to arrays individually (for-each fashion).
1045//

Callers 1

ImportTensorFlowGraphDefFunction · 0.85

Calls 4

IsDiscardableArrayFunction · 0.85
EraseArrayMethod · 0.80
insertMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected