diff --git a/engines/pytorch/pytorch-native/src/main/native/ai_djl_pytorch_jni_PyTorchLibrary_inference.cc b/engines/pytorch/pytorch-native/src/main/native/ai_djl_pytorch_jni_PyTorchLibrary_inference.cc index 1c6911d20c0..b7a00c8757f 100644 --- a/engines/pytorch/pytorch-native/src/main/native/ai_djl_pytorch_jni_PyTorchLibrary_inference.cc +++ b/engines/pytorch/pytorch-native/src/main/native/ai_djl_pytorch_jni_PyTorchLibrary_inference.cc @@ -25,8 +25,10 @@ struct JITCallGuard { torch::NoGradGuard no_grad; #else c10::InferenceMode guard; +#ifdef __ANDROID__ torch::jit::GraphOptimizerEnabledGuard no_optimizer_guard{false}; #endif +#endif }; JNIEXPORT jlong JNICALL diff --git a/engines/pytorch/pytorch-native/src/main/native/ai_djl_pytorch_jni_PyTorchLibrary_torch_reduction.cc b/engines/pytorch/pytorch-native/src/main/native/ai_djl_pytorch_jni_PyTorchLibrary_torch_reduction.cc index 6b1abb8cec0..a46a6e4bc29 100644 --- a/engines/pytorch/pytorch-native/src/main/native/ai_djl_pytorch_jni_PyTorchLibrary_torch_reduction.cc +++ b/engines/pytorch/pytorch-native/src/main/native/ai_djl_pytorch_jni_PyTorchLibrary_torch_reduction.cc @@ -132,16 +132,16 @@ JNIEXPORT jlong JNICALL Java_ai_djl_pytorch_jni_PyTorchLibrary_torchSum__J_3JZ( API_END_RETURN() } -JNIEXPORT jlong JNICALL Java_ai_djl_pytorch_jni_PyTorchLibrary_torchCumProd - (JNIEnv * env, jobject jthis, jlong jhandle, jlong jdim, jint jdtype) { +JNIEXPORT jlong JNICALL Java_ai_djl_pytorch_jni_PyTorchLibrary_torchCumProd( + JNIEnv* env, jobject jthis, jlong jhandle, jlong jdim, jint jdtype) { API_BEGIN() const auto* tensor_ptr = reinterpret_cast(jhandle); if (jdtype == -1) { - const auto* result_ptr = new torch::Tensor(tensor_ptr->cumprod(jdim)); - return reinterpret_cast(result_ptr); + const auto* result_ptr = new torch::Tensor(tensor_ptr->cumprod(jdim)); + return reinterpret_cast(result_ptr); } else { - const auto* result_ptr = new torch::Tensor(tensor_ptr->cumprod(jdim, utils::GetScalarTypeFromDType(jdtype))); - return reinterpret_cast(result_ptr); + const auto* result_ptr = new torch::Tensor(tensor_ptr->cumprod(jdim, utils::GetScalarTypeFromDType(jdtype))); + return reinterpret_cast(result_ptr); } API_END_RETURN() }