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


##########
python/mxnet/ndarray/ndarray.py:
##########
@@ -2653,6 +2653,8 @@ def asnumpy(self):
         array([[1, 1, 1],
                [1, 1, 1]], dtype=int32)
         """
+        if self.dtype == bfloat16:
+            return self.astype(np.float32).asnumpy()

Review Comment:
   Is it call itself or SyncCopyTocpu is missing for bfloat16 ?



##########
src/imperative/imperative.cc:
##########
@@ -33,11 +33,13 @@ namespace mxnet {
 thread_local bool Imperative::is_train_                 = false;
 thread_local bool Imperative::is_recording_             = false;
 thread_local bool Imperative::is_deferred_compute_      = false;
+thread_local OptConstraint Imperative::opt_constraints_ = OptConstraint::None;

Review Comment:
   ```suggestion
   thread_local unsigned int Imperative::opt_constraints_ = OptConstraint::None;
   ```
   as I understand we are going to store bitmask of the features



##########
include/mxnet/imperative.h:
##########
@@ -237,6 +246,16 @@ class Imperative {
     }
     return old;
   }
+  /*! \brief return current optimization constraints. */
+  OptConstraint get_opt_constraints() const {

Review Comment:
   ```suggestion
     unsigned int get_opt_constraints() const {
   ```
   as the intention is to use OptConstraint as bitmask



##########
src/imperative/imperative.cc:
##########
@@ -367,6 +369,10 @@ void Imperative::RecordDeferredCompute(nnvm::NodeAttrs&& 
attrs,
     node_count_++;
   }
 
+  if (get_opt_constraints() != OptConstraint::None) {
+    node->attrs.dict[OPT_CONSTRAINT_ATTR] = 
std::to_string(static_cast<int>(get_opt_constraints()));

Review Comment:
   ```suggestion
       node->attrs.dict[OPT_CONSTRAINT_ATTR] = 
std::to_string(static_cast<unsigned int>(get_opt_constraints()));
   ```
   or maybe it is worth to overload operator << to make it human readable



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