mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
Improve AddValueInfo (#8451)
* change AddValueInfo * fix after merge master
This commit is contained in:
parent
b2b9de939f
commit
619a8782a5
7 changed files with 12 additions and 15 deletions
|
|
@ -719,7 +719,7 @@ class Graph {
|
|||
/** Gets the NodeArgs that represent value_info instances in the Graph.
|
||||
These are the values that are neither Graph inputs nor outputs.
|
||||
@remarks Contains no nullptr values. */
|
||||
const std::vector<const NodeArg*>& GetValueInfo() const noexcept { return value_info_; }
|
||||
const std::unordered_set<const NodeArg*>& GetValueInfo() const noexcept { return value_info_; }
|
||||
|
||||
#if !defined(ORT_MINIMAL_BUILD)
|
||||
void AddValueInfo(const NodeArg* new_value_info);
|
||||
|
|
@ -1408,7 +1408,7 @@ class Graph {
|
|||
bool graph_outputs_manually_set_ = false;
|
||||
|
||||
// Graph value_info.
|
||||
std::vector<const NodeArg*> value_info_;
|
||||
std::unordered_set<const NodeArg*> value_info_;
|
||||
|
||||
// All node args owned by <*this> graph. Key is node arg name.
|
||||
std::unordered_map<std::string, std::unique_ptr<NodeArg>> node_args_;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class GraphViewer {
|
|||
/** Gets all ValueInfo NodeArg instances in the Graph.
|
||||
@remarks NOT filtered using filter_info_.
|
||||
*/
|
||||
const std::vector<const NodeArg*>& GetValueInfo() const noexcept;
|
||||
const std::unordered_set<const NodeArg*>& GetValueInfo() const noexcept;
|
||||
|
||||
/**
|
||||
Gets the Node instance at the specified index.
|
||||
|
|
|
|||
|
|
@ -1198,7 +1198,7 @@ void Graph::InitializeStateFromModelFileGraphProto() {
|
|||
const auto& name = graph_value_info.name();
|
||||
const auto* node_arg = GetNodeArg(name);
|
||||
if (node_arg != nullptr) {
|
||||
value_info_.push_back(node_arg);
|
||||
value_info_.insert(node_arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2778,10 +2778,9 @@ const ONNX_NAMESPACE::TensorProto* Graph::GetConstantInitializer(const std::stri
|
|||
|
||||
#if !defined(ORT_MINIMAL_BUILD)
|
||||
void Graph::AddValueInfo(const NodeArg* new_value_info) {
|
||||
for (const auto* info : value_info_) {
|
||||
ORT_ENFORCE(info->Name() != new_value_info->Name(), "Error: trying to add an existing value info.");
|
||||
}
|
||||
value_info_.push_back(new_value_info);
|
||||
NodeArg* node_arg = GetNodeArg(new_value_info->Name());
|
||||
ORT_ENFORCE(node_arg && node_arg == new_value_info, "Error: trying to add an value info that are no in graph.");
|
||||
value_info_.insert(new_value_info);
|
||||
}
|
||||
|
||||
std::vector<NodeArg*> Graph::CreateNodeArgs(const google::protobuf::RepeatedPtrField<std::string>& names,
|
||||
|
|
@ -3417,9 +3416,7 @@ Status Graph::SetGraphInputsOutputs() {
|
|||
// Remove the output arg name from graph outputs since it's
|
||||
// the input of this node, which we call it intermediate result
|
||||
// and store it in <m_valueinfo>.
|
||||
if (std::find(value_info_.begin(), value_info_.end(), input_arg) == value_info_.end()) {
|
||||
value_info_.push_back(input_arg);
|
||||
}
|
||||
value_info_.insert(input_arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ const std::vector<const NodeArg*>& GraphViewer::GetOutputs() const noexcept {
|
|||
}
|
||||
|
||||
// Get graph value infos.
|
||||
const std::vector<const NodeArg*>& GraphViewer::GetValueInfo() const noexcept {
|
||||
const std::unordered_set<const NodeArg*>& GraphViewer::GetValueInfo() const noexcept {
|
||||
return graph_->GetValueInfo();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -591,7 +591,7 @@ struct ProviderHost {
|
|||
|
||||
virtual const std::vector<const NodeArg*>& GraphViewer__GetInputs(const GraphViewer* p) noexcept = 0;
|
||||
virtual const std::vector<const NodeArg*>& GraphViewer__GetOutputs(const GraphViewer* p) noexcept = 0;
|
||||
virtual const std::vector<const NodeArg*>& GraphViewer__GetValueInfo(const GraphViewer* p) noexcept = 0;
|
||||
virtual const std::unordered_set<const NodeArg*>& GraphViewer__GetValueInfo(const GraphViewer* p) noexcept = 0;
|
||||
|
||||
virtual const InitializedTensorSet& GraphViewer__GetAllInitializedTensors(const GraphViewer* p) = 0;
|
||||
virtual bool GraphViewer__GetInitializedTensor(const GraphViewer* p, const std::string& tensor_name, const ONNX_NAMESPACE::TensorProto*& value) = 0;
|
||||
|
|
|
|||
|
|
@ -644,7 +644,7 @@ struct GraphViewer final {
|
|||
|
||||
const std::vector<const NodeArg*>& GetInputs() const noexcept { return g_host->GraphViewer__GetInputs(this); }
|
||||
const std::vector<const NodeArg*>& GetOutputs() const noexcept { return g_host->GraphViewer__GetOutputs(this); }
|
||||
const std::vector<const NodeArg*>& GetValueInfo() const noexcept { return g_host->GraphViewer__GetValueInfo(this); }
|
||||
const std::unordered_set<const NodeArg*>& GetValueInfo() const noexcept { return g_host->GraphViewer__GetValueInfo(this); }
|
||||
|
||||
const InitializedTensorSet& GetAllInitializedTensors() const noexcept { return g_host->GraphViewer__GetAllInitializedTensors(this); }
|
||||
bool GetInitializedTensor(const std::string& tensor_name, const ONNX_NAMESPACE::TensorProto*& value) const { return g_host->GraphViewer__GetInitializedTensor(this, tensor_name, value); }
|
||||
|
|
|
|||
|
|
@ -673,7 +673,7 @@ struct ProviderHostImpl : ProviderHost {
|
|||
|
||||
const std::vector<const NodeArg*>& GraphViewer__GetInputs(const GraphViewer* p) noexcept override { return p->GetInputs(); }
|
||||
const std::vector<const NodeArg*>& GraphViewer__GetOutputs(const GraphViewer* p) noexcept override { return p->GetOutputs(); }
|
||||
const std::vector<const NodeArg*>& GraphViewer__GetValueInfo(const GraphViewer* p) noexcept override { return p->GetValueInfo(); }
|
||||
const std::unordered_set<const NodeArg*>& GraphViewer__GetValueInfo(const GraphViewer* p) noexcept override { return p->GetValueInfo(); }
|
||||
|
||||
const InitializedTensorSet& GraphViewer__GetAllInitializedTensors(const GraphViewer* p) override { return p->GetAllInitializedTensors(); }
|
||||
bool GraphViewer__GetInitializedTensor(const GraphViewer* p, const std::string& tensor_name, const ONNX_NAMESPACE::TensorProto*& value) override { return p->GetInitializedTensor(tensor_name, value); }
|
||||
|
|
|
|||
Loading…
Reference in a new issue