Repository: deepjavalibrary/djl
Pull request #2126 (2022-11-03 18:09:13)

[ci] Avoid static setup/tearDown in testng
## Description ##

Brief description of what this PR is about

- If this change is a backward incompatible change, why must this change be made?
- Interesting edge cases to note here


codecov-commenter: # [Codecov](https://codecov.io/gh/deepjavalibrary/djl/pull/2126?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) Report
Base: **72.08**% // Head: **71.36**% // Decreases project coverage by **`-0.72%`** :warning:
> Coverage data is based on head [(`b44328e`)](https://codecov.io/gh/deepjavalibrary/djl/pull/2126?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) compared to base [(`bb5073f`)](https://codecov.io/gh/deepjavalibrary/djl/commit/bb5073f7ffc33f1883621fc1783dbb01e70b418f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary).
> Patch coverage: 71.54% of modified lines in pull request are covered.

<details><summary>Additional details and impacted files</summary>


```diff
@@             Coverage Diff              @@
##             master    #2126      +/-   ##
============================================
- Coverage     72.08%   71.36%   -0.73%     
- Complexity     5126     6284    +1158     
============================================
  Files           473      624     +151     
  Lines         21970    27823    +5853     
  Branches       2351     3000     +649     
============================================
+ Hits          15838    19857    +4019     
- Misses         4925     6505    +1580     
- Partials       1207     1461     +254     
```


| [Impacted Files](https://codecov.io/gh/deepjavalibrary/djl/pull/2126?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) | Coverage Δ | |
|---|---|---|
| [api/src/main/java/ai/djl/modality/cv/Image.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2126/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L0ltYWdlLmphdmE=) | `69.23% <ø> (-4.11%)` | :arrow_down: |
| [...rc/main/java/ai/djl/modality/cv/MultiBoxPrior.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2126/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L011bHRpQm94UHJpb3IuamF2YQ==) | `76.00% <ø> (ø)` | |
| [...rc/main/java/ai/djl/modality/cv/output/Joints.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2126/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L291dHB1dC9Kb2ludHMuamF2YQ==) | `71.42% <ø> (ø)` | |
| [.../main/java/ai/djl/modality/cv/output/Landmark.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2126/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L291dHB1dC9MYW5kbWFyay5qYXZh) | `100.00% <ø> (ø)` | |
| [...main/java/ai/djl/modality/cv/output/Rectangle.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2126/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L291dHB1dC9SZWN0YW5nbGUuamF2YQ==) | `72.41% <0.00%> (ø)` | |
| [...i/djl/modality/cv/translator/BigGANTranslator.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2126/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvQmlnR0FOVHJhbnNsYXRvci5qYXZh) | `21.42% <0.00%> (-5.24%)` | :arrow_down: |
| [.../modality/cv/translator/ImageFeatureExtractor.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2126/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvSW1hZ2VGZWF0dXJlRXh0cmFjdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [.../ai/djl/modality/cv/translator/YoloTranslator.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2126/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvWW9sb1RyYW5zbGF0b3IuamF2YQ==) | `27.77% <0.00%> (+18.95%)` | :arrow_up: |
| [...modality/cv/translator/wrapper/FileTranslator.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2126/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3Ivd3JhcHBlci9GaWxlVHJhbnNsYXRvci5qYXZh) | `44.44% <ø> (ø)` | |
| [...y/cv/translator/wrapper/InputStreamTranslator.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2126/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3Ivd3JhcHBlci9JbnB1dFN0cmVhbVRyYW5zbGF0b3IuamF2YQ==) | `44.44% <ø> (ø)` | |
| ... and [557 more](https://codecov.io/gh/deepjavalibrary/djl/pull/2126/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/deepjavalibrary/djl/pull/2126?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary).


Patch:
diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml
index d1c389360..a1264ff06 100644
--- a/.github/workflows/continuous.yml
+++ b/.github/workflows/continuous.yml
@@ -17,7 +17,7 @@ jobs:
     runs-on: ${{ matrix.operating-system }}
     strategy:
       matrix:
-        operating-system: [ ubuntu-18.04, macos-latest ]
+        operating-system: [ ubuntu-18.04, macos-12 ]
 
     steps:
       - uses: actions/checkout@v3
diff --git a/build.gradle b/build.gradle
index 606a88da0..2a6fd8ea5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -83,6 +83,7 @@ configure(javaProjects()) {
             // systemProperty "ai.djl.logging.level", "debug"
             systemProperty "org.slf4j.simpleLogger.defaultLogLevel", "debug"
             systemProperty "org.slf4j.simpleLogger.log.org.mortbay.log", "warn"
+            systemProperty "org.slf4j.simpleLogger.log.org.testng", "info"
             systemProperty "disableProgressBar", "true"
             systemProperty "nightly", System.getProperty("nightly", "false")
             if (gradle.startParameter.offline) {
diff --git a/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/engine/PpModel.java b/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/engine/PpModel.java
index c6008725a..9809e4202 100644
--- a/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/engine/PpModel.java
+++ b/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/engine/PpModel.java
@@ -94,6 +94,12 @@ public class PpModel extends BaseModel {
                 JniUtils.switchIrOptim(
                         config, ArgumentsUtil.booleanValue(options, "SwitchIrOptim"));
             }
+            if (options.containsKey("enableONNXRuntime")) {
+                JniUtils.enableONNXRuntime(config);
+            }
+            if (options.containsKey("enableOrtOptimization")) {
+                JniUtils.enableOrtOptimization(config);
+            }
         }
         paddlePredictor = new PaddlePredictor(JniUtils.createPredictor(config));
         JniUtils.deleteConfig(config);
diff --git a/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/jni/JniUtils.java b/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/jni/JniUtils.java
index c3651a347..4d92610a4 100644
--- a/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/jni/JniUtils.java
+++ b/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/jni/JniUtils.java
@@ -107,6 +107,14 @@ public final class JniUtils {
         PaddleLibrary.LIB.useFeedFetchOp(config);
     }
 
+    public static void enableONNXRuntime(long config) {
+        PaddleLibrary.LIB.analysisConfigEnableONNXRuntime(config);
+    }
+
+    public static void enableOrtOptimization(long config) {
+        PaddleLibrary.LIB.analysisConfigEnableORTOptimization(config);
+    }
+
     public static void deleteConfig(long config) {
         PaddleLibrary.LIB.deleteAnalysisConfig(config);
     }
diff --git a/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/jni/LibUtils.java b/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/jni/LibUtils.java
index 16249b3c9..b8d563719 100644
--- a/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/jni/LibUtils.java
+++ b/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/jni/LibUtils.java
@@ -70,6 +70,8 @@ public final class LibUtils {
             loadLinuxDependencies(libName);
         } else if (System.getProperty("os.name").startsWith("Win")) {
             loadWindowsDependencies(libName);
+        } else if (System.getProperty("os.name").startsWith("Mac")) {
+            loadMacOsDependencies(libName);
         }
         logger.debug("Now loading " + libName);
         System.load(libName); // NOPMD
@@ -91,7 +93,13 @@ public final class LibUtils {
                             + libDir
                             + ", the current one is set to: "
                             + Utils.getenv("LD_LIBRARY_PATH"));
-            List<String> names = Arrays.asList("libdnnl.so.2", "libiomp5.so", "libmklml_intel.so");
+            List<String> names =
+                    Arrays.asList(
+                            "libdnnl.so.2",
+                            "libiomp5.so",
+                            "libmklml_intel.so",
+                            "libonnxruntime.so",
+                            "libpaddle2onnx.so");
             names.forEach(
                     name -> {
                         Path path = libDir.resolve(name);
@@ -108,7 +116,24 @@ public final class LibUtils {
 
     public static void loadWindowsDependencies(String libName) {
         Path libDir = Paths.get(libName).getParent();
-        List<String> names = Arrays.asList("openblas.dll", "mkldnn.dll");
+        List<String> names =
+                Arrays.asList("openblas.dll", "mkldnn.dll", "onnxruntime.dll", "paddle2onnx.dll");
+        names.forEach(
+                name -> {
+                    Path path = libDir.resolve(name);
+                    if (Files.isRegularFile(path)) {
+                        String lib = path.toAbsolutePath().toString();
+                        logger.debug("Now loading " + lib);
+                        System.load(lib);
+                    } else {
+                        logger.debug(name + " is not found, skip loading...");
+                    }
+                });
+    }
+
+    public static void loadMacOsDependencies(String libName) {
+        Path libDir = Paths.get(libName).getParent();
+        List<String> names = Arrays.asList("libonnxruntime.dylib", "libpaddle2onnx.dylib");
         names.forEach(
                 name -> {
                     Path path = libDir.resolve(name);
diff --git a/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/jni/PaddleLibrary.java b/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/jni/PaddleLibrary.java
index f2a4f41e6..b4f9904f1 100644
--- a/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/jni/PaddleLibrary.java
+++ b/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/jni/PaddleLibrary.java
@@ -54,6 +54,10 @@ final class PaddleLibrary {
 
     native void analysisConfigRemovePass(long handle, String pass);
 
+    native void analysisConfigEnableONNXRuntime(long handle);
+
+    native void analysisConfigEnableORTOptimization(long handle);
+
     native void useFeedFetchOp(long handle);
 
     native void deleteAnalysisConfig(long handle);
diff --git a/engines/paddlepaddle/paddlepaddle-native/build.cmd b/engines/paddlepaddle/paddlepaddle-native/build.cmd
index 992e269b6..2f7ae5a37 100644
--- a/engines/paddlepaddle/paddlepaddle-native/build.cmd
+++ b/engines/paddlepaddle/paddlepaddle-native/build.cmd
@@ -7,9 +7,9 @@
 set FILEPATH="paddle"
 
 if "%1" == "cpu" (
-  set DOWNLOAD_URL="https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Windows/CPU/x86-64_vs2017_avx_openblas/paddle_inference.zip"
-) else if "%1" == "cu110" (
-  set DOWNLOAD_URL="https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Windows/GPU/x86-64_vs2017_avx_mkl_cuda11.0_cudnn8/paddle_inference.zip"
+  set DOWNLOAD_URL="https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/Windows/CPU/x86-64_avx-openblas-vs2017/paddle_inference.zip"
+) else if "%1" == "cu112" (
+  set DOWNLOAD_URL="https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/Windows/GPU/x86-64_cuda11.2_cudnn8.2.1_trt8.0.1.6_mkl_avx_vs2019/paddle_inference.zip"
 )
 
 if exist %FILEPATH% (
diff --git a/engines/paddlepaddle/paddlepaddle-native/build.gradle b/engines/paddlepaddle/paddlepaddle-native/build.gradle
index 11dbd1b60..f73193a97 100644
--- a/engines/paddlepaddle/paddlepaddle-native/build.gradle
+++ b/engines/paddlepaddle/paddlepaddle-native/build.gradle
@@ -53,12 +53,12 @@ task prepareNativeLibs() {
         delete "${buildDir}/native"
 
         def files = [
-                "cpu/linux"  : "https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Linux/CPU/gcc5.4_avx_openblas/paddle_inference.tgz",
-                "cu102/linux": "https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Linux/GPU/x86-64_gcc5.4_avx_mkl_cuda10.2_cudnn8.1.1_trt7.2.3.4/paddle_inference.tgz",
-                "cu112/linux": "https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Linux/GPU/x86-64_gcc5.4_avx_mkl_cuda11.2_cudnn8.2.1_trt8.0.3.4/paddle_inference.tgz",
-                "cpu/osx"    : "https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/MacOS/CPU/x86-64_clang_avx_openb/paddle_inference_install_dir.tgz",
-                "cpu/win"    : "https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Windows/CPU/x86-64_vs2017_avx_openblas/paddle_inference.zip",
-                "cu110/win"  : "https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Windows/GPU/x86-64_vs2017_avx_mkl_cuda11.0_cudnn8/paddle_inference.zip"
+                "cpu/linux"  : "https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/Linux/CPU/gcc5.4_avx_openblas/paddle_inference.tgz",
+                "cu102/linux": "https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/Linux/GPU/x86-64_gcc5.4_avx_mkl_cuda10.2_cudnn8.1.1_trt7.2.3.4/paddle_inference.tgz",
+                "cu112/linux": "https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/Linux/GPU/x86-64_gcc5.4_avx_mkl_cuda11.2_cudnn8.2.1_trt8.0.3.4/paddle_inference.tgz",
+                "cpu/osx"    : "https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/MacOS/CPU/x86-64_clang_avx_openblas/paddle_inference_install_dir.tgz",
+                "cpu/win"    : "https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/Windows/CPU/x86-64_avx-openblas-vs2017/paddle_inference.zip",
+                "cu112/win"  : "https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/Windows/GPU/x86-64_cuda11.2_cudnn8.2.1_trt8.0.1.6_mkl_avx_vs2019/paddle_inference.zip"
         ]
 
         def downloadDir = file("${buildDir}/download")
@@ -124,7 +124,7 @@ task uploadS3 {
                 "${buildDir}/native/cu112/linux/native/lib/",
                 "${buildDir}/native/cpu/osx/native/lib/",
                 "${buildDir}/native/cpu/win/native/lib/",
-                "${buildDir}/native/cu110/win/native/lib/"
+                "${buildDir}/native/cu112/win/native/lib/"
         ]
         uploadDirs.each { item ->
             fileTree(item).files.name.each {
diff --git a/engines/paddlepaddle/paddlepaddle-native/build.sh b/engines/paddlepaddle/paddlepaddle-native/build.sh
index b51845005..74fd416a6 100755
--- a/engines/paddlepaddle/paddlepaddle-native/build.sh
+++ b/engines/paddlepaddle/paddlepaddle-native/build.sh
@@ -14,21 +14,21 @@ pushd $WORK_DIR
 
 echo "Trying to find paddle folder..."
 
-# https://www.paddlepaddle.org.cn/inference/v2.2/user_guides/download_lib.html 2.2.2
+# https://www.paddlepaddle.org.cn/inference/v2.3/user_guides/download_lib.html 2.3.2
 
 if [[ ! -d "paddle" ]]; then
   echo "Folder not found. Downloading C++ package..."
   if [[ $PLATFORM == 'linux' ]]; then
     if [[ $1 == "cpu" ]]; then
-      curl -s https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Linux/CPU/gcc5.4_avx_openblas/paddle_inference.tgz -o paddle.tgz
+      curl -s https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/Linux/CPU/gcc5.4_avx_openblas/paddle_inference.tgz -o paddle.tgz
       tar -xvzf paddle.tgz
       mv paddle_inference paddle
     elif [[ $1 == "cu102" ]]; then
-      curl -s https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Linux/GPU/x86-64_gcc5.4_avx_mkl_cuda10.2_cudnn7.6.5_trt6.0.1.5/paddle_inference.tgz -o paddle.tgz
+      curl -s https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/Linux/GPU/x86-64_gcc5.4_avx_mkl_cuda10.2_cudnn7.6.5_trt6.0.1.5/paddle_inference.tgz -o paddle.tgz
         tar -xvzf paddle.tgz
         mv paddle_inference paddle
     elif [[ $1 == "cu112" ]]; then
-      curl -s https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Linux/GPU/x86-64_gcc5.4_avx_mkl_cuda11.2_cudnn8.2.1_trt8.0.3.4/paddle_inference.tgz -o paddle.tgz
+      curl -s https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/Linux/GPU/x86-64_gcc5.4_avx_mkl_cuda11.2_cudnn8.2.1_trt8.0.3.4/paddle_inference.tgz -o paddle.tgz
         tar -xvzf paddle.tgz
         mv paddle_inference paddle
     else
@@ -36,7 +36,7 @@ if [[ ! -d "paddle" ]]; then
       exit 1
     fi
   elif [[ $PLATFORM == 'darwin' ]]; then
-    curl -s https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/MacOS/CPU/x86-64_clang_avx_openb/paddle_inference_install_dir.tgz -o paddle.tgz
+    curl -s https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/MacOS/CPU/x86-64_clang_avx_openblas/paddle_inference_install_dir.tgz -o paddle.tgz
     tar -xvzf paddle.tgz
     mv paddle_inference_install_dir paddle
   else
diff --git a/engines/paddlepaddle/paddlepaddle-native/src/main/native/ai_djl_paddlepaddle_jni_PaddleLibrary_inference.cc b/engines/paddlepaddle/paddlepaddle-native/src/main/native/ai_djl_paddlepaddle_jni_PaddleLibrary_inference.cc
index 5b32d19d6..e1b78545d 100644
--- a/engines/paddlepaddle/paddlepaddle-native/src/main/native/ai_djl_paddlepaddle_jni_PaddleLibrary_inference.cc
+++ b/engines/paddlepaddle/paddlepaddle-native/src/main/native/ai_djl_paddlepaddle_jni_PaddleLibrary_inference.cc
@@ -81,6 +81,18 @@ JNIEXPORT void JNICALL Java_ai_djl_paddlepaddle_jni_PaddleLibrary_analysisConfig
   config_ptr->pass_builder()->DeletePass(djl::utils::jni::GetStringFromJString(env, jpass));
 }
 
+JNIEXPORT void JNICALL Java_ai_djl_paddlepaddle_jni_PaddleLibrary_analysisConfigEnableONNXRuntime
+        (JNIEnv* env, jobject jthis, jlong jhandle) {
+    auto* config_ptr = reinterpret_cast<paddle::AnalysisConfig*>(jhandle);
+    config_ptr->EnableONNXRuntime();
+}
+
+JNIEXPORT void JNICALL Java_ai_djl_paddlepaddle_jni_PaddleLibrary_analysisConfigEnableORTOptimization
+        (JNIEnv* env, jobject jthis, jlong jhandle) {
+    auto* config_ptr = reinterpret_cast<paddle::AnalysisConfig*>(jhandle);
+    config_ptr->EnableORTOptimization();
+}
+
 JNIEXPORT void JNICALL Java_ai_djl_paddlepaddle_jni_PaddleLibrary_deleteAnalysisConfig(
     JNIEnv* env, jobject jthis, jlong jhandle) {
   const auto* config_ptr = reinterpret_cast<paddle::AnalysisConfig*>(jhandle);
diff --git a/engines/tensorflow/tensorflow-api/build.gradle b/engines/tensorflow/tensorflow-api/build.gradle
index 5e564e128..b7c6c9934 100644
--- a/engines/tensorflow/tensorflow-api/build.gradle
+++ b/engines/tensorflow/tensorflow-api/build.gradle
@@ -7,7 +7,7 @@ configurations {
 dependencies {
     api "org.bytedeco:javacpp:${javacpp_version}"
     api "com.google.protobuf:protobuf-java:${protobuf_version}"
-    api "org.tensorflow:tensorflow-core-api:0.4.0"
+    api "org.tensorflow:tensorflow-core-api:0.4.2"
 
     exclusion "org.bytedeco:javacpp:${javacpp_version}"
     exclusion "com.google.protobuf:protobuf-java:${protobuf_version}"
diff --git a/engines/tensorflow/tensorflow-native/build.gradle b/engines/tensorflow/tensorflow-native/build.gradle
index 45066a6b9..d72e52dc0 100644
--- a/engines/tensorflow/tensorflow-native/build.gradle
+++ b/engines/tensorflow/tensorflow-native/build.gradle
@@ -13,11 +13,11 @@ configurations {
 }
 
 dependencies {
-    download "org.tensorflow:tensorflow-core-api:0.4.0:linux-x86_64-gpu"
-    download "org.tensorflow:tensorflow-core-api:0.4.0:linux-x86_64"
-    download "org.tensorflow:tensorflow-core-api:0.4.0:macosx-x86_64"
-    download "org.tensorflow:tensorflow-core-api:0.4.0:windows-x86_64"
-    download "org.tensorflow:tensorflow-core-api:0.4.0:windows-x86_64-gpu"
+    download "org.tensorflow:tensorflow-core-api:0.4.2:linux-x86_64-gpu"
+    download "org.tensorflow:tensorflow-core-api:0.4.2:linux-x86_64"
+    download "org.tensorflow:tensorflow-core-api:0.4.2:macosx-x86_64"
+    download "org.tensorflow:tensorflow-core-api:0.4.2:windows-x86_64"
+    download "org.tensorflow:tensorflow-core-api:0.4.2:windows-x86_64-gpu"
 }
 
 task uploadTensorflowNativeLibs() {
diff --git a/gradle.properties b/gradle.properties
index 7f754b706..714988d86 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -14,12 +14,12 @@ systemProp.org.gradle.internal.publish.checksums.insecure=true
 djl_version=0.20.0
 mxnet_version=1.9.1
 pytorch_version=1.12.1
-tensorflow_version=2.7.0
+tensorflow_version=2.7.4
 tflite_version=2.6.2
 dlr_version=1.6.0
 trt_version=8.4.1
 onnxruntime_version=1.13.1
-paddlepaddle_version=2.2.2
+paddlepaddle_version=2.3.2
 sentencepiece_version=0.1.96
 tokenizers_version=0.12.0
 fasttext_version=0.9.2


Test patch:
diff --git a/api/src/test/java/ai/djl/nn/convolutional/OutputShapeTest.java b/api/src/test/java/ai/djl/nn/convolutional/OutputShapeTest.java
index 1d1100b0d..6e84ef76b 100644
--- a/api/src/test/java/ai/djl/nn/convolutional/OutputShapeTest.java
+++ b/api/src/test/java/ai/djl/nn/convolutional/OutputShapeTest.java
@@ -20,15 +20,15 @@ import org.testng.annotations.BeforeClass;
 
 public abstract class OutputShapeTest {
 
-    static NDManager manager;
+    protected NDManager manager;
 
     @BeforeClass
-    public static void setupManager() {
+    public void setupManager() {
         manager = NDManager.newBaseManager();
     }
 
     @AfterClass
-    public static void teardownManager() {
+    public void teardownManager() {
         manager.close();
     }
 }
diff --git a/engines/paddlepaddle/paddlepaddle-model-zoo/src/test/java/ai/djl/paddlepaddle/zoo/MaskDetectionTest.java b/engines/paddlepaddle/paddlepaddle-model-zoo/src/test/java/ai/djl/paddlepaddle/zoo/MaskDetectionTest.java
index 8545d0df0..62e1bd1e6 100644
--- a/engines/paddlepaddle/paddlepaddle-model-zoo/src/test/java/ai/djl/paddlepaddle/zoo/MaskDetectionTest.java
+++ b/engines/paddlepaddle/paddlepaddle-model-zoo/src/test/java/ai/djl/paddlepaddle/zoo/MaskDetectionTest.java
@@ -109,6 +109,8 @@ public class MaskDetectionTest {
                         .setTypes(Image.class, Classifications.class)
                         .optArtifactId("ai.djl.paddlepaddle:mask_classification")
                         .optFilter("flavor", "server")
+                        .optOption("enableONNXRuntime", "true")
+                        .optOption("enableOrtOptimization", "true")
                         .build();
         ZooModel<Image, Classifications> model = criteria.loadModel();
         return model.newPredictor();
@@ -121,6 +123,8 @@ public class MaskDetectionTest {
                         .setTypes(Image.class, DetectedObjects.class)
                         .optArtifactId("ai.djl.paddlepaddle:face_detection")
                         .optFilter("flavor", "server")
+                        .optOption("enableONNXRuntime", "true")
+                        .optOption("enableOrtOptimization", "true")
                         .build();
 
         try (ZooModel<Image, DetectedObjects> model = criteria.loadModel();