[tvm4j] provide error msg for failure function call (#2967)
authorYizhi Liu <liuyizhi@apache.org>
Fri, 5 Apr 2019 02:49:08 +0000 (19:49 -0700)
committerTianqi Chen <tqchen@users.noreply.github.com>
Fri, 5 Apr 2019 02:49:08 +0000 (19:49 -0700)
jvm/native/src/main/native/ml_dmlc_tvm_native_c_api.cc

index fada50c..d22e045 100644 (file)
@@ -178,6 +178,10 @@ JNIEXPORT jint JNICALL Java_ml_dmlc_tvm_LibInfo_tvmFuncCall(
   int ret = TVMFuncCall(reinterpret_cast<TVMFunctionHandle>(jhandle),
     &argValues[0], &argTypes[0], numArgs, &retVal, &retTypeCode);
 
+  if (ret != 0) {
+    return ret;
+  }
+
   for (auto iter = pushedStrs.cbegin(); iter != pushedStrs.cend(); iter++) {
     env->ReleaseStringUTFChars(iter->first, iter->second);
     env->DeleteGlobalRef(iter->first);