@@ -40,7 +40,7 @@ namespace {
4040tflite_api_dispatcher::Interpreter* convertLongToInterpreter (JNIEnv* env,
4141 jlong handle) {
4242 if (handle == 0 ) {
43- ThrowException (env, kIllegalArgumentException ,
43+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
4444 " Internal error: Invalid handle to Interpreter." );
4545 return nullptr ;
4646 }
@@ -50,7 +50,7 @@ tflite_api_dispatcher::Interpreter* convertLongToInterpreter(JNIEnv* env,
5050tflite_api_dispatcher::TfLiteModel* convertLongToModel (JNIEnv* env,
5151 jlong handle) {
5252 if (handle == 0 ) {
53- ThrowException (env, kIllegalArgumentException ,
53+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
5454 " Internal error: Invalid handle to model." );
5555 return nullptr ;
5656 }
@@ -59,7 +59,7 @@ tflite_api_dispatcher::TfLiteModel* convertLongToModel(JNIEnv* env,
5959
6060BufferErrorReporter* convertLongToErrorReporter (JNIEnv* env, jlong handle) {
6161 if (handle == 0 ) {
62- ThrowException (env, kIllegalArgumentException ,
62+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
6363 " Internal error: Invalid handle to ErrorReporter." );
6464 return nullptr ;
6565 }
@@ -68,7 +68,7 @@ BufferErrorReporter* convertLongToErrorReporter(JNIEnv* env, jlong handle) {
6868
6969TfLiteDelegate* convertLongToDelegate (JNIEnv* env, jlong handle) {
7070 if (handle == 0 ) {
71- ThrowException (env, kIllegalArgumentException ,
71+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
7272 " Internal error: Invalid handle to delegate." );
7373 return nullptr ;
7474 }
@@ -80,7 +80,7 @@ std::vector<int> convertJIntArrayToVector(JNIEnv* env, jintArray inputs) {
8080 std::vector<int > outputs (size, 0 );
8181 jint* ptr = env->GetIntArrayElements (inputs, nullptr );
8282 if (ptr == nullptr ) {
83- ThrowException (env, kIllegalArgumentException ,
83+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
8484 " Array has empty dimensions." );
8585 return {};
8686 }
@@ -130,7 +130,7 @@ bool AreDimsDifferent(JNIEnv* env, TfLiteTensor* tensor, jintArray dims) {
130130 int num_dims = static_cast <int >(env->GetArrayLength (dims));
131131 jint* ptr = env->GetIntArrayElements (dims, nullptr );
132132 if (ptr == nullptr ) {
133- ThrowException (env, kIllegalArgumentException ,
133+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
134134 " Empty dimensions of input array." );
135135 return true ;
136136 }
@@ -170,7 +170,7 @@ Java_org_tensorflow_lite_NativeInterpreterWrapper_getInputNames(JNIEnv* env,
170170 if (interpreter == nullptr ) return nullptr ;
171171 jclass string_class = env->FindClass (" java/lang/String" );
172172 if (string_class == nullptr ) {
173- ThrowException (env, kUnsupportedOperationException ,
173+ ThrowException (env, tflite::jni:: kUnsupportedOperationException ,
174174 " Internal error: Can not find java/lang/String class to get "
175175 " input names." );
176176 return nullptr ;
@@ -197,7 +197,7 @@ Java_org_tensorflow_lite_NativeInterpreterWrapper_allocateTensors(
197197
198198 if (interpreter->AllocateTensors () != kTfLiteOk ) {
199199 ThrowException (
200- env, kIllegalStateException ,
200+ env, tflite::jni:: kIllegalStateException ,
201201 " Internal error: Unexpected failure when preparing tensor allocations:"
202202 " %s" ,
203203 error_reporter->CachedErrorMessage ());
@@ -284,7 +284,7 @@ Java_org_tensorflow_lite_NativeInterpreterWrapper_getOutputNames(JNIEnv* env,
284284 if (interpreter == nullptr ) return nullptr ;
285285 jclass string_class = env->FindClass (" java/lang/String" );
286286 if (string_class == nullptr ) {
287- ThrowException (env, kUnsupportedOperationException ,
287+ ThrowException (env, tflite::jni:: kUnsupportedOperationException ,
288288 " Internal error: Can not find java/lang/String class to get "
289289 " output names." );
290290 return nullptr ;
@@ -365,12 +365,12 @@ Java_org_tensorflow_lite_NativeInterpreterWrapper_useXNNPACK(
365365 // TODO(b/166483905): Add support for multiple delegates when model allows.
366366 if (delegation_status != kTfLiteOk &&
367367 delegation_status != kTfLiteApplicationError ) {
368- ThrowException (env, kIllegalArgumentException ,
368+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
369369 " Internal error: Failed to apply XNNPACK delegate: %s" ,
370370 error_reporter->CachedErrorMessage ());
371371 }
372372 } else {
373- ThrowException (env, kIllegalArgumentException ,
373+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
374374 " Failed to load XNNPACK delegate from current runtime. "
375375 " Have you added the necessary dependencies?" );
376376 }
@@ -422,7 +422,7 @@ Java_org_tensorflow_lite_NativeInterpreterWrapper_createModel(
422422 auto model = tflite_api_dispatcher::TfLiteModel::VerifyAndBuildFromFile (
423423 path, verifier.get (), error_reporter);
424424 if (!model) {
425- ThrowException (env, kIllegalArgumentException ,
425+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
426426 " Contents of %s does not encode a valid "
427427 " TensorFlow Lite model: %s" ,
428428 path, error_reporter->CachedErrorMessage ());
@@ -443,15 +443,15 @@ Java_org_tensorflow_lite_NativeInterpreterWrapper_createModelWithBuffer(
443443 static_cast <char *>(env->GetDirectBufferAddress (model_buffer));
444444 jlong capacity = env->GetDirectBufferCapacity (model_buffer);
445445 if (!VerifyModel (buf, capacity)) {
446- ThrowException (env, kIllegalArgumentException ,
446+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
447447 " ByteBuffer is not a valid flatbuffer model" );
448448 return 0 ;
449449 }
450450
451451 auto model = tflite_api_dispatcher::TfLiteModel::BuildFromBuffer (
452452 buf, static_cast <size_t >(capacity), error_reporter);
453453 if (!model) {
454- ThrowException (env, kIllegalArgumentException ,
454+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
455455 " ByteBuffer does not encode a valid model: %s" ,
456456 error_reporter->CachedErrorMessage ());
457457 return 0 ;
@@ -474,7 +474,7 @@ Java_org_tensorflow_lite_NativeInterpreterWrapper_createInterpreter(
474474 TfLiteStatus status = tflite_api_dispatcher::InterpreterBuilder (
475475 *model, *(resolver.get ()))(&interpreter, static_cast <int >(num_threads));
476476 if (status != kTfLiteOk ) {
477- ThrowException (env, kIllegalArgumentException ,
477+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
478478 " Internal error: Cannot create interpreter: %s" ,
479479 error_reporter->CachedErrorMessage ());
480480 return 0 ;
@@ -496,7 +496,7 @@ JNIEXPORT void JNICALL Java_org_tensorflow_lite_NativeInterpreterWrapper_run(
496496
497497 if (interpreter->Invoke () != kTfLiteOk ) {
498498 // TODO(b/168266570): Return InterruptedException.
499- ThrowException (env, kIllegalArgumentException ,
499+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
500500 " Internal error: Failed to run on the given Interpreter: %s" ,
501501 error_reporter->CachedErrorMessage ());
502502 return ;
@@ -511,7 +511,7 @@ Java_org_tensorflow_lite_NativeInterpreterWrapper_getOutputDataType(
511511 if (interpreter == nullptr ) return -1 ;
512512 const int idx = static_cast <int >(output_idx);
513513 if (output_idx < 0 || output_idx >= interpreter->outputs ().size ()) {
514- ThrowException (env, kIllegalArgumentException ,
514+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
515515 " Failed to get %d-th output out of %d outputs" , output_idx,
516516 interpreter->outputs ().size ());
517517 return -1 ;
@@ -532,7 +532,7 @@ Java_org_tensorflow_lite_NativeInterpreterWrapper_resizeInput(
532532 convertLongToInterpreter (env, interpreter_handle);
533533 if (interpreter == nullptr ) return JNI_FALSE;
534534 if (input_idx < 0 || input_idx >= interpreter->inputs ().size ()) {
535- ThrowException (env, kIllegalArgumentException ,
535+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
536536 " Input error: Can not resize %d-th input for a model having "
537537 " %d inputs." ,
538538 input_idx, interpreter->inputs ().size ());
@@ -552,7 +552,7 @@ Java_org_tensorflow_lite_NativeInterpreterWrapper_resizeInput(
552552 tensor_idx, convertJIntArrayToVector (env, dims));
553553 }
554554 if (status != kTfLiteOk ) {
555- ThrowException (env, kIllegalArgumentException ,
555+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
556556 " Internal error: Failed to resize %d-th input: %s" ,
557557 input_idx, error_reporter->CachedErrorMessage ());
558558 return JNI_FALSE;
@@ -578,7 +578,7 @@ Java_org_tensorflow_lite_NativeInterpreterWrapper_applyDelegate(
578578
579579 TfLiteStatus status = interpreter->ModifyGraphWithDelegate (delegate);
580580 if (status != kTfLiteOk ) {
581- ThrowException (env, kIllegalArgumentException ,
581+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
582582 " Internal error: Failed to apply delegate: %s" ,
583583 error_reporter->CachedErrorMessage ());
584584 }
@@ -597,7 +597,7 @@ Java_org_tensorflow_lite_NativeInterpreterWrapper_resetVariableTensors(
597597
598598 TfLiteStatus status = interpreter->ResetVariableTensors ();
599599 if (status != kTfLiteOk ) {
600- ThrowException (env, kIllegalArgumentException ,
600+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
601601 " Internal error: Failed to reset variable tensors: %s" ,
602602 error_reporter->CachedErrorMessage ());
603603 }
@@ -609,7 +609,7 @@ Java_org_tensorflow_lite_NativeInterpreterWrapper_createCancellationFlag(
609609 tflite_api_dispatcher::Interpreter* interpreter =
610610 convertLongToInterpreter (env, interpreter_handle);
611611 if (interpreter == nullptr ) {
612- ThrowException (env, kIllegalArgumentException ,
612+ ThrowException (env, tflite::jni:: kIllegalArgumentException ,
613613 " Internal error: Invalid handle to interpreter." );
614614 }
615615 std::atomic_bool* cancellation_flag = new std::atomic_bool (false );
0 commit comments