Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changhai etfeeder others attrs #27

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions et_feeder/et_feeder_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ ETFeederNode::ETFeederNode(std::shared_ptr<ChakraProtoMsg::Node> node) {
this->comm_dst_ = static_cast<uint32_t>(attr.int32_val());
} else if (attr_name == "comm_tag") {
this->comm_tag_ = static_cast<uint32_t>(attr.int32_val());
} else {
this->other_attrs_.emplace(attr_name, attr);
}
}
}
Expand Down Expand Up @@ -73,6 +75,20 @@ void ETFeederNode::setDepUnresolvedParentIDs(
dep_unresolved_parent_ids_ = dep_unresolved_parent_ids;
}

const ChakraProtoMsg::AttributeProto& ETFeederNode::get_other_attr(
const string& attr_name) const {
if (this->has_other_attr(attr_name))
return this->other_attrs_.at(attr_name);
throw std::runtime_error(
"Asked for attr \"" + attr_name + "\" from node " +
std::to_string(this->id_) + ", which do not exist");
}

bool ETFeederNode::has_other_attr(const string& attr_name) const {
const auto& item = this->other_attrs_.find(attr_name);
return item != this->other_attrs_.end();
}

uint64_t ETFeederNode::id() {
return id_;
}
Expand Down
6 changes: 6 additions & 0 deletions et_feeder/et_feeder_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class ETFeederNode {
void setDepUnresolvedParentIDs(
std::vector<uint64_t> const& dep_unresolved_parent_ids);

const ChakraProtoMsg::AttributeProto& get_other_attr(
const std::string& attr_name) const;
bool has_other_attr(const std::string& attr_name) const;

uint64_t id();
std::string name();
bool is_cpu_op();
Expand Down Expand Up @@ -46,6 +50,8 @@ class ETFeederNode {
std::unordered_set<std::shared_ptr<ETFeederNode>> children_set_{};
std::vector<std::shared_ptr<ETFeederNode>> children_vec_{};
std::vector<uint64_t> dep_unresolved_parent_ids_{};
std::unordered_map<std::string, const ChakraProtoMsg::AttributeProto&>
other_attrs_{};

uint64_t id_;
std::string name_;
Expand Down
Loading