You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/01/09 08:24:55 UTC

[GitHub] [incubator-mxnet] marcoabreu commented on a change in pull request #17255: Set np default dtype( float32 <-> float64)

marcoabreu commented on a change in pull request #17255: Set np default dtype( float32 <-> float64)
URL: https://github.com/apache/incubator-mxnet/pull/17255#discussion_r364606683
 
 

 ##########
 File path: include/mxnet/imperative.h
 ##########
 @@ -136,6 +137,34 @@ class Imperative {
     }
     return old;
   }
+  /*! \brief return current ndarray default dtype,
+   *  float32(false), float64(true).
+   * */
+  int is_np_default_dtype() const {
+    if (is_np_default_dtype_global_) {
+      return 2;
+    }
+    return is_np_default_dtype_thread_local_ ? 1 : 0;
+  }
+  /*! \brief specify ndarray default dtype off, thread local on or global on. */
+  bool set_is_np_default_dtype(int is_np_default_dtype) {
+    NumpyDefaultDtype flag = static_cast<NumpyDefaultDtype>(is_np_default_dtype);
+    bool old = this->is_np_default_dtype();
+    switch (flag) {
+      case GlobalOn:
+        is_np_default_dtype_global_ = true;
+        is_np_default_dtype_thread_local_ = true;
+        break;
+      case ThreadLocalOn:
+        is_np_default_dtype_thread_local_ = true;
+        break;
+      case Off:
+        is_np_default_dtype_global_ = false;
+        is_np_default_dtype_thread_local_ = false;
+        break;
+    }
+    return old;
 
 Review comment:
   ?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services