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 2018/11/20 02:55:24 UTC

[GitHub] stu1130 commented on a change in pull request #13190: [WIP] catch floating number divide by zero

stu1130 commented on a change in pull request #13190: [WIP] catch floating number divide by zero
URL: https://github.com/apache/incubator-mxnet/pull/13190#discussion_r234854681
 
 

 ##########
 File path: src/engine/engine.cc
 ##########
 @@ -23,10 +23,30 @@
  * \brief Implementation of engine.
  */
 #include <mxnet/engine.h>
+#include <fenv.h>
+#include <signal.h>
 #include <memory>
 #include <cstdlib>
 #include "./engine_impl.h"
 
+#ifdef _TEST_FLOAT_EXCEPTION
+static void float_num_err_handler(int sig, siginfo_t *siginfo, void *context) {
+  fprintf(stderr, ">>> Floating point error occur\n");
+  switch (siginfo->si_code) {
+  case FPE_INTDIV:
+    fprintf(stderr, ">>> Integer division by zero\n");
+    break;
+  case FPE_FLTOVF:
+    fprintf(stderr, ">>> Floating overflow trap\n");
+    break;
+  case FPE_FLTDIV:
+    fprintf(stderr, ">>> Floating/decimal division by zero\n");
+    break;
+  }
+  assert(0);
 
 Review comment:
   why adding assert(0) here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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