anko-intel commented on code in PR #20983:
URL: https://github.com/apache/incubator-mxnet/pull/20983#discussion_r849307106


##########
src/c_api/c_api_ndarray.cc:
##########
@@ -291,6 +291,18 @@ int MXAutogradSetIsRecording(int is_recording, int* prev) {
   API_END();
 }
 
+int MXSetOptimizationConstraints(int constraints, int* prev) {

Review Comment:
   maybe unsigned int ?



##########
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:
   what happened if conversion is not proper ?



-- 
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]

Reply via email to