| 991 | } |
| 992 | |
| 993 | void 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 | |
| 1020 | void FixNoOrphanedArray(Model* model) { |
| 1021 | std::unordered_set<string> arrays_without_known_use; |
no test coverage detected