Lines Matching refs:env
35 JNIEnv *env, jobject /* this */, jstring _nnApiDeviceName) { in Java_com_android_nn_benchmark_core_NNTestBase_hasNnApiDevice() argument
39 : env->GetStringUTFChars(_nnApiDeviceName, NULL); in Java_com_android_nn_benchmark_core_NNTestBase_hasNnApiDevice()
55 env->ReleaseStringUTFChars(_nnApiDeviceName, nnApiDeviceName); in Java_com_android_nn_benchmark_core_NNTestBase_hasNnApiDevice()
65 JNIEnv *env, in Java_com_android_nn_benchmark_core_NNTestBase_initModel() argument
73 const char *modelFileName = env->GetStringUTFChars(_modelFileName, NULL); in Java_com_android_nn_benchmark_core_NNTestBase_initModel()
77 : env->GetStringUTFChars(_nnApiDeviceName, NULL); in Java_com_android_nn_benchmark_core_NNTestBase_initModel()
81 : env->GetStringUTFChars(_nnApiCacheDir, NULL); in Java_com_android_nn_benchmark_core_NNTestBase_initModel()
86 env->ReleaseStringUTFChars(_modelFileName, modelFileName); in Java_com_android_nn_benchmark_core_NNTestBase_initModel()
88 env->ReleaseStringUTFChars(_nnApiDeviceName, nnApiDeviceName); in Java_com_android_nn_benchmark_core_NNTestBase_initModel()
92 jclass nnapiFailureClass = env->FindClass( in Java_com_android_nn_benchmark_core_NNTestBase_initModel()
95 env->GetMethodID(nnapiFailureClass, "<init>", "(I)V"); in Java_com_android_nn_benchmark_core_NNTestBase_initModel()
97 env->NewObject(nnapiFailureClass, constructor, nnapiErrno); in Java_com_android_nn_benchmark_core_NNTestBase_initModel()
98 env->Throw(static_cast<jthrowable>(exception)); in Java_com_android_nn_benchmark_core_NNTestBase_initModel()
108 JNIEnv *env, in Java_com_android_nn_benchmark_core_NNTestBase_destroyModel() argument
119 JNIEnv *env, in Java_com_android_nn_benchmark_core_NNTestBase_resizeInputTensors() argument
124 jint* shapePtr = env->GetIntArrayElements(_inputShape, nullptr); in Java_com_android_nn_benchmark_core_NNTestBase_resizeInputTensors()
125 jsize shapeLen = env->GetArrayLength(_inputShape); in Java_com_android_nn_benchmark_core_NNTestBase_resizeInputTensors()
134 InferenceInOutSequenceList(JNIEnv *env,
152 InferenceInOutSequenceList::InferenceInOutSequenceList(JNIEnv *env, in InferenceInOutSequenceList() argument
155 : mEnv(env), mValid(false) { in InferenceInOutSequenceList()
157 jclass list_class = env->FindClass("java/util/List"); in InferenceInOutSequenceList()
159 jmethodID list_size = env->GetMethodID(list_class, "size", "()I"); in InferenceInOutSequenceList()
161 jmethodID list_get = env->GetMethodID(list_class, "get", "(I)Ljava/lang/Object;"); in InferenceInOutSequenceList()
163 jmethodID list_add = env->GetMethodID(list_class, "add", "(Ljava/lang/Object;)Z"); in InferenceInOutSequenceList()
166 jclass inOutSeq_class = env->FindClass("com/android/nn/benchmark/core/InferenceInOutSequence"); in InferenceInOutSequenceList()
168 jmethodID inOutSeq_size = env->GetMethodID(inOutSeq_class, "size", "()I"); in InferenceInOutSequenceList()
170 jmethodID inOutSeq_get = env->GetMethodID(inOutSeq_class, "get", in InferenceInOutSequenceList()
174 jclass inout_class = env->FindClass("com/android/nn/benchmark/core/InferenceInOut"); in InferenceInOutSequenceList()
176 jfieldID inout_input = env->GetFieldID(inout_class, "mInput", "[B"); in InferenceInOutSequenceList()
178 jfieldID inout_expectedOutputs = env->GetFieldID(inout_class, "mExpectedOutputs", "[[B"); in InferenceInOutSequenceList()
180 jfieldID inout_inputCreator = env->GetFieldID(inout_class, "mInputCreator", in InferenceInOutSequenceList()
188 if (env->ExceptionCheck()) { return; } in InferenceInOutSequenceList()
191 …jclass inputCreator_class = env->FindClass("com/android/nn/benchmark/core/InferenceInOut$InputCrea… in InferenceInOutSequenceList()
193 …jmethodID createInput_method = env->GetMethodID(inputCreator_class, "createInput", "(Ljava/nio/Byt… in InferenceInOutSequenceList()
221 inputCreator = [env, inout, inout_inputCreator, createInput_method]( in InferenceInOutSequenceList()
223 jobject byteBuffer = env->NewDirectByteBuffer(buffer, length); in InferenceInOutSequenceList()
225 jobject creator = env->GetObjectField(inout, inout_inputCreator); in InferenceInOutSequenceList()
227 env->CallVoidMethod(creator, createInput_method, byteBuffer); in InferenceInOutSequenceList()
228 if (env->ExceptionCheck()) { return false; } in InferenceInOutSequenceList()
247 if (env->ExceptionCheck()) { in InferenceInOutSequenceList()
311 JNIEnv *env, in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark() argument
322 jclass list_class = env->FindClass("java/util/List"); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
324 jmethodID list_add = env->GetMethodID(list_class, "add", "(Ljava/lang/Object;)Z"); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
327 jclass result_class = env->FindClass("com/android/nn/benchmark/core/InferenceResult"); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
329 jmethodID result_ctor = env->GetMethodID(result_class, "<init>", "(F[F[F[[BII)V"); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
335 InferenceInOutSequenceList data(env, inOutDataList, expectGoldenOutputs); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
351 meanSquareErrorArray = env->NewFloatArray(rentry.meanSquareErrors.size()); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
352 if (env->ExceptionCheck()) { return false; } in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
353 maxSingleErrorArray = env->NewFloatArray(rentry.maxSingleErrors.size()); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
354 if (env->ExceptionCheck()) { return false; } in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
356 jfloat *bytes = env->GetFloatArrayElements(meanSquareErrorArray, nullptr); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
360 env->ReleaseFloatArrayElements(meanSquareErrorArray, bytes, 0); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
363 jfloat *bytes = env->GetFloatArrayElements(maxSingleErrorArray, nullptr); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
367 env->ReleaseFloatArrayElements(maxSingleErrorArray, bytes, 0); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
372 jclass byteArrayClass = env->FindClass("[B"); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
374 inferenceOutputs = env->NewObjectArray( in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
380 inferenceOutput = env->NewByteArray(rentry.inferenceOutputs[i].size()); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
381 if (env->ExceptionCheck()) { return false; } in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
382 jbyte *bytes = env->GetByteArrayElements(inferenceOutput, nullptr); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
384 env->ReleaseByteArrayElements(inferenceOutput, bytes, 0); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
385 env->SetObjectArrayElement(inferenceOutputs, i, inferenceOutput); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
389 jobject object = env->NewObject( in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
393 if (env->ExceptionCheck() || object == NULL) { return false; } in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
395 env->CallBooleanMethod(resultList, list_add, object); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
396 if (env->ExceptionCheck()) { return false; } in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
401 env->DeleteLocalRef(meanSquareErrorArray); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
404 env->DeleteLocalRef(maxSingleErrorArray); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
406 env->DeleteLocalRef(object); in Java_com_android_nn_benchmark_core_NNTestBase_runBenchmark()
417 JNIEnv *env, in Java_com_android_nn_benchmark_core_NNTestBase_dumpAllLayers() argument
425 InferenceInOutSequenceList data(env, inOutDataList, /*expectGoldenOutputs=*/false); in Java_com_android_nn_benchmark_core_NNTestBase_dumpAllLayers()
430 const char *dumpPathStr = env->GetStringUTFChars(dumpPath, JNI_FALSE); in Java_com_android_nn_benchmark_core_NNTestBase_dumpAllLayers()
432 env->ReleaseStringUTFChars(dumpPath, dumpPathStr); in Java_com_android_nn_benchmark_core_NNTestBase_dumpAllLayers()
449 JNIEnv *env, in Java_com_android_nn_benchmark_core_NNTestBase_getAcceleratorNames() argument
459 jclass list_class = env->FindClass("java/util/List"); in Java_com_android_nn_benchmark_core_NNTestBase_getAcceleratorNames()
461 jmethodID list_add = env->GetMethodID(list_class, "add", "(Ljava/lang/Object;)Z"); in Java_com_android_nn_benchmark_core_NNTestBase_getAcceleratorNames()
476 auto device_name = env->NewStringUTF(buffer); in Java_com_android_nn_benchmark_core_NNTestBase_getAcceleratorNames()
478 env->CallBooleanMethod(resultList, list_add, device_name); in Java_com_android_nn_benchmark_core_NNTestBase_getAcceleratorNames()
479 if (env->ExceptionCheck()) { return false; } in Java_com_android_nn_benchmark_core_NNTestBase_getAcceleratorNames()
484 static jfloatArray convertToJfloatArray(JNIEnv* env, const std::vector<float>& from) { in convertToJfloatArray() argument
485 jfloatArray to = env->NewFloatArray(from.size()); in convertToJfloatArray()
486 if (env->ExceptionCheck()) { in convertToJfloatArray()
489 jfloat* bytes = env->GetFloatArrayElements(to, nullptr); in convertToJfloatArray()
491 env->ReleaseFloatArrayElements(to, bytes, 0); in convertToJfloatArray()
497 JNIEnv* env, in Java_com_android_nn_benchmark_core_NNTestBase_runCompilationBenchmark() argument
505 jclass result_class = env->FindClass("com/android/nn/benchmark/core/CompilationBenchmarkResult"); in Java_com_android_nn_benchmark_core_NNTestBase_runCompilationBenchmark()
507 jmethodID result_ctor = env->GetMethodID(result_class, "<init>", "([F[F[FI)V"); in Java_com_android_nn_benchmark_core_NNTestBase_runCompilationBenchmark()
517 convertToJfloatArray(env, result.compileWithoutCacheTimeSec); in Java_com_android_nn_benchmark_core_NNTestBase_runCompilationBenchmark()
523 saveToCacheArray = convertToJfloatArray(env, result.saveToCacheTimeSec.value()); in Java_com_android_nn_benchmark_core_NNTestBase_runCompilationBenchmark()
528 prepareFromCacheArray = convertToJfloatArray(env, result.prepareFromCacheTimeSec.value()); in Java_com_android_nn_benchmark_core_NNTestBase_runCompilationBenchmark()
532 jobject object = env->NewObject(result_class, result_ctor, compileWithoutCacheArray, in Java_com_android_nn_benchmark_core_NNTestBase_runCompilationBenchmark()
534 if (env->ExceptionCheck()) return nullptr; in Java_com_android_nn_benchmark_core_NNTestBase_runCompilationBenchmark()