PawelGlomski-Intel commented on code in PR #20983:
URL: https://github.com/apache/incubator-mxnet/pull/20983#discussion_r850356711
##########
src/common/utils.h:
##########
@@ -438,6 +438,32 @@ inline std::string attr_value_string(const
nnvm::NodeAttrs& attrs,
return attrs.dict.at(attr_name);
}
+template <typename Fn>
+inline void attr_foreach(const nnvm::NodeAttrs& attrs, const std::string&
attr_name, const Fn& fn) {
+ const auto& found_it = attrs.dict.find(attr_name);
+ if (found_it != attrs.dict.end()) {
+ fn(found_it->second);
+ }
+ for (const auto& subgraph : attrs.subgraphs) {
+ DFSVisit(subgraph->outputs,
+ [&](const nnvm::ObjectPtr& node) { attr_foreach(node->attrs,
attr_name, fn); });
+ }
+}
+
+template <typename ValueType>
+inline ValueType flag_attr_accumulate(const nnvm::NodeAttrs& attrs, const
std::string& attr_name) {
+ static_assert(std::is_integral<ValueType>::value);
+
+ ValueType result = 0;
+ attr_foreach(attrs, attr_name, [&result](const std::string& attr_value) {
+ std::istringstream ss(attr_value);
+ ValueType temp;
+ ss >> temp;
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]