Repository: deepjavalibrary/djl
Pull request #1599 (2022-04-24 17:39:56)

[basicdataset] Fixed out of bound limit
## Description ##

In Stanford Question Answering Dataset the limit is specially handled, and there exists a severe bug that if the limit is too large (or the limit is set as default) it will cause an `IndexOutOfBoundException`.

This PR fixed this bug and changed the test cases into a more strict one so that this bug will be detected.



codecov-commenter: # [Codecov](https://codecov.io/gh/deepjavalibrary/djl/pull/1599?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) Report
> Merging [#1599](https://codecov.io/gh/deepjavalibrary/djl/pull/1599?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) (3a0f5d0) into [master](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) (bb5073f) will **decrease** coverage by `1.22%`.
> The diff coverage is `60.49%`.

```diff
@@             Coverage Diff              @@
##             master    #1599      +/-   ##
============================================
- Coverage     72.08%   70.86%   -1.23%     
- Complexity     5126     5401     +275     
============================================
  Files           473      504      +31     
  Lines         21970    23615    +1645     
  Branches       2351     2568     +217     
============================================
+ Hits          15838    16734     +896     
- Misses         4925     5602     +677     
- Partials       1207     1279      +72     
```


| [Impacted Files](https://codecov.io/gh/deepjavalibrary/djl/pull/1599?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/1599/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: |
| [...i/djl/modality/cv/translator/BigGANTranslator.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1599/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% <ø> (-5.24%)` | :arrow_down: |
| [...odality/cv/translator/BigGANTranslatorFactory.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvQmlnR0FOVHJhbnNsYXRvckZhY3RvcnkuamF2YQ==) | `33.33% <0.00%> (+8.33%)` | :arrow_up: |
| [...nslator/InstanceSegmentationTranslatorFactory.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvSW5zdGFuY2VTZWdtZW50YXRpb25UcmFuc2xhdG9yRmFjdG9yeS5qYXZh) | `14.28% <0.00%> (-3.90%)` | :arrow_down: |
| [.../modality/cv/translator/YoloTranslatorFactory.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvWW9sb1RyYW5zbGF0b3JGYWN0b3J5LmphdmE=) | `8.33% <0.00%> (-1.67%)` | :arrow_down: |
| [...i/djl/modality/cv/translator/YoloV5Translator.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvWW9sb1Y1VHJhbnNsYXRvci5qYXZh) | `5.69% <0.00%> (ø)` | |
| [...odality/cv/translator/YoloV5TranslatorFactory.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvWW9sb1Y1VHJhbnNsYXRvckZhY3RvcnkuamF2YQ==) | `8.33% <0.00%> (-1.67%)` | :arrow_down: |
| [...pi/src/main/java/ai/djl/ndarray/BytesSupplier.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL25kYXJyYXkvQnl0ZXNTdXBwbGllci5qYXZh) | `54.54% <0.00%> (-12.13%)` | :arrow_down: |
| [...ain/java/ai/djl/ndarray/index/dim/NDIndexPick.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL25kYXJyYXkvaW5kZXgvZGltL05ESW5kZXhQaWNrLmphdmE=) | `100.00% <ø> (ø)` | |
| [api/src/main/java/ai/djl/nn/Blocks.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL25uL0Jsb2Nrcy5qYXZh) | `75.00% <0.00%> (-25.00%)` | :arrow_down: |
| ... and [235 more](https://codecov.io/gh/deepjavalibrary/djl/pull/1599/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/deepjavalibrary/djl/pull/1599?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/deepjavalibrary/djl/pull/1599?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary). Last update [109c9b4...3a0f5d0](https://codecov.io/gh/deepjavalibrary/djl/pull/1599?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary).


Patch:
diff --git a/README.md b/README.md
index 1c16a4c9c..2c3016aae 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,6 @@
 ![DeepJavaLibrary](website/img/deepjavalibrary.png?raw=true "Deep Java Library")
 
 ![Continuous](https://github.com/deepjavalibrary/djl/workflows/Continuous/badge.svg)
-![Continuous PyTorch](https://github.com/deepjavalibrary/djl/workflows/Continous%20PyTorch/badge.svg)
-![Continuous Tensorflow](https://github.com/deepjavalibrary/djl/workflows/Continuous%20Tensorflow/badge.svg)
 ![Docs](https://github.com/deepjavalibrary/djl/workflows/Docs/badge.svg)
 ![Nightly Publish](https://github.com/deepjavalibrary/djl/workflows/Nightly%20Publish/badge.svg)
 
diff --git a/basicdataset/src/main/java/ai/djl/basicdataset/nlp/StanfordQuestionAnsweringDataset.java b/basicdataset/src/main/java/ai/djl/basicdataset/nlp/StanfordQuestionAnsweringDataset.java
index 7fe2abdf1..7716d5ab1 100644
--- a/basicdataset/src/main/java/ai/djl/basicdataset/nlp/StanfordQuestionAnsweringDataset.java
+++ b/basicdataset/src/main/java/ai/djl/basicdataset/nlp/StanfordQuestionAnsweringDataset.java
@@ -228,6 +228,28 @@ public class StanfordQuestionAnsweringDataset extends TextDataset implements Raw
         return data;
     }
 
+    /**
+     * Since a question might have no answer, we need extra logic to find the last index of the
+     * answer in the {@code TargetTextData}. There are not many consecutive questions without
+     * answer, so this logic will not cause a high cost.
+     *
+     * @param questionInfoIndex the last index of the record in {@code questionInfoList} that needs
+     *     to be preprocessed
+     * @return the last index of the answer in {@code TargetTextData} that needs to be preprocessed
+     */
+    private int getLastAnswerIndex(int questionInfoIndex) {
+        // Go backwards through the questionInfoList until it finds one with an answer
+        for (; questionInfoIndex >= 0; questionInfoIndex--) {
+            QuestionInfo questionInfo = questionInfoList.get(questionInfoIndex);
+            if (!questionInfo.answerIndexList.isEmpty()) {
+                return questionInfo.answerIndexList.get(questionInfo.answerIndexList.size() - 1);
+            }
+        }
+
+        // Could not find a QuestionInfo with an answer
+        return 0;
+    }
+
     /**
      * Performs pre-processing steps on text data such as tokenising, applying {@link
      * ai.djl.modality.nlp.preprocess.TextProcessor}s, creating vocabulary, and word embeddings.
@@ -241,13 +263,10 @@ public class StanfordQuestionAnsweringDataset extends TextDataset implements Raw
     @Override
     protected void preprocess(List<String> newTextData, boolean source) throws EmbeddingException {
         TextData textData = source ? sourceTextData : targetTextData;
-        QuestionInfo questionInfo = questionInfoList.get(Math.toIntExact(this.limit) - 1);
+        int index = (int) Math.min(limit, questionInfoList.size()) - 1;
         int lastIndex =
-                source
-                        ? questionInfo.questionIndex
-                        : questionInfo.answerIndexList.get(questionInfo.answerIndexList.size() - 1);
-        textData.preprocess(
-                manager, newTextData.subList(0, Math.min(lastIndex + 1, newTextData.size())));
+                source ? questionInfoList.get(index).questionIndex : getLastAnswerIndex(index);
+        textData.preprocess(manager, newTextData.subList(0, lastIndex + 1));
     }
 
     /** A builder for a {@link StanfordQuestionAnsweringDataset}. */
diff --git a/docs/development/troubleshooting.md b/docs/development/troubleshooting.md
index 6959ecf99..e8a0aa6d5 100644
--- a/docs/development/troubleshooting.md
+++ b/docs/development/troubleshooting.md
@@ -257,3 +257,20 @@ and relying on DJL's `NDManager` to efficiently GC the memory. You can do that b
 ```
 -Dai.djl.disable_close_resource_on_finalize=true
 ```
+
+## 11. Special character issues (PaddlePaddle)
+
+Please remember to not include special characters in your data/model path. Like "数据" or some non-asicii character.
+
+```
+C++ Traceback (most recent call last):
+Not support stack backtrace yet.
+Error Message Summary:
+NotFoundError: Cannot open file C: \Users\数据\.dil.ai\cache\repo\model\undefined\ai\dil|localmodelzoo\d4cb1b0cfc0101b98c3fec6f29568bef\.model
+please confirm whether the file is existeed!
+
+[Hint: Expected static_cast<bool>(fin.is_open()) == true, but received static_cast<bool>(fin.is_open)):0 != true:1.]
+fatal error has been detected by the Java Runtime Environment:
+```
+
+
diff --git a/engines/onnxruntime/onnxruntime-engine/README.md b/engines/onnxruntime/onnxruntime-engine/README.md
index 74b31d3e3..87e690fb6 100644
--- a/engines/onnxruntime/onnxruntime-engine/README.md
+++ b/engines/onnxruntime/onnxruntime-engine/README.md
@@ -73,7 +73,7 @@ Maven:
 <dependency>
     <groupId>com.microsoft.onnxruntime</groupId>
     <artifactId>onnxruntime_gpu</artifactId>
-    <version>1.10.0</version>
+    <version>1.11.0</version>
     <scope>runtime</scope>
 </dependency>
 ```
@@ -83,5 +83,5 @@ Gradle:
     implementation("ai.djl.onnxruntime:onnxruntime-engine:0.16.0") {
         exclude group: "com.microsoft.onnxruntime", module: "onnxruntime"
     }
-    implementation "com.microsoft.onnxruntime:onnxruntime_gpu:1.10.0"
+    implementation "com.microsoft.onnxruntime:onnxruntime_gpu:1.11.0"
 ```
diff --git a/engines/onnxruntime/onnxruntime-engine/src/main/java/ai/djl/onnxruntime/engine/OrtSymbolBlock.java b/engines/onnxruntime/onnxruntime-engine/src/main/java/ai/djl/onnxruntime/engine/OrtSymbolBlock.java
index b9dad479b..9c5aa7b3c 100644
--- a/engines/onnxruntime/onnxruntime-engine/src/main/java/ai/djl/onnxruntime/engine/OrtSymbolBlock.java
+++ b/engines/onnxruntime/onnxruntime-engine/src/main/java/ai/djl/onnxruntime/engine/OrtSymbolBlock.java
@@ -85,10 +85,26 @@ public class OrtSymbolBlock extends AbstractSymbolBlock implements AutoCloseable
         Map<String, OnnxTensor> container = new ConcurrentHashMap<>();
         // forward
         try (OrtNDManager sub = (OrtNDManager) manager.newSubManager()) {
-            // feed data in to match names
-            for (int i = 0; i < inputNames.size(); ++i) {
-                OrtNDArray ortNDArray = sub.from(inputs.get(i));
-                container.put(inputNames.get(i), ortNDArray.getTensor());
+            // If input data has name
+            if (inputs.get(0).getName() != null) {
+                for (NDArray input : inputs) {
+                    String name = input.getName();
+                    if (name == null) {
+                        throw new IllegalArgumentException(
+                                "All or none of input tensors must have a name.");
+                    }
+                    if (!inputNames.contains(name)) {
+                        throw new IllegalArgumentException("Invalid input tensor name: " + name);
+                    }
+                    OrtNDArray ortNDArray = sub.from(input);
+                    container.put(name, ortNDArray.getTensor());
+                }
+            } else {
+                // feed data in to match names
+                for (int i = 0; i < inputNames.size(); ++i) {
+                    OrtNDArray ortNDArray = sub.from(inputs.get(i));
+                    container.put(inputNames.get(i), ortNDArray.getTensor());
+                }
             }
 
             OrtSession.Result results = session.run(container);
@@ -100,6 +116,16 @@ public class OrtSymbolBlock extends AbstractSymbolBlock implements AutoCloseable
         }
     }
 
+    /** {@inheritDoc} */
+    @Override
+    public PairList<String, Shape> describeInput() {
+        PairList<String, Shape> result = new PairList<>();
+        for (String name : session.getInputNames()) {
+            result.add(name, null);
+        }
+        return result;
+    }
+
     private NDList evaluateOutput(OrtSession.Result results) {
         NDList output = new NDList();
         for (Map.Entry<String, OnnxValue> r : results) {
diff --git a/engines/paddlepaddle/paddlepaddle-engine/README.md b/engines/paddlepaddle/paddlepaddle-engine/README.md
index e64ce2247..00b01641a 100644
--- a/engines/paddlepaddle/paddlepaddle-engine/README.md
+++ b/engines/paddlepaddle/paddlepaddle-engine/README.md
@@ -30,7 +30,7 @@ You can pull the PaddlePaddle engine from the central Maven repository by includ
 <dependency>
     <groupId>ai.djl.paddlepaddle</groupId>
     <artifactId>paddlepaddle-engine</artifactId>
-    <version>0.16.0</version>
+    <version>0.17.0</version>
     <scope>runtime</scope>
 </dependency>
 ```
@@ -43,28 +43,28 @@ You can choose a native library based on your platform if you don't have network
 ### macOS
 For macOS, you can use the following library:
 
-- ai.djl.paddlepaddle:paddlepaddle-native-cpu:2.0.2:osx-x86_64
+- ai.djl.paddlepaddle:paddlepaddle-native-cpu:2.2.2:osx-x86_64
 
 ```xml
 <dependency>
     <groupId>ai.djl.paddlepaddle</groupId>
     <artifactId>paddlepaddle-native-cpu</artifactId>
     <classifier>osx-x86_64</classifier>
-    <version>2.0.2</version>
+    <version>2.2.2</version>
     <scope>runtime</scope>
 </dependency>
 ```
 
 ### Linux
 
-- ai.djl.paddlepaddle:paddlepaddle-native-cpu:2.0.2:linux-x86_64
+- ai.djl.paddlepaddle:paddlepaddle-native-cpu:2.2.2:linux-x86_64
 
 ```xml
 <dependency>
     <groupId>ai.djl.paddlepaddle</groupId>
     <artifactId>paddlepaddle-native-cpu</artifactId>
     <classifier>linux-x86_64</classifier>
-    <version>2.0.2</version>
+    <version>2.2.2</version>
     <scope>runtime</scope>
 </dependency>
 ```
@@ -74,18 +74,18 @@ For macOS, you can use the following library:
 To use Linux packages, users are also required to set `LD_LIBRARY_PATH` to the folder:
 
 ```
-LD_LIBRARY_PATH=$HOME/.djl.ai/paddle/2.0.2-<cuda-flavor>-linux-x86_64
+LD_LIBRARY_PATH=$HOME/.djl.ai/paddle/2.2.2-<cuda-flavor>-linux-x86_64
 ```
 
-- ai.djl.paddlepaddle:paddlepaddle-native-cu101:2.0.2:linux-x86_64 - CUDA 10.1
-- ai.djl.paddlepaddle:paddlepaddle-native-cu102:2.0.2:linux-x86_64 - CUDA 10.2
+- ai.djl.paddlepaddle:paddlepaddle-native-cu102:2.2.2:linux-x86_64 - CUDA 10.2
+- ai.djl.paddlepaddle:paddlepaddle-native-cu112:2.2.2:linux-x86_64 - CUDA 11.2
 
 ```xml
 <dependency>
     <groupId>ai.djl.paddlepaddle</groupId>
-    <artifactId>paddlepaddle-native-cu101</artifactId>
+    <artifactId>paddlepaddle-native-cu102</artifactId>
     <classifier>linux-x86_64</classifier>
-    <version>2.0.2</version>
+    <version>2.2.2</version>
     <scope>runtime</scope>
 </dependency>
 ```
@@ -93,9 +93,9 @@ LD_LIBRARY_PATH=$HOME/.djl.ai/paddle/2.0.2-<cuda-flavor>-linux-x86_64
 ```xml
 <dependency>
     <groupId>ai.djl.paddlepaddle</groupId>
-    <artifactId>paddlepaddle-native-cu102</artifactId>
+    <artifactId>paddlepaddle-native-cu112</artifactId>
     <classifier>linux-x86_64</classifier>
-    <version>2.0.2</version>
+    <version>2.2.2</version>
     <scope>runtime</scope>
 </dependency>
 ```
@@ -103,14 +103,28 @@ LD_LIBRARY_PATH=$HOME/.djl.ai/paddle/2.0.2-<cuda-flavor>-linux-x86_64
 
 ### Windows
 
-- ai.djl.paddlepaddle:paddlepaddle-native-cpu:2.0.2:win-x86_64
+- ai.djl.paddlepaddle:paddlepaddle-native-cpu:2.2.2:win-x86_64
 
 ```xml
 <dependency>
     <groupId>ai.djl.paddlepaddle</groupId>
     <artifactId>paddlepaddle-native-cpu</artifactId>
     <classifier>win-x86_64</classifier>
-    <version>2.0.2</version>
+    <version>2.2.2</version>
+    <scope>runtime</scope>
+</dependency>
+```
+
+#### Windows GPU (Experimental)
+
+- ai.djl.paddlepaddle:paddlepaddle-native-cu110:2.2.2:win-x86_64
+
+```xml
+<dependency>
+    <groupId>ai.djl.paddlepaddle</groupId>
+    <artifactId>paddlepaddle-native-cu110</artifactId>
+    <classifier>win-x86_64</classifier>
+    <version>2.2.2</version>
     <scope>runtime</scope>
 </dependency>
 ```
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 503f52f01..6f1130b27 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
@@ -24,7 +24,6 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Matcher;
@@ -107,12 +106,17 @@ public final class LibUtils {
 
     public static void loadWindowsDependencies(String libName) {
         Path libDir = Paths.get(libName).getParent();
-        List<String> names = Collections.singletonList("openblas.dll");
+        List<String> names = Arrays.asList("openblas.dll", "mkldnn.dll");
         names.forEach(
                 name -> {
-                    String lib = libDir.resolve(name).toAbsolutePath().toString();
-                    logger.debug("Now loading " + lib);
-                    System.load(libDir.resolve(name).toAbsolutePath().toString());
+                    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...");
+                    }
                 });
     }
 
diff --git a/engines/paddlepaddle/paddlepaddle-native/build.cmd b/engines/paddlepaddle/paddlepaddle-native/build.cmd
index e0dc21154..992e269b6 100644
--- a/engines/paddlepaddle/paddlepaddle-native/build.cmd
+++ b/engines/paddlepaddle/paddlepaddle-native/build.cmd
@@ -7,7 +7,9 @@
 set FILEPATH="paddle"
 
 if "%1" == "cpu" (
-  set DOWNLOAD_URL="https://alpha-djl-demos.s3.amazonaws.com/temp/paddle_inference_install_dir-windows-openblas-2.0.2.zip"
+  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"
 )
 
 if exist %FILEPATH% (
@@ -16,7 +18,7 @@ if exist %FILEPATH% (
     echo Couldn't find %FILEPATH%, downloading it ...
     echo Downloading from: %DOWNLOAD_URL%
     powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%cd%\paddle.zip')"
-    powershell -Command "Expand-Archive -LiteralPath paddle.zip -DestinationPath %cd%"
+    powershell -Command "Expand-Archive -LiteralPath paddle.zip -DestinationPath %cd%\paddle"
     rename paddle_inference_install_dir paddle
     del /f paddle.zip
     echo Finished downloading paddle
diff --git a/engines/paddlepaddle/paddlepaddle-native/build.gradle b/engines/paddlepaddle/paddlepaddle-native/build.gradle
index 3b4538c7d..11dbd1b60 100644
--- a/engines/paddlepaddle/paddlepaddle-native/build.gradle
+++ b/engines/paddlepaddle/paddlepaddle-native/build.gradle
@@ -53,11 +53,12 @@ task prepareNativeLibs() {
         delete "${buildDir}/native"
 
         def files = [
-                "cpu/linux"  : "https://alpha-djl-demos.s3.amazonaws.com/temp/paddle202/paddle_inference_install_dir-2.0.2-openblas-gcc54-ubuntu.tgz",
-                "cu101/linux": "https://paddle-inference-lib.bj.bcebos.com/2.0.2-gpu-cuda10.1-cudnn7-avx-mkl/paddle_inference.tgz",
-                "cu102/linux": "https://paddle-inference-lib.bj.bcebos.com/2.0.2-gpu-cuda10.2-cudnn8-avx-mkl/paddle_inference.tgz",
-                "cpu/osx"    : "https://paddle-inference-lib.bj.bcebos.com/mac/2.0.2/cpu_avx_openblas/paddle_inference.tgz",
-                "cpu/win"    : "https://alpha-djl-demos.s3.amazonaws.com/temp/paddle_inference_install_dir-windows-openblas-2.0.2.zip"
+                "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"
         ]
 
         def downloadDir = file("${buildDir}/download")
@@ -119,10 +120,11 @@ task uploadS3 {
         def f = new File("${buildDir}/native/files.txt")
         def uploadDirs = [
                 "${buildDir}/native/cpu/linux/native/lib/",
-                "${buildDir}/native/cu101/linux/native/lib/",
                 "${buildDir}/native/cu102/linux/native/lib/",
+                "${buildDir}/native/cu112/linux/native/lib/",
                 "${buildDir}/native/cpu/osx/native/lib/",
-                "${buildDir}/native/cpu/win/native/lib/"
+                "${buildDir}/native/cpu/win/native/lib/",
+                "${buildDir}/native/cu110/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 b35510ddf..b51845005 100755
--- a/engines/paddlepaddle/paddlepaddle-native/build.sh
+++ b/engines/paddlepaddle/paddlepaddle-native/build.sh
@@ -14,19 +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
+
 if [[ ! -d "paddle" ]]; then
   echo "Folder not found. Downloading C++ package..."
   if [[ $PLATFORM == 'linux' ]]; then
     if [[ $1 == "cpu" ]]; then
-      curl -s https://alpha-djl-demos.s3.amazonaws.com/temp/paddle202/paddle_inference_install_dir-2.0.2-openblas-gcc54-ubuntu.tgz -o paddle.tgz
+      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
       tar -xvzf paddle.tgz
-      mv paddle_inference_install_dir paddle
-    elif [[ $1 == "cu101" ]]; then
-      curl -s https://paddle-inference-lib.bj.bcebos.com/2.0.2-gpu-cuda10.1-cudnn7-avx-mkl/paddle_inference.tgz -o 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
         tar -xvzf paddle.tgz
         mv paddle_inference paddle
-    elif [[ $1 == "cu102" ]]; then
-      curl -s https://paddle-inference-lib.bj.bcebos.com/2.0.2-gpu-cuda10.2-cudnn8-avx-mkl/paddle_inference.tgz -o paddle.tgz
+    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
         tar -xvzf paddle.tgz
         mv paddle_inference paddle
     else
@@ -34,7 +36,7 @@ if [[ ! -d "paddle" ]]; then
       exit 1
     fi
   elif [[ $PLATFORM == 'darwin' ]]; then
-    curl -s https://paddle-inference-lib.bj.bcebos.com/mac/2.0.2/cpu_avx_openblas/paddle_inference.tgz -o paddle.tgz
+    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
     tar -xvzf paddle.tgz
     mv paddle_inference_install_dir paddle
   else
diff --git a/gradle.properties b/gradle.properties
index 23f45258e..511984dd5 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -14,8 +14,8 @@ tensorflow_version=2.7.0
 tflite_version=2.6.2
 dlr_version=1.6.0
 trt_version=8.0.1
-onnxruntime_version=1.10.0
-paddlepaddle_version=2.0.2
+onnxruntime_version=1.11.0
+paddlepaddle_version=2.2.2
 sentencepiece_version=0.1.95
 tokenizers_version=0.11.0
 fasttext_version=0.9.2


Test patch:
diff --git a/basicdataset/src/test/java/ai/djl/basicdataset/StanfordQuestionAnsweringDatasetTest.java b/basicdataset/src/test/java/ai/djl/basicdataset/StanfordQuestionAnsweringDatasetTest.java
index 0e4ae2b61..55f6f2837 100644
--- a/basicdataset/src/test/java/ai/djl/basicdataset/StanfordQuestionAnsweringDatasetTest.java
+++ b/basicdataset/src/test/java/ai/djl/basicdataset/StanfordQuestionAnsweringDatasetTest.java
@@ -122,13 +122,12 @@ public class StanfordQuestionAnsweringDatasetTest {
                                                     TestUtils.getTextEmbedding(
                                                             manager, EMBEDDING_SIZE)))
                             .setSampling(32, true)
-                            .optLimit(350)
                             .optUsage(Dataset.Usage.TEST)
                             .build();
 
             stanfordQuestionAnsweringDataset.prepare();
             stanfordQuestionAnsweringDataset.prepare();
-            Assert.assertEquals(stanfordQuestionAnsweringDataset.size(), 350);
+            Assert.assertEquals(stanfordQuestionAnsweringDataset.size(), 11873);
 
             Record record0 = stanfordQuestionAnsweringDataset.get(manager, 0);
             Record record6 = stanfordQuestionAnsweringDataset.get(manager, 6);