wkcn commented on a change in pull request #16234: [MXNET-1426] Fix the wrong 
result of sum, mean, argmin, argmax when inputs contain inf or nan
URL: https://github.com/apache/incubator-mxnet/pull/16234#discussion_r344984993
 
 

 ##########
 File path: 3rdparty/mshadow/mshadow/base.h
 ##########
 @@ -606,6 +606,64 @@ struct divto {
   typedef op::div OPType;
 };
 }  // namespace sv
+
+#ifndef __CUDA_ARCH__
+using std::isnan;
+using std::isinf;
+#endif
+
+/*! \brief
+ *  determines if the given floating point
+ *  number is not a number */
+namespace isnan_typed {
+  template<typename DType>
+  MSHADOW_XINLINE bool IsNan(volatile DType val) {
+    return false;
+  }
+  template<>
+  MSHADOW_XINLINE bool IsNan(volatile float val) {
+    return isnan(val);
+  }
+  template<>
+  MSHADOW_XINLINE bool IsNan(volatile double val) {
+    return isnan(val);
+  }
+  template<>
+  MSHADOW_XINLINE bool IsNan(volatile long double val) {
+    return isnan(val);
+  }
+  template<>
+  MSHADOW_XINLINE bool IsNan(volatile mshadow::half::half_t val) {
+    return (val.half_ & 0x7fff) > 0x7c00;
 
 Review comment:
   Hi @marcoabreu , I add two constants `MSHADOW_HALF_SIGN_BIT` and 
`MSHADOW_HALF_EXPONENT_BITS` in 
[3rdparty/mshadow/mshadow/half.h](https://github.com/apache/incubator-mxnet/pull/16234/commits/9183cb3a2284a7d920bb720a19c38dc49d66fdea#diff-0d54cfcb67beaf0744f1efe71b45bfdfR352),
 and replace these two magic values.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to