mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
Use INFO instead of WARNING for an unused graph input. (#1235)
* Use INFO instead of WARNING for an unused graph input. * Drop severity of unused initializer as well * Update to output a warning level message if removing an initializer that is never used, and an info level message if removing an initializer that optimization has made redundant.
This commit is contained in:
parent
fa4b956f12
commit
07a2466d9f
3 changed files with 19 additions and 3 deletions
|
|
@ -987,6 +987,9 @@ class Graph {
|
|||
// NodeArgs that come from outer scope. Used when building a graph so that
|
||||
// these don't get recorded as graph inputs in the GraphProto.
|
||||
std::unordered_set<std::string> outer_scope_node_arg_names_;
|
||||
|
||||
// number of times Resolve has run.
|
||||
int num_resolves_ = 0;
|
||||
};
|
||||
|
||||
} // namespace onnxruntime
|
||||
|
|
|
|||
|
|
@ -418,9 +418,10 @@ common::Status SaveInputOutputNamesToNodeMapping(const onnxruntime::Graph& graph
|
|||
for (const auto& graph_input : graph_inputs) {
|
||||
const auto& name = graph_input->Name();
|
||||
if (input_map.find(name) == end_map) {
|
||||
// dummy entry for an input that we didn't find a use of in the graph. warn about it in case that's a bug.
|
||||
// dummy entry for an input that we didn't find a use of in the graph. log it in case that's a bug.
|
||||
// utils::CopyOneInputAcrossDevices will use the input OrtValue as is given we don't believe it's used anywhere.
|
||||
LOGS(session_state.Logger(), WARNING) << "Graph input with name " << name << " is not associated with a node. ";
|
||||
LOGS(session_state.Logger(), INFO) << (graph.IsSubgraph() ? "Subgraph" : "Graph") << " input with name "
|
||||
<< name << " is not used by any node.";
|
||||
ORT_RETURN_IF_ERROR(session_state.AddInputNameToNodeInfoMapping(name, empty_node_info));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1330,6 +1330,7 @@ Status Graph::InferAndVerifySubgraphTypes(const Node& node, Graph& subgraph,
|
|||
" inputs and requires ", num_required_subgraph_inputs,
|
||||
" inputs. Either provide all subgraph inputs, or just the required inputs.");
|
||||
}
|
||||
|
||||
subgraph_inputs = &required_subgraph_inputs;
|
||||
num_subgraph_inputs = num_required_subgraph_inputs;
|
||||
}
|
||||
|
|
@ -1879,6 +1880,8 @@ Status Graph::Resolve(bool no_proto_sync_required) {
|
|||
|
||||
ORT_RETURN_IF_ERROR(ForThisAndAllSubgraphs(all_subgraphs, finalize_func));
|
||||
|
||||
++num_resolves_;
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
|
@ -2233,7 +2236,16 @@ void Graph::CleanUnusedInitializers() {
|
|||
for (const auto& pv : name_to_initial_tensor_) {
|
||||
const std::string& name = pv.first;
|
||||
if (used_args.find(name) == end) {
|
||||
LOGS_DEFAULT(WARNING) << name << " exists in this graph's initializers but it is not used by any node";
|
||||
// on the first call to Graph::Resolve we are removing unnecessary initializers that should be removed
|
||||
// from the model.
|
||||
// on later calls we are removing initializers that optimizations have made redundant.
|
||||
if (num_resolves_ == 0) {
|
||||
LOGS_DEFAULT(WARNING) << "Removing initializer '"
|
||||
<< name << "'. It is not used by any node and should be removed from the model.";
|
||||
} else {
|
||||
LOGS_DEFAULT(INFO) << "Removing initializer '" << name << "'. It is no longer used by any node.";
|
||||
}
|
||||
|
||||
erase_list.push_back(name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue