| 967 | } |
| 968 | |
| 969 | void FixNoMissingArray(Model* model) { |
| 970 | for (const auto& op : model->operators) { |
| 971 | for (const auto& input : op->inputs) { |
| 972 | if (!model->HasArray(input) && !model->IsOptionalArray(input)) { |
| 973 | model->GetOrCreateArray(input); |
| 974 | } |
| 975 | } |
| 976 | for (const auto& output : op->outputs) { |
| 977 | if (!model->HasArray(output) && !model->IsOptionalArray(output)) { |
| 978 | model->GetOrCreateArray(output); |
| 979 | } |
| 980 | } |
| 981 | } |
| 982 | if (model->flags.allow_nonexistent_arrays()) { |
| 983 | for (const string& output_array : model->flags.output_arrays()) { |
| 984 | model->GetOrCreateArray(output_array); |
| 985 | } |
| 986 | for (const auto& rnn_state : model->flags.rnn_states()) { |
| 987 | model->GetOrCreateArray(rnn_state.state_array()); |
| 988 | model->GetOrCreateArray(rnn_state.back_edge_source_array()); |
| 989 | } |
| 990 | } |
| 991 | } |
| 992 | |
| 993 | void CheckNoOrphanedArray(const Model& model) { |
| 994 | std::unordered_set<string> arrays_without_known_use; |
no test coverage detected