This is an automated email from the ASF dual-hosted git repository.

nswamy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new e1fe7b1  Throw exception if MXSymbolInferShape fails. (#12733)
e1fe7b1 is described below

commit e1fe7b14f4c31c35f77c9ee3b701a59db86c38c0
Author: Casey Marshall <[email protected]>
AuthorDate: Fri Oct 5 09:04:43 2018 -0700

    Throw exception if MXSymbolInferShape fails. (#12733)
    
    * Throw exception if MXSymbolInferShape fails.
    
    * scala-package/native/src/main/native/org_apache_mxnet_native_c_api.cc:
      (Java_org_apache_mxnet_LibInfo_mxSymbolInferShape): throw
      IllegalArgumentException with the content of MXGetError if call to
      MXSymbolInferShape fails.
    
    * Remove stray space.
    
    * Don't throw in JNI.
    
    checkCall in scala code will do the right thing with a nonzero exit
    status.
    
    * Don't repeat the memory free code.
    
    Just wrap the FillSymbolInferShape calls in `if (ret == 0) { ... }`.
    
    * Fix too-long line.
---
 .../main/native/org_apache_mxnet_native_c_api.cc   | 39 ++++++++++++----------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git 
a/scala-package/native/src/main/native/org_apache_mxnet_native_c_api.cc 
b/scala-package/native/src/main/native/org_apache_mxnet_native_c_api.cc
index 95325f3..17d166e 100644
--- a/scala-package/native/src/main/native/org_apache_mxnet_native_c_api.cc
+++ b/scala-package/native/src/main/native/org_apache_mxnet_native_c_api.cc
@@ -1581,26 +1581,29 @@ JNIEXPORT jint JNICALL 
Java_org_apache_mxnet_LibInfo_mxSymbolInferShape
   env->ReleaseIntArrayElements(jargShapeData, argShapeData, 0);
   env->ReleaseIntArrayElements(jargIndPtr, argIndPtr, 0);
 
-  jclass listClass = env->FindClass("scala/collection/mutable/ListBuffer");
-  jmethodID listAppend = env->GetMethodID(listClass,
-    "$plus$eq", "(Ljava/lang/Object;)Lscala/collection/mutable/ListBuffer;");
+  if (ret == 0) {
+    jclass listClass = env->FindClass("scala/collection/mutable/ListBuffer");
+    jmethodID listAppend = env->GetMethodID(listClass,
+      "$plus$eq", "(Ljava/lang/Object;)Lscala/collection/mutable/ListBuffer;");
 
-  if (FillSymbolInferShape(env, listAppend, jinShapeData, inShapeSize, 
inShapeNdim, inShapeData)) {
-    // TODO(Yizhi): out of memory error thrown, return a specific error code ?
-    return -1;
-  }
-  if (FillSymbolInferShape(
-        env, listAppend, joutShapeData, outShapeSize, outShapeNdim, 
outShapeData)) {
-    // TODO(Yizhi): out of memory error thrown, return a specific error code ?
-    return -1;
-  }
-  if (FillSymbolInferShape(
-        env, listAppend, jauxShapeData, auxShapeSize, auxShapeNdim, 
auxShapeData)) {
-    // TODO(Yizhi): out of memory error thrown, return a specific error code ?
-    return -1;
-  }
+    if (FillSymbolInferShape(
+          env, listAppend, jinShapeData, inShapeSize, inShapeNdim, 
inShapeData)) {
+      // TODO(Yizhi): out of memory error thrown, return a specific error code 
?
+      return -1;
+    }
+    if (FillSymbolInferShape(
+          env, listAppend, joutShapeData, outShapeSize, outShapeNdim, 
outShapeData)) {
+      // TODO(Yizhi): out of memory error thrown, return a specific error code 
?
+      return -1;
+    }
+    if (FillSymbolInferShape(
+          env, listAppend, jauxShapeData, auxShapeSize, auxShapeNdim, 
auxShapeData)) {
+      // TODO(Yizhi): out of memory error thrown, return a specific error code 
?
+      return -1;
+    }
 
-  SetIntField(env, jcomplete, complete);
+    SetIntField(env, jcomplete, complete);
+  }
 
   // release allocated memory
   if (jkeys != NULL) {

Reply via email to