I set input data, run it, and get output data in my android application code.
// set input data
final int inputDim = 4864;
Random random = new Random();
NDArray inputNdArray = NDArray.empty(new long[]{inputDim}, new TVMType("float32"), TVMContext.cpu());
float[] inputdata = new float[inputDim];
for (int i = 0; i < inputDim; i++) {
inputdata[i] = random.nextFloat();
}
inputNdArray.copyFrom(inputdata); <---- issue
Function setInputFunc = graphRuntimeModule.getFunction("set_input");
setInputFunc.pushArg(INPUT_NAME).pushArg(inputNdArray).invoke();
// inference
Function runFunc = graphRuntimeModule.getFunction("run");
runFunc.invoke();
// get output data
final int outputDim = 2;
NDArray outputNdArray = NDArray.empty(new long[]{outputDim}, new TVMType("float32"), tvmCtx);
Function getOutputFunc = graphRuntimeModule.getFunction("get_output");
getOutputFunc.pushArg(OUTPUT_INDEX).pushArg(outputNdArray).invoke();
float[] output = outputNdArray.asFloatArray(); <---- issue
The execution of this code fails unless I comment out those two lines marked with <---- issue.
The error message is as follows. It fails when it gets the shape of NDArray variables
by calling JNIEXPORT jint JNICALL Java_ml_dmlc_tvm_LibInfo_tvmArrayGetShape function.
A/art: art/runtime/check_jni.cc:72] JNI DETECTED ERROR IN APPLICATION: the return type of CallObjectMethodV does not match boolean java.util.List.add(java.lang.Object)
art/runtime/check_jni.cc:72] in call to CallObjectMethodV
art/runtime/check_jni.cc:72] from int ml.dmlc.tvm.LibInfo.tvmArrayGetShape(long, java.util.List)
Can I get some advice on this issue?
Thank you.