Skip to content

Commit 2cbf740

Browse files
RyanUnderhillhouseroad
authored andcommitted
Domain exists in GraphProto but not in Node (onnx#1310)
* Domain needs to be copied in graph nodes * Initialize has_domain_
1 parent 9b874e9 commit 2cbf740

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Diff for: onnx/common/ir.h

+13
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ struct Node : public Attributes<Node> {
409409
size_t stage_;
410410
bool has_name_;
411411
std::string name_;
412+
bool has_domain_;
413+
std::string domain_;
412414
bool has_doc_string_;
413415
std::string doc_string_;
414416

@@ -426,6 +428,16 @@ struct Node : public Attributes<Node> {
426428
has_name_ = true;
427429
name_ = std::move(name);
428430
}
431+
bool has_domain() {
432+
return has_domain_;
433+
}
434+
const std::string& domain() const {
435+
return domain_;
436+
}
437+
void setDomain(std::string domain) {
438+
has_domain_ = true;
439+
domain_ = std::move(domain);
440+
}
429441
bool has_doc_string() const {
430442
return has_doc_string_;
431443
}
@@ -1132,6 +1144,7 @@ inline Node::Node(Graph * graph_, NodeKind kind_) :
11321144
graph_(graph_),
11331145
stage_(graph_->new_node_stage_),
11341146
has_name_(false),
1147+
has_domain_(false),
11351148
has_doc_string_(false) {
11361149
graph_->all_nodes.emplace(this);
11371150
}

Diff for: onnx/common/ir_pb_converter.cc

+6
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ std::unique_ptr<Graph> graphProtoToGraph(const ONNX_NAMESPACE::GraphProto& gp, b
252252
if (np.has_name()) {
253253
n->setName(np.name());
254254
}
255+
if (np.has_domain()) {
256+
n->setDomain(np.domain());
257+
}
255258
}
256259

257260
for (auto n : g->nodes()) {
@@ -528,6 +531,9 @@ void encodeGraph(GraphProto * p_g, const std::shared_ptr<Graph> & g) {
528531
if (node->has_name()) {
529532
p_n->set_name(node->name());
530533
}
534+
if (node->has_domain()) {
535+
p_n->set_domain(node->domain());
536+
}
531537
}
532538

533539
auto num_initializers = g->initializers().size();

0 commit comments

Comments
 (0)