From fd669f16ce9e32c0894363e0e7a25b30fa1288e5 Mon Sep 17 00:00:00 2001 From: Frank Liu Date: Tue, 7 Feb 2023 20:18:01 -0800 Subject: [PATCH] [DLR] Remove Neo-dlr engine from DJL (#2373) --- .github/workflows/native_jni_s3_dlr.yml | 77 ------ bom/build.gradle | 3 - docs/development/cache_management.md | 1 - docs/development/dependency_management.md | 5 - .../inference_performance_optimization.md | 12 - docs/engine.md | 1 - docs/faq.md | 1 - docs/hybrid_engine.md | 4 - docs/mkdocs.yml | 1 - engines/dlr/README.md | 10 - engines/dlr/dlr-engine/README.md | 90 ------ engines/dlr/dlr-engine/build.gradle | 76 ------ engines/dlr/dlr-engine/gradlew | 1 - .../java/ai/djl/dlr/engine/DlrEngine.java | 108 -------- .../ai/djl/dlr/engine/DlrEngineProvider.java | 45 --- .../main/java/ai/djl/dlr/engine/DlrModel.java | 96 ------- .../java/ai/djl/dlr/engine/DlrNDArray.java | 69 ----- .../java/ai/djl/dlr/engine/DlrNDManager.java | 117 -------- .../java/ai/djl/dlr/engine/DlrPredictor.java | 50 ---- .../ai/djl/dlr/engine/DlrSymbolBlock.java | 86 ------ .../java/ai/djl/dlr/engine/package-info.java | 15 - .../main/java/ai/djl/dlr/jni/DlrLibrary.java | 52 ---- .../main/java/ai/djl/dlr/jni/JniUtils.java | 85 ------ .../main/java/ai/djl/dlr/jni/LibUtils.java | 256 ------------------ .../java/ai/djl/dlr/jni/package-info.java | 15 - .../main/java/ai/djl/dlr/zoo/DlrModelZoo.java | 45 --- .../java/ai/djl/dlr/zoo/DlrZooProvider.java | 26 -- .../java/ai/djl/dlr/zoo/package-info.java | 15 - .../dlr-engine/src/main/javadoc/overview.html | 14 - .../services/ai.djl.engine.EngineProvider | 1 - .../ai.djl.repository.zoo.ZooProvider | 1 - .../ai/djl/dlr/engine/DlrNDManagerTest.java | 54 ---- .../java/ai/djl/dlr/engine/package-info.java | 15 - .../java/ai/djl/dlr/integration/DlrTest.java | 75 ----- .../ai/djl/dlr/integration/package-info.java | 15 - .../ai/djl/dlr/resnet/metadata.json | 102 ------- engines/dlr/dlr-native/.gitignore | 2 - engines/dlr/dlr-native/CMakeLists.txt | 18 -- engines/dlr/dlr-native/README.md | 39 --- engines/dlr/dlr-native/build.gradle | 223 --------------- engines/dlr/dlr-native/build.sh | 31 --- engines/dlr/dlr-native/gradlew | 1 - .../main/native/ai_djl_dlr_jni_DlrLibrary.cc | 147 ---------- .../djl/paddlepaddle/engine/PpPredictor.java | 2 +- gradle.properties | 1 - integration/build.gradle | 2 - jacoco/build.gradle | 2 - serving/README.md | 2 +- settings.gradle | 2 - tools/gradle/publish.gradle | 1 - website/javadoc.html | 3 +- 51 files changed, 3 insertions(+), 2112 deletions(-) delete mode 100644 .github/workflows/native_jni_s3_dlr.yml delete mode 100644 engines/dlr/README.md delete mode 100644 engines/dlr/dlr-engine/README.md delete mode 100644 engines/dlr/dlr-engine/build.gradle delete mode 120000 engines/dlr/dlr-engine/gradlew delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrEngine.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrEngineProvider.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrModel.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrNDArray.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrNDManager.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrPredictor.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrSymbolBlock.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/package-info.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/DlrLibrary.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/JniUtils.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/LibUtils.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/package-info.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/zoo/DlrModelZoo.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/zoo/DlrZooProvider.java delete mode 100644 engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/zoo/package-info.java delete mode 100644 engines/dlr/dlr-engine/src/main/javadoc/overview.html delete mode 100644 engines/dlr/dlr-engine/src/main/resources/META-INF/services/ai.djl.engine.EngineProvider delete mode 100644 engines/dlr/dlr-engine/src/main/resources/META-INF/services/ai.djl.repository.zoo.ZooProvider delete mode 100644 engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/engine/DlrNDManagerTest.java delete mode 100644 engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/engine/package-info.java delete mode 100644 engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/integration/DlrTest.java delete mode 100644 engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/integration/package-info.java delete mode 100644 engines/dlr/dlr-engine/src/test/resources/mlrepo/model/cv/image_classification/ai/djl/dlr/resnet/metadata.json delete mode 100644 engines/dlr/dlr-native/.gitignore delete mode 100644 engines/dlr/dlr-native/CMakeLists.txt delete mode 100644 engines/dlr/dlr-native/README.md delete mode 100644 engines/dlr/dlr-native/build.gradle delete mode 100755 engines/dlr/dlr-native/build.sh delete mode 120000 engines/dlr/dlr-native/gradlew delete mode 100644 engines/dlr/dlr-native/src/main/native/ai_djl_dlr_jni_DlrLibrary.cc diff --git a/.github/workflows/native_jni_s3_dlr.yml b/.github/workflows/native_jni_s3_dlr.yml deleted file mode 100644 index 29c9e46464c..00000000000 --- a/.github/workflows/native_jni_s3_dlr.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: Native JNI S3 DLR - -on: - workflow_dispatch: - -jobs: - build-dlr-jni-cpu: - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - distribution: 'corretto' - java-version: 11 - - uses: actions/cache@v3 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Release JNI prep - run: ./gradlew :engines:dlr:dlr-native:compileJNI - - name: Run test - run: ./gradlew :engines:dlr:dlr-engine:test -Pjni - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1-node16 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-2 - - name: Copy files to S3 with the AWS CLI - run: | - DLR_VERSION="$(cat gradle.properties | awk -F '=' '/dlr_version/ {print $2}')" - DJL_VERSION="$(cat gradle.properties | awk -F '=' '/djl_version/ {print $2}')" - aws s3 cp engines/dlr/dlr-native/build/*djl_dlr* s3://djl-ai/publish/dlr-${DLR_VERSION}/jnilib/${DJL_VERSION}/osx-x86_64/ - aws cloudfront create-invalidation --distribution-id E371VB8JQ6NRVY --paths "/dlr-${DLR_VERSION}/jnilib*" - - build-dlr-jni-linux-cpu: - runs-on: ubuntu-latest - container: amazonlinux:2 - steps: - - name: Install Environment - run: | - yum -y update - yum -y groupinstall "Development Tools" - yum -y install patch cmake3 - ln -sf /usr/bin/cmake3 /usr/bin/cmake - pip3 install awscli --upgrade - - uses: actions/checkout@v3 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - distribution: 'corretto' - java-version: 11 - - uses: actions/cache@v3 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Release JNI prep - run: | - ./gradlew :engines:dlr:dlr-native:compileJNI - ./gradlew -Pjni :engines:dlr:dlr-engine:test - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1-node16 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-2 - - name: Copy files to S3 with the AWS CLI - run: | - DLR_VERSION="$(cat gradle.properties | awk -F '=' '/dlr_version/ {print $2}')" - DJL_VERSION="$(cat gradle.properties | awk -F '=' '/djl_version/ {print $2}')" - aws s3 cp engines/dlr/dlr-native/build/*djl_dlr* s3://djl-ai/publish/dlr-${DLR_VERSION}/jnilib/${DJL_VERSION}/linux-x86_64/ - aws cloudfront create-invalidation --distribution-id E371VB8JQ6NRVY --paths "/dlr-${DLR_VERSION}/jnilib*" diff --git a/bom/build.gradle b/bom/build.gradle index 0383116bd98..3ccf27526d4 100644 --- a/bom/build.gradle +++ b/bom/build.gradle @@ -24,7 +24,6 @@ dependencies { api "ai.djl.android:pytorch-native:${version}" api "ai.djl.aws:aws-ai:${version}" api "ai.djl.audio:audio:${version}" - api "ai.djl.dlr:dlr-engine:${version}" api "ai.djl.fasttext:fasttext-engine:${version}" api "ai.djl.hadoop:hadoop:${version}" api "ai.djl.huggingface:tokenizers:${version}" @@ -130,8 +129,6 @@ publishing { addDependency(dependencies, "ai.djl.paddlepaddle", "paddlepaddle-native-cu102", "linux-x86_64", "${paddlepaddle_version}") addDependency(dependencies, "ai.djl.paddlepaddle", "paddlepaddle-native-cu112", "linux-x86_64", "${paddlepaddle_version}") addDependency(dependencies, "ai.djl.paddlepaddle", "paddlepaddle-native-cu110", "win-x86_64", "${paddlepaddle_version}") - addDependency(dependencies, "ai.djl.dlr", "dlr-native-cpu", "osx-x86_64", "${dlr_version}") - addDependency(dependencies, "ai.djl.dlr", "dlr-native-cpu", "linux-x86_64", "${dlr_version}") addDependency(dependencies, "ai.djl.tflite", "tflite-native-cpu", "osx-x86_64", "${tflite_version}") addDependency(dependencies, "ai.djl.tflite", "tflite-native-cpu", "linux-x86_64", "${tflite_version}") } diff --git a/docs/development/cache_management.md b/docs/development/cache_management.md index f918ae870f7..61f7289adf5 100644 --- a/docs/development/cache_management.md +++ b/docs/development/cache_management.md @@ -7,7 +7,6 @@ By default, cache directories are located at current user's home directory: - `.djl.ai/mxnet` is the default cache directory stores Apache MXNet engine native libraries - `.djl.ai/pytorch` is the default cache directory stores Pytorch engine native libraries - `.djl.ai/tensorflow` is the default cache directory stores TensorFlow engine native libraries -- `.djl.ai/dlr` is the default cache directory stores Neo DLR engine native libraries - `.djl.ai/fasttext` is the default cache directory stores fastText native libraries - `.djl.ai/sentencepiece` is the default cache directory stores Sentencepiece native libraries diff --git a/docs/development/dependency_management.md b/docs/development/dependency_management.md index 62dbb9315a6..271d5027083 100644 --- a/docs/development/dependency_management.md +++ b/docs/development/dependency_management.md @@ -110,11 +110,6 @@ See [How to use DJL's BOM](../../bom/README.md#how-to-use-djls-bom) for detail. | | onnxruntime-native-auto(deprecated) | Please use com.microsoft.onnxruntime:onnxruntime instead | | | onnxruntime-native-cpu(deprecated) | Please use com.microsoft.onnxruntime:onnxruntime instead | | | | | -| [ai.djl.dlr](https://search.maven.org/search?q=g:ai.djl.dlr) | [dlr-engine](../../engines/dlr/dlr-engine/README.md#installation) | Neo DLR engine adapter | -| | [dlr-native-cpu(osx-x86_64)](../../engines/dlr/dlr-engine/README.md#macos) | Contains Neo LR native library for macOS | -| | [dlr-native-cpu(linux-x86_64)](../../engines/dlr/dlr-engine/README.md#linux) | Contains Neo DLR native library for Linux | -| | dlr-native-auto (deprecated) | No longer needed since DJL 0.15.0 | -| | | | | [ai.djl.tflite](https://search.maven.org/search?q=g:ai.djl.tflite) | [tflite-engine](../../engines/tflite/tflite-engine/README.md#installation) | TensorFlow Lite engine adapter | | | [tflite-native-cpu(osx-x86_64)](../../engines/tflite/tflite-engine/README.md#macos) | Contains TensorFlow Lite native library for macOS | | | [tflite-native-cpu(linux-x86_64)](../../engines/tflite/tflite-engine/README.md#linux) | Contains TensorFlow Lite native library for Linux | diff --git a/docs/development/inference_performance_optimization.md b/docs/development/inference_performance_optimization.md index a3449d30f4c..568df164af0 100644 --- a/docs/development/inference_performance_optimization.md +++ b/docs/development/inference_performance_optimization.md @@ -136,18 +136,6 @@ export TF_NUM_INTEROP_THREADS=1 export TF_NUM_INTRAOP_THREADS=1 ``` -### DLR(Experimental) - -#### Multithreading Inference(Experimental) -DLR(TVM) itself doesn't support multithreading. The most obvious reason is that in the implementation of forward(), it is require to setInputs, runInference followed by getOutputs. -As a result, we create a new TVM model when we call newPredictor() and free the model when you call Predictor.close(). -Please make sure to create a new Predictor in each thread. - -TVM internally leverages full hardware resource. Based on our experiment, setting TVM_NUM_THREADS to 1 get best throughput as it avoids resource contention. -```bash -export TVM_NUM_THREADS=1 -``` - ### ONNXRuntime #### Thread configuration diff --git a/docs/engine.md b/docs/engine.md index 59af022cb0b..20333c50565 100644 --- a/docs/engine.md +++ b/docs/engine.md @@ -34,7 +34,6 @@ Currently, the engines that are supported by DJL are: - [TensorRT](../engines/tensorrt/README.md) - supports basic inference - [XGBoost](../engines/ml/xgboost/README.md) - supports basic inference - [LightGBM](../engines/ml/lightgbm/README.md) - supports basic inference -- [DLR](../engines/dlr/README.md) - supports basic inference ## Setup diff --git a/docs/faq.md b/docs/faq.md index fc121d5f901..be96d55f737 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -22,7 +22,6 @@ support the following models: - Python script model - PaddlePaddle model - TFLite model -- Neo DLR (TVM) model - XGBoost model - LightGBM model - Sentencepiece model diff --git a/docs/hybrid_engine.md b/docs/hybrid_engine.md index 5abbe4d3f01..dfd652d7ff6 100644 --- a/docs/hybrid_engine.md +++ b/docs/hybrid_engine.md @@ -8,7 +8,6 @@ Many of DJL engines only has limited support for NDArray operations. Here is a l - [PaddlePaddle](../engines/paddlepaddle/README.md) - [TFLite](../engines/tflite/tflite-engine/README.md) - [TensorRT](../engines/tensorrt/README.md) -- [DLR](../engines/dlr/README.md) Currently, those engines only covers the basic NDArray creation methods. To better support the necessary preprocessing and postprocessing, you can use one of the full Engines along with it @@ -55,9 +54,6 @@ System.setProperty("ai.djl.tflite.disable_alternative", "true"); # disable hybrid engine for TensorRT System.setProperty("ai.djl.tensorrt.disable_alternative", "true"); - -# disable hybrid engine for Neo DLR -System.setProperty("ai.djl.dlr.disable_alternative", "false"); ``` diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index d02c1b6611d..b0c1910079c 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -132,7 +132,6 @@ nav: - LightGBM: 'engines/ml/lightgbm/README.md' - TensorRT: 'engines/tensorrt/README.md' - TensorFlow Lite: 'engines/tflite/tflite-engine/README.md' - - Neo DLR: 'engines/dlr/dlr-engine/README.md' - Extensions: - Android: 'android/README.md' - AWS S3 support: 'extensions/aws-ai/README.md' diff --git a/engines/dlr/README.md b/engines/dlr/README.md deleted file mode 100644 index d247f79b592..00000000000 --- a/engines/dlr/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# DLR Engine(Experimental) - -This directory contains the Deep Java Library (DJL) EngineProvider for Neo DLR. - -It is based off the [Neo-ai/neo-ai-dlr](https://github.com/neo-ai/neo-ai-dlr). - -## Modules - -- [DLR Engine](dlr-engine/README.md) - The DJL implementation for DLR Engine -- [DLR native library](dlr-native/README.md) - A utility module for building the dlr-native jars containing the native binaries diff --git a/engines/dlr/dlr-engine/README.md b/engines/dlr/dlr-engine/README.md deleted file mode 100644 index 62da6757470..00000000000 --- a/engines/dlr/dlr-engine/README.md +++ /dev/null @@ -1,90 +0,0 @@ -# DJL - DLR engine implementation(Experimental) - -## Overview -This module contains the Deep Java Library (DJL) EngineProvider for DLR. - -It is based off the [Neo DLR](https://github.com/neo-ai/neo-ai-dlr). - - -We don't recommend developers use classes within this module directly. -Use of these classes will couple your code to the DLR and make switching between engines difficult. - -DLR is a DL library with limited support for NDArray operations. -Currently, it only covers the basic NDArray creation methods. To better support the necessary preprocessing and postprocessing, -you can use one of the other Engine along with it to run in a hybrid mode. -For more information, see [Hybrid Engine](../../../docs/hybrid_engine.md). - -## Documentation - -The latest javadocs can be found on [here](https://javadoc.io/doc/ai.djl.dlr/dlr-engine/latest/index.html). - -You can also build the latest javadocs locally using the following command: - -```sh -# for Linux/macOS: -./gradlew javadoc -``` -The javadocs output is generated in the `build/doc/javadoc` folder. - -## Installation -You can pull the DLR engine from the central Maven repository by including the following dependency: - -- ai.djl.dlr:dlr-engine:0.20.0 - -```xml - - ai.djl.dlr - dlr-engine - 0.20.0 - runtime - -``` - -By default, DJL will download the DLR native libraries into [cache folder](../../../docs/development/cache_management.md) the first time you run DJL. -It will automatically determine the appropriate jars for your system based on the platform and GPU support. - -You can choose a native library based on your platform if you don't have network access at runtime. - -### macOS -For macOS, you can use the following library: - -- ai.djl.dlr:dlr-native-cpu:1.6.0:osx-x86_64 - -```xml - - ai.djl.dlr - dlr-native-cpu - 1.6.0 - runtime - osx-x86_64 - -``` - -### Linux -For Linux, you can use the following library: - -- ai.djl.dlr:dlr-native-cpu:1.6.0:linux-x86_64 - -```xml - - ai.djl.dlr - dlr-native-cpu - 1.6.0 - runtime - linux-x86_64 - -``` - -## Load your own custom dlr -You can use environment variable to specify your custom dlr by - -``` -export DLR_LIBRARY_PATH=path/to/your/dlr -``` - -## Platform Limitation -DLR engine is still under development. The supported platform are limited to Macosx, Linux CPU. If you would like to use other platforms, please let us know. - -# Multi-threading Capabilities -TVM runtime itself doesn't support multi-threading. As a result, when creating a new Predictor, we will copy the tvm model to avoid sharing the states. -We are still actively testing multithreading capability. diff --git a/engines/dlr/dlr-engine/build.gradle b/engines/dlr/dlr-engine/build.gradle deleted file mode 100644 index 45fe1852cdb..00000000000 --- a/engines/dlr/dlr-engine/build.gradle +++ /dev/null @@ -1,76 +0,0 @@ -group "ai.djl.dlr" - -dependencies { - api project(":api") - - testImplementation(project(":testing")) - testImplementation("org.testng:testng:${testng_version}") { - exclude group: "junit", module: "junit" - } - testImplementation "org.slf4j:slf4j-simple:${slf4j_version}" - testRuntimeOnly project(":engines:pytorch:pytorch-engine") - testRuntimeOnly project(":engines:pytorch:pytorch-jni") -} - -compileJava.dependsOn(processResources) - -processResources { - outputs.dir file("${project.buildDir}/classes/java/main/jnilib") - doLast { - def url = "https://publish.djl.ai/dlr-${dlr_version}/jnilib/${djl_version}" - def files = [ - "osx-x86_64/libdjl_dlr.dylib": "osx-x86_64/libdjl_dlr.dylib", - "linux-x86_64/libdjl_dlr.so" : "linux-x86_64/libdjl_dlr.so" - ] - def jnilibDir = "${project.projectDir}/jnilib/${djl_version}" - files.each { entry -> - def file = new File("${jnilibDir}/${entry.value}") - if (file.exists()) { - project.logger.lifecycle("prebuilt or cached file found for ${entry.value}") - } else { - def nativeDir = "${project.parent.projectDir}/dlr-native/jnilib/${djl_version}/" - def jnilibFile = new File("${nativeDir}/${entry.value}") - if (jnilibFile.exists()) { - project.logger.lifecycle("Copying " + jnilibFile) - copy { - from jnilibFile - into file.getParent() - } - } else if (!project.hasProperty("jni")) { - project.logger.lifecycle("Downloading ${url}/${entry.key}") - file.getParentFile().mkdirs() - new URL("${url}/${entry.key}").withInputStream { i -> file.withOutputStream { it << i } } - } - } - } - copy { - from jnilibDir - into "${project.buildDir}/classes/java/main/jnilib" - } - - // write properties - def propFile = file("${project.buildDir}/classes/java/main/dlr-engine.properties") - propFile.text = "djl_version=${version}\ndlr_version=${dlr_version}" - } -} - -test { - environment "PATH", "src/test/bin:${environment.PATH}" -} - -publishing { - publications { - maven(MavenPublication) { - artifactId "dlr-engine" - pom { - name = "DJL Engine Adapter for DLR" - description = "Deep Java Library (DJL) Engine Adapter for DLR" - url = "http://www.djl.ai/engines/dlr/${project.name}" - } - } - } -} - -clean.doFirst { - delete System.getProperty("user.home") + "/.djl.ai/dlr" -} diff --git a/engines/dlr/dlr-engine/gradlew b/engines/dlr/dlr-engine/gradlew deleted file mode 120000 index ab9334b002e..00000000000 --- a/engines/dlr/dlr-engine/gradlew +++ /dev/null @@ -1 +0,0 @@ -../../../gradlew \ No newline at end of file diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrEngine.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrEngine.java deleted file mode 100644 index 727bed9cf77..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrEngine.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl.dlr.engine; - -import ai.djl.Device; -import ai.djl.Model; -import ai.djl.dlr.jni.JniUtils; -import ai.djl.dlr.jni.LibUtils; -import ai.djl.engine.Engine; -import ai.djl.engine.EngineException; -import ai.djl.ndarray.NDManager; - -/** - * The {@code DlrEngine} is an implementation of the {@link Engine} based on the Neo DLR. - * - *

To get an instance of the {@code DlrEngine} when it is not the default Engine, call {@link - * Engine#getEngine(String)} with the Engine name "DLR". - */ -public final class DlrEngine extends Engine { - - public static final String ENGINE_NAME = "DLR"; - static final int RANK = 10; - - private Engine alternativeEngine; - private boolean initialized; - - private DlrEngine() {} - - static Engine newInstance() { - try { - LibUtils.loadLibrary(); - return new DlrEngine(); - } catch (Throwable t) { - throw new EngineException("Failed to load DLR native library", t); - } - } - - /** {@inheritDoc} */ - @Override - public Engine getAlternativeEngine() { - if (!initialized && !Boolean.getBoolean("ai.djl.dlr.disable_alternative")) { - Engine engine = Engine.getInstance(); - if (engine.getRank() < getRank()) { - // alternativeEngine should not have the same rank as DLR - alternativeEngine = engine; - } - initialized = true; - } - return alternativeEngine; - } - - /** {@inheritDoc} */ - @Override - public String getEngineName() { - return ENGINE_NAME; - } - - /** {@inheritDoc} */ - @Override - public int getRank() { - return RANK; - } - - /** {@inheritDoc} */ - @Override - public String getVersion() { - return JniUtils.getDlrVersion(); - } - - /** {@inheritDoc} */ - @Override - public boolean hasCapability(String capability) { - return false; - } - - /** {@inheritDoc} */ - @Override - public Model newModel(String name, Device device) { - // Only support CPU for now - if (device != null && device != Device.cpu()) { - throw new IllegalArgumentException("DLR only support CPU"); - } - return new DlrModel(name, newBaseManager(Device.cpu())); - } - - /** {@inheritDoc} */ - @Override - public NDManager newBaseManager() { - return newBaseManager(null); - } - - /** {@inheritDoc} */ - @Override - public NDManager newBaseManager(Device device) { - return DlrNDManager.getSystemManager().newSubManager(device); - } -} diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrEngineProvider.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrEngineProvider.java deleted file mode 100644 index f23d235bb0e..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrEngineProvider.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl.dlr.engine; - -import ai.djl.engine.Engine; -import ai.djl.engine.EngineProvider; - -/** {@code DlrEngineProvider} is the DLR implementation of {@link EngineProvider}. */ -public class DlrEngineProvider implements EngineProvider { - - private static volatile Engine engine; // NOPMD - - /** {@inheritDoc} */ - @Override - public String getEngineName() { - return DlrEngine.ENGINE_NAME; - } - - /** {@inheritDoc} */ - @Override - public int getEngineRank() { - return DlrEngine.RANK; - } - - /** {@inheritDoc} */ - @Override - public Engine getEngine() { - if (engine == null) { - synchronized (this) { - engine = DlrEngine.newInstance(); - } - } - return engine; - } -} diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrModel.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrModel.java deleted file mode 100644 index 6bf824f662b..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrModel.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl.dlr.engine; - -import ai.djl.BaseModel; -import ai.djl.Device; -import ai.djl.Model; -import ai.djl.inference.Predictor; -import ai.djl.ndarray.NDManager; -import ai.djl.ndarray.types.DataType; -import ai.djl.translate.Translator; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Map; - -/** - * {@code DlrModel} is the DLR implementation of {@link Model}. - * - *

OrtModel contains all the methods in Model to load and process a model. In addition, it - * provides DLR Specific functionality - */ -public class DlrModel extends BaseModel { - - /** - * Constructs a new Model on a given device. - * - * @param name the model name - * @param manager the {@link NDManager} to holds the NDArray - */ - DlrModel(String name, NDManager manager) { - super(name); - this.manager = manager; - this.manager.setName("dlrModel"); - // DLR only support float32 - dataType = DataType.FLOAT32; - } - - /** {@inheritDoc} */ - @Override - public void load(Path modelPath, String prefix, Map options) throws IOException { - setModelDir(modelPath); - if (prefix == null) { - prefix = modelName; - } - if (block != null) { - throw new UnsupportedOperationException("DLR does not support dynamic blocks"); - } - checkModelFiles(prefix); - } - - /** {@inheritDoc} */ - @Override - public Predictor newPredictor(Translator translator, Device device) { - return new DlrPredictor<>(this, modelDir.toString(), device, translator); - } - - private void checkModelFiles(String prefix) throws IOException { - String libExt; - String os = System.getProperty("os.name").toLowerCase(); - if (os.startsWith("mac")) { - libExt = ".dylib"; - } else if (os.startsWith("linux")) { - libExt = ".so"; - } else if (os.startsWith("win")) { - libExt = ".dll"; - } else { - throw new IllegalStateException("found unsupported os"); - } - // TODO make the check platform independent - Path module = modelDir.resolve(prefix + libExt); - if (Files.notExists(module) || !Files.isRegularFile(module)) { - throw new FileNotFoundException("module file(.so/.dylib/.dll) is missing"); - } - Path params = modelDir.resolve(prefix + ".params"); - if (Files.notExists(params) || !Files.isRegularFile(module)) { - throw new FileNotFoundException("params file(.params) is missing"); - } - Path graph = modelDir.resolve(prefix + ".json"); - if (Files.notExists(graph) || !Files.isRegularFile(graph)) { - throw new FileNotFoundException("graph file(.json) is missing"); - } - } -} diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrNDArray.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrNDArray.java deleted file mode 100644 index f9928fa9df4..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrNDArray.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl.dlr.engine; - -import ai.djl.ndarray.NDArray; -import ai.djl.ndarray.NDArrayAdapter; -import ai.djl.ndarray.NDManager; -import ai.djl.ndarray.types.DataType; -import ai.djl.ndarray.types.Shape; - -import java.nio.ByteBuffer; -import java.util.UUID; - -/** {@code DlrNDArray} is the DLR implementation of {@link NDArray}. */ -public class DlrNDArray extends NDArrayAdapter { - - private ByteBuffer data; - - /** - * Constructs an DLR NDArray from a {@link DlrNDManager} (internal. Use {@link NDManager} - * instead). - * - * @param manager the manager to attach the new array to - * @param alternativeManager the alternative manager to execute unsupported operation - * @param data the underlying data - * @param shape the shape of {@code DlrNDArray} - * @param dataType the {@link DataType} of the {@link NDArray} - */ - DlrNDArray( - DlrNDManager manager, - NDManager alternativeManager, - ByteBuffer data, - Shape shape, - DataType dataType) { - super(manager, alternativeManager, shape, dataType, UUID.randomUUID().toString()); - this.data = data; - manager.attachInternal(uid, this); - } - - /** {@inheritDoc} */ - @Override - public void intern(NDArray replaced) { - this.data = ((DlrNDArray) replaced).data; - } - - /** {@inheritDoc} */ - @Override - public void detach() { - manager.detachInternal(getUid()); - manager = DlrNDManager.getSystemManager(); - } - - /** {@inheritDoc} */ - @Override - public ByteBuffer toByteBuffer() { - data.rewind(); - return data; - } -} diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrNDManager.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrNDManager.java deleted file mode 100644 index 4a0e1bcf220..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrNDManager.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl.dlr.engine; - -import ai.djl.Device; -import ai.djl.engine.Engine; -import ai.djl.ndarray.BaseNDManager; -import ai.djl.ndarray.NDArray; -import ai.djl.ndarray.NDManager; -import ai.djl.ndarray.types.DataType; -import ai.djl.ndarray.types.Shape; - -import java.nio.Buffer; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.FloatBuffer; - -/** {@code DlrNDManager} is the DLR implementation of {@link NDManager}. */ -public class DlrNDManager extends BaseNDManager { - - private static final DlrNDManager SYSTEM_MANAGER = new SystemManager(); - - private DlrNDManager(NDManager parent, Device device) { - super(parent, device); - } - - static DlrNDManager getSystemManager() { - return SYSTEM_MANAGER; - } - - /** {@inheritDoc} */ - @Override - public final Engine getEngine() { - return Engine.getEngine(DlrEngine.ENGINE_NAME); - } - - /** {@inheritDoc} */ - @Override - public ByteBuffer allocateDirect(int capacity) { - return ByteBuffer.allocateDirect(capacity).order(ByteOrder.nativeOrder()); - } - - /** {@inheritDoc} */ - @Override - public DlrNDArray from(NDArray array) { - if (array == null || array instanceof DlrNDArray) { - return (DlrNDArray) array; - } - DlrNDArray result = - (DlrNDArray) create(array.toByteBuffer(), array.getShape(), array.getDataType()); - result.setName(array.getName()); - return result; - } - - /** {@inheritDoc} */ - @Override - public DlrNDManager newSubManager(Device dev) { - DlrNDManager manager = new DlrNDManager(this, dev); - attachInternal(manager.uid, manager); - return manager; - } - - /** {@inheritDoc} */ - @Override - public NDArray create(Buffer data, Shape shape, DataType dataType) { - if (dataType != DataType.FLOAT32) { - if (data instanceof ByteBuffer) { - return new DlrNDArray(this, alternativeManager, (ByteBuffer) data, shape, dataType); - } - if (alternativeManager != null) { - return alternativeManager.create(data, shape, dataType); - } - throw new UnsupportedOperationException("DlrNDArray only supports float32."); - } - int size = Math.toIntExact(shape.size()); - BaseNDManager.validateBuffer(data, dataType, size); - if (data instanceof ByteBuffer) { - return new DlrNDArray(this, alternativeManager, (ByteBuffer) data, shape, dataType); - } - ByteBuffer bb = ByteBuffer.allocate(size * dataType.getNumOfBytes()); - bb.asFloatBuffer().put((FloatBuffer) data); - bb.rewind(); - return new DlrNDArray(this, alternativeManager, bb, shape, dataType); - } - - /** {@inheritDoc} */ - @Override - public void close() { - super.close(); - if (alternativeManager != null) { - alternativeManager.close(); - alternativeManager = null; - } - } - - /** The SystemManager is the root {@link DlrNDManager} of which all others are children. */ - private static final class SystemManager extends DlrNDManager implements SystemNDManager { - - SystemManager() { - super(null, null); - } - - /** {@inheritDoc} */ - @Override - public void close() {} - } -} diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrPredictor.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrPredictor.java deleted file mode 100644 index 4a332fcc246..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrPredictor.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl.dlr.engine; - -import ai.djl.Device; -import ai.djl.dlr.jni.JniUtils; -import ai.djl.inference.Predictor; -import ai.djl.translate.Translator; - -/** - * {@code DlrPredictor} is special implementation of {@link Predictor} for DLR. - * - *

The native Dlr doesn't support multi-threading feature, when creating a new DlrPredictor, we - * copy the Dlr model handle to workaround the issue. - */ -public class DlrPredictor extends Predictor { - /** - * Creates a new instance of {@code DlrPredictor}. - * - * @param model the model on which the predictions are based - * @param modelDir the path to the model artifacts - * @param device the device that the model use - * @param translator the translator to be used - */ - public DlrPredictor( - DlrModel model, String modelDir, Device device, Translator translator) { - super(model, translator, device, false); - long modelHandle = JniUtils.createDlrModel(modelDir, device); - block = new DlrSymbolBlock((DlrNDManager) manager, modelHandle); - // disable cpu affinity by default - JniUtils.useDlrCpuAffinity(modelHandle, false); - } - - /** {@inheritDoc} */ - @Override - public void close() { - super.close(); - ((DlrSymbolBlock) block).close(); - } -} diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrSymbolBlock.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrSymbolBlock.java deleted file mode 100644 index 066bafbc284..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/DlrSymbolBlock.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ - -package ai.djl.dlr.engine; - -import ai.djl.dlr.jni.JniUtils; -import ai.djl.ndarray.NDList; -import ai.djl.nn.AbstractSymbolBlock; -import ai.djl.nn.ParameterList; -import ai.djl.nn.SymbolBlock; -import ai.djl.training.ParameterStore; -import ai.djl.util.PairList; - -import java.util.concurrent.atomic.AtomicReference; - -/** - * {@code DlrSymbolBlock} is the DLR implementation of {@link SymbolBlock}. - * - *

You can create a {@code DlrSymbolBlock} using {@link ai.djl.Model#load(java.nio.file.Path, - * String)}. - */ -public class DlrSymbolBlock extends AbstractSymbolBlock implements AutoCloseable { - - private AtomicReference handle; - private DlrNDManager manager; - - /** - * Constructs a {@code DlrSymbolBlock}. - * - *

You can create a {@code DlrSymbolBlock} using {@link ai.djl.Model#load(java.nio.file.Path, - * String)}. - * - * @param manager the manager to use for the block - * @param handle the handle for native DLR model - */ - public DlrSymbolBlock(DlrNDManager manager, long handle) { - this.handle = new AtomicReference<>(handle); - this.manager = manager; - } - - /** {@inheritDoc} */ - @Override - protected NDList forwardInternal( - ParameterStore parameterStore, - NDList inputs, - boolean training, - PairList params) { - long modelHandle = handle.get(); - // TODO maybe verify the number of inputs - // currently we assume the order of the input NDList is the same - // as the model input - try (DlrNDManager sub = (DlrNDManager) manager.newSubManager()) { - for (int i = 0; i < inputs.size(); ++i) { - DlrNDArray array = sub.from(inputs.get(i)); - JniUtils.setDlrInput(modelHandle, array, i); - } - } - JniUtils.runDlrModel(modelHandle); - return JniUtils.getDlrOutputs(modelHandle, inputs.head().getManager()); - } - - /** {@inheritDoc} */ - @Override - public void close() { - Long pointer = handle.getAndSet(null); - if (pointer != null) { - JniUtils.deleteDlrModel(pointer); - } - } - - /** {@inheritDoc} */ - @Override - public ParameterList getDirectParameters() { - throw new UnsupportedOperationException("Not yet supported"); - } -} diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/package-info.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/package-info.java deleted file mode 100644 index 67a09dc4ae5..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/engine/package-info.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ - -/** Contains classes to interface with the underlying DLR Engine. */ -package ai.djl.dlr.engine; diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/DlrLibrary.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/DlrLibrary.java deleted file mode 100644 index 33ac3551877..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/DlrLibrary.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl.dlr.jni; - -/** A class containing utilities to interact with the DLR Engine's JNI layer. */ -@SuppressWarnings("MissingJavadocMethod") -final class DlrLibrary { - - static final DlrLibrary LIB = new DlrLibrary(); - - private DlrLibrary() {} - - native int getDlrNumInputs(long handle); - - native int getDlrNumWeights(long handle); - - native String getDlrInputName(long handle, int index); - - native String getDlrWeightName(long handle, int index); - - native void setDLRInput(long handle, String name, long[] shape, float[] input, int dim); - - native long[] getDlrOutputShape(long handle, int index); - - native float[] getDlrOutput(long handle, int index); - - native int getDlrNumOutputs(long handle); - - native long createDlrModel(String modelPath, int deviceType, int deviceId); - - native void deleteDlrModel(long handle); - - native void runDlrModel(long handle); - - native String getDlrBackend(long handle); - - native String getDlrVersion(); - - native void setDlrNumThreads(long handle, int threads); - - native void useDlrCPUAffinity(long handle, boolean use); -} diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/JniUtils.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/JniUtils.java deleted file mode 100644 index 531a85d228a..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/JniUtils.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl.dlr.jni; - -import ai.djl.Device; -import ai.djl.dlr.engine.DlrNDArray; -import ai.djl.ndarray.NDList; -import ai.djl.ndarray.NDManager; -import ai.djl.ndarray.types.Shape; - -/** - * A class containing utilities to interact with the PyTorch Engine's Java Native Interface (JNI) - * layer. - */ -@SuppressWarnings("MissingJavadocMethod") -public final class JniUtils { - - private JniUtils() {} - - public static void setDlrInput(long modelHandle, DlrNDArray input, int index) { - long[] shape = input.getShape().getShape(); - float[] data = input.toFloatArray(); - String name = DlrLibrary.LIB.getDlrInputName(modelHandle, index); - DlrLibrary.LIB.setDLRInput(modelHandle, name, shape, data, shape.length); - } - - public static NDList getDlrOutputs(long modelHandle, NDManager manager) { - int numOutputs = DlrLibrary.LIB.getDlrNumOutputs(modelHandle); - NDList res = new NDList(numOutputs); - for (int i = 0; i < numOutputs; i++) { - float[] data = DlrLibrary.LIB.getDlrOutput(modelHandle, i); - long[] shape = DlrLibrary.LIB.getDlrOutputShape(modelHandle, i); - res.add(manager.create(data, new Shape(shape))); - } - return res; - } - - public static long createDlrModel(String path, Device device) { - int deviceId = 0; - if (!device.equals(Device.cpu())) { - deviceId = device.getDeviceId(); - } - return DlrLibrary.LIB.createDlrModel(path, mapDevice(device.getDeviceType()), deviceId); - } - - public static void deleteDlrModel(long modelHandle) { - DlrLibrary.LIB.deleteDlrModel(modelHandle); - } - - public static void runDlrModel(long modelHandle) { - DlrLibrary.LIB.runDlrModel(modelHandle); - } - - public static void setDlrNumThreads(long modelHandle, int threads) { - DlrLibrary.LIB.setDlrNumThreads(modelHandle, threads); - } - - public static void useDlrCpuAffinity(long modelHandle, boolean use) { - DlrLibrary.LIB.useDlrCPUAffinity(modelHandle, use); - } - - public static String getDlrVersion() { - return DlrLibrary.LIB.getDlrVersion(); - } - - private static int mapDevice(String deviceType) { - if (Device.Type.CPU.equals(deviceType)) { - return 1; - } else if (Device.Type.GPU.equals(deviceType)) { - return 2; - } else { - throw new IllegalArgumentException("The device " + deviceType + " is not supported"); - } - } -} diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/LibUtils.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/LibUtils.java deleted file mode 100644 index f19da826128..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/LibUtils.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl.dlr.jni; - -import ai.djl.util.ClassLoaderUtils; -import ai.djl.util.Platform; -import ai.djl.util.Utils; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.Collections; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Utilities for finding the DLR Engine binary on the System. - * - *

The Engine will be searched for in a variety of locations in the following order: - * - *

    - *
  1. In the path specified by the DLR_LIBRARY_PATH environment variable - *
- */ -@SuppressWarnings("MissingJavadocMethod") -public final class LibUtils { - - private static final Logger logger = LoggerFactory.getLogger(LibUtils.class); - - private static final String LIB_NAME = "djl_dlr"; - private static final String NATIVE_LIB_NAME = "dlr"; - - private static final Pattern VERSION_PATTERN = - Pattern.compile("(\\d+\\.\\d+\\.\\d+(-[a-z]+)?)(-SNAPSHOT)?(-\\d+)?"); - - private LibUtils() {} - - public static void loadLibrary() { - String libName = findNativeOverrideLibrary(); - if (libName == null) { - libName = findNativeLibrary(); - if (libName == null) { - throw new IllegalStateException("Native library not found"); - } - } - - Path nativeLibDir = Paths.get(libName).getParent(); - if (nativeLibDir == null || !nativeLibDir.toFile().isDirectory()) { - throw new IllegalStateException("Native folder cannot be found"); - } - String jniPath = copyJniLibraryFromClasspath(nativeLibDir); - System.load(libName); // NOPMD - logger.debug("Loading DLR native library from: {}", libName); - System.load(jniPath); // NOPMD - logger.debug("Loading DLR JNI library from: {}", jniPath); - } - - private static synchronized String findNativeLibrary() { - Platform platform = Platform.detectPlatform("dlr"); - if (platform.isPlaceholder()) { - return downloadDlr(platform); - } - return copyNativeLibraryFromClasspath(platform); - } - - private static String copyNativeLibraryFromClasspath(Platform platform) { - Path tmp = null; - try { - String libName = System.mapLibraryName(NATIVE_LIB_NAME); - Path cacheDir = getCacheDir(platform); - Path path = cacheDir.resolve(libName); - if (Files.exists(path)) { - return path.toAbsolutePath().toString(); - } - - Path dlrCacheRoot = Utils.getEngineCacheDir("dlr"); - Files.createDirectories(dlrCacheRoot); - tmp = Files.createTempDirectory(dlrCacheRoot, "tmp"); - for (String file : platform.getLibraries()) { - String libPath = "native/lib/" + file; - logger.info("Extracting {} to cache ...", libPath); - try (InputStream is = ClassLoaderUtils.getResourceAsStream(libPath)) { - Files.copy(is, tmp.resolve(file), StandardCopyOption.REPLACE_EXISTING); - } - } - - Utils.moveQuietly(tmp, cacheDir); - return path.toAbsolutePath().toString(); - } catch (IOException e) { - throw new IllegalStateException("Failed to extract DLR native library", e); - } finally { - if (tmp != null) { - Utils.deleteQuietly(tmp); - } - } - } - - private static String findLibraryInPath(String libPath) { - String[] paths = libPath.split(File.pathSeparator); - List mappedLibNames; - mappedLibNames = Collections.singletonList(System.mapLibraryName(NATIVE_LIB_NAME)); - - for (String path : paths) { - File p = new File(path); - if (!p.exists()) { - continue; - } - for (String name : mappedLibNames) { - if (p.isFile() && p.getName().endsWith(name)) { - return p.getAbsolutePath(); - } - - File file = new File(path, name); - if (file.exists() && file.isFile()) { - return file.getAbsolutePath(); - } - } - } - return null; - } - - private static String findNativeOverrideLibrary() { - String libPath = Utils.getEnvOrSystemProperty("DLR_LIBRARY_PATH"); - if (libPath != null) { - String libName = findLibraryInPath(libPath); - if (libName != null) { - return libName; - } - } - - libPath = System.getProperty("java.library.path"); - if (libPath != null) { - return findLibraryInPath(libPath); - } - return null; - } - - private static String copyJniLibraryFromClasspath(Path nativeDir) { - String name = System.mapLibraryName(LIB_NAME); - Platform platform = Platform.detectPlatform("dlr"); - String classifier = platform.getClassifier(); - String djlVersion = platform.getApiVersion(); - Path path = nativeDir.resolve(djlVersion + '-' + name); - if (Files.exists(path)) { - return path.toAbsolutePath().toString(); - } - Path tmp = null; - // both cpu & gpu share the same jnilib - String lib = "jnilib/" + classifier + '/' + name; - try (InputStream is = ClassLoaderUtils.getResourceAsStream(lib)) { - tmp = Files.createTempFile(nativeDir, "jni", "tmp"); - Files.copy(is, tmp, StandardCopyOption.REPLACE_EXISTING); - Utils.moveQuietly(tmp, path); - return path.toAbsolutePath().toString(); - } catch (IOException e) { - throw new IllegalStateException("Cannot copy jni files", e); - } finally { - if (tmp != null) { - Utils.deleteQuietly(tmp); - } - } - } - - private static String downloadDlr(Platform platform) { - String version = platform.getVersion(); - String flavor = platform.getFlavor(); - String os = platform.getOsPrefix(); - - String libName = System.mapLibraryName(NATIVE_LIB_NAME); - Path cacheDir = getCacheDir(platform); - Path path = cacheDir.resolve(libName); - if (Files.exists(path)) { - return path.toAbsolutePath().toString(); - } - // if files not found - Path dlrCacheRoot = Utils.getEngineCacheDir("dlr"); - - Matcher matcher = VERSION_PATTERN.matcher(version); - if (!matcher.matches()) { - throw new IllegalArgumentException("Unexpected version: " + version); - } - String link = "https://publish.djl.ai/dlr-" + matcher.group(1) + "/native"; - Path tmp = null; - try (InputStream is = Utils.openUrl(link + "/files.txt")) { - Files.createDirectories(dlrCacheRoot); - List lines = Utils.readLines(is); - if (flavor.startsWith("cu") - && !lines.contains(flavor + '/' + os + "/native/lib/" + libName)) { - logger.warn("No matching cuda flavor for {} found: {}.", os, flavor); - // fallback to CPU - flavor = "cpu"; - - // check again - path = cacheDir.resolve(libName); - if (Files.exists(path)) { - return path.toAbsolutePath().toString(); - } - } - - tmp = Files.createTempDirectory(dlrCacheRoot, "tmp"); - boolean found = false; - for (String line : lines) { - if (line.startsWith(os + '/' + flavor + '/')) { - found = true; - URL url = new URL(link + '/' + line); - String fileName = line.substring(line.lastIndexOf('/') + 1); - logger.info("Downloading {} ...", url); - try (InputStream fis = Utils.openUrl(url)) { - Files.copy(fis, tmp.resolve(fileName), StandardCopyOption.REPLACE_EXISTING); - } - } - } - if (!found) { - throw new IllegalStateException( - "No DLR native library matches your operating system: " + platform); - } - - Utils.moveQuietly(tmp, cacheDir); - return path.toAbsolutePath().toString(); - } catch (IOException e) { - throw new IllegalStateException("Failed to download DLR native library", e); - } finally { - if (tmp != null) { - Utils.deleteQuietly(tmp); - } - } - } - - private static Path getCacheDir(Platform platform) { - String version = platform.getVersion(); - String flavor = platform.getFlavor(); - String classifier = platform.getClassifier(); - Path cacheDir = Utils.getEngineCacheDir("dlr"); - logger.debug("Using cache dir: {}", cacheDir); - return cacheDir.resolve(version + '-' + flavor + '-' + classifier); - } -} diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/package-info.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/package-info.java deleted file mode 100644 index f75c566bc52..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/jni/package-info.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ - -/** Contains classes to interface with the underlying DLR Engine. */ -package ai.djl.dlr.jni; diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/zoo/DlrModelZoo.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/zoo/DlrModelZoo.java deleted file mode 100644 index a4b8f094444..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/zoo/DlrModelZoo.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl.dlr.zoo; - -import ai.djl.Application.CV; -import ai.djl.dlr.engine.DlrEngine; -import ai.djl.repository.Repository; -import ai.djl.repository.zoo.ModelZoo; - -import java.util.Collections; -import java.util.Set; - -/** DlrModelZoo is a repository that contains all dlr models for DJL. */ -public class DlrModelZoo extends ModelZoo { - - private static final String DJL_REPO_URL = "https://mlrepo.djl.ai/"; - private static final Repository REPOSITORY = Repository.newInstance("Dlr", DJL_REPO_URL); - public static final String GROUP_ID = "ai.djl.dlr"; - - DlrModelZoo() { - addModel(REPOSITORY.model(CV.IMAGE_CLASSIFICATION, GROUP_ID, "resnet", "0.0.1")); - } - - /** {@inheritDoc} */ - @Override - public String getGroupId() { - return GROUP_ID; - } - - /** {@inheritDoc} */ - @Override - public Set getSupportedEngines() { - return Collections.singleton(DlrEngine.ENGINE_NAME); - } -} diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/zoo/DlrZooProvider.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/zoo/DlrZooProvider.java deleted file mode 100644 index 9a9ebddc39a..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/zoo/DlrZooProvider.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl.dlr.zoo; - -import ai.djl.repository.zoo.ModelZoo; -import ai.djl.repository.zoo.ZooProvider; - -/** An DLR model zoo provider implements the {@link ai.djl.repository.zoo.ZooProvider} interface. */ -public class DlrZooProvider implements ZooProvider { - - /** {@inheritDoc} */ - @Override - public ModelZoo getModelZoo() { - return new DlrModelZoo(); - } -} diff --git a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/zoo/package-info.java b/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/zoo/package-info.java deleted file mode 100644 index 4585872f5f9..00000000000 --- a/engines/dlr/dlr-engine/src/main/java/ai/djl/dlr/zoo/package-info.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ - -/** Contains the built-in {@link ai.djl.dlr.zoo.DlrModelZoo}. */ -package ai.djl.dlr.zoo; diff --git a/engines/dlr/dlr-engine/src/main/javadoc/overview.html b/engines/dlr/dlr-engine/src/main/javadoc/overview.html deleted file mode 100644 index 5fd07a26d8d..00000000000 --- a/engines/dlr/dlr-engine/src/main/javadoc/overview.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - -

This document is the API specification for the Deep Java Library (DJL) DLR Engine.

- -

- The DLR Engine module contains the DLR implementation of the DJL EngineProvider. - See here for more details. -

- - - diff --git a/engines/dlr/dlr-engine/src/main/resources/META-INF/services/ai.djl.engine.EngineProvider b/engines/dlr/dlr-engine/src/main/resources/META-INF/services/ai.djl.engine.EngineProvider deleted file mode 100644 index 152fb2fe6c5..00000000000 --- a/engines/dlr/dlr-engine/src/main/resources/META-INF/services/ai.djl.engine.EngineProvider +++ /dev/null @@ -1 +0,0 @@ -ai.djl.dlr.engine.DlrEngineProvider diff --git a/engines/dlr/dlr-engine/src/main/resources/META-INF/services/ai.djl.repository.zoo.ZooProvider b/engines/dlr/dlr-engine/src/main/resources/META-INF/services/ai.djl.repository.zoo.ZooProvider deleted file mode 100644 index 0a29989a33e..00000000000 --- a/engines/dlr/dlr-engine/src/main/resources/META-INF/services/ai.djl.repository.zoo.ZooProvider +++ /dev/null @@ -1 +0,0 @@ -ai.djl.dlr.zoo.DlrZooProvider diff --git a/engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/engine/DlrNDManagerTest.java b/engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/engine/DlrNDManagerTest.java deleted file mode 100644 index 5893f0d6420..00000000000 --- a/engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/engine/DlrNDManagerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl.dlr.engine; - -import ai.djl.ndarray.NDArray; -import ai.djl.ndarray.types.DataType; -import ai.djl.ndarray.types.Shape; -import ai.djl.testing.TestRequirements; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import java.nio.ByteBuffer; - -public class DlrNDManagerTest { - - @Test - public void testNDArray() { - TestRequirements.notWindows(); - TestRequirements.notArm(); - - try (DlrNDManager manager = - (DlrNDManager) DlrNDManager.getSystemManager().newSubManager()) { - NDArray zeros = manager.zeros(new Shape(1, 2)); - float[] data = zeros.toFloatArray(); - Assert.assertEquals(data[0], 0); - - NDArray ones = manager.ones(new Shape(1, 2)); - data = ones.toFloatArray(); - Assert.assertEquals(data[0], 1); - - float[] buf = {0f, 1f, 2f, 3f}; - NDArray array = manager.create(buf); - Assert.assertEquals(array.toFloatArray(), buf); - - ByteBuffer bb = ByteBuffer.allocate(4 * buf.length); - bb.asFloatBuffer().put(buf); - bb.rewind(); - - NDArray dlrArray = manager.create(bb, new Shape(4), DataType.FLOAT32); - Assert.assertEquals(dlrArray.toFloatArray(), buf); - } - } -} diff --git a/engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/engine/package-info.java b/engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/engine/package-info.java deleted file mode 100644 index 67a09dc4ae5..00000000000 --- a/engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/engine/package-info.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ - -/** Contains classes to interface with the underlying DLR Engine. */ -package ai.djl.dlr.engine; diff --git a/engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/integration/DlrTest.java b/engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/integration/DlrTest.java deleted file mode 100644 index 342ddc10f1f..00000000000 --- a/engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/integration/DlrTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl.dlr.integration; - -import ai.djl.Application; -import ai.djl.ModelException; -import ai.djl.inference.Predictor; -import ai.djl.modality.Classifications; -import ai.djl.modality.cv.Image; -import ai.djl.modality.cv.ImageFactory; -import ai.djl.modality.cv.transform.Resize; -import ai.djl.modality.cv.transform.ToTensor; -import ai.djl.modality.cv.translator.ImageClassificationTranslator; -import ai.djl.repository.zoo.Criteria; -import ai.djl.repository.zoo.ZooModel; -import ai.djl.testing.TestRequirements; -import ai.djl.training.util.ProgressBar; -import ai.djl.translate.TranslateException; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; - -public class DlrTest { - - @Test - public void testDlr() throws ModelException, IOException, TranslateException { - TestRequirements.notWindows(); - TestRequirements.notArm(); - - String os; - if (System.getProperty("os.name").toLowerCase().startsWith("mac")) { - os = "osx"; - } else if (System.getProperty("os.name").toLowerCase().startsWith("linux")) { - os = "linux"; - } else { - throw new IllegalStateException("Unexpected os"); - } - ImageClassificationTranslator translator = - ImageClassificationTranslator.builder() - .addTransform(new Resize(224, 224)) - .addTransform(new ToTensor()) - .build(); - Criteria criteria = - Criteria.builder() - .setTypes(Image.class, Classifications.class) - .optApplication(Application.CV.IMAGE_CLASSIFICATION) - .optFilter("layers", "50") - .optFilter("os", os) - .optTranslator(translator) - .optEngine("DLR") - .optProgress(new ProgressBar()) - .build(); - Path file = Paths.get("../../../examples/src/test/resources/kitten.jpg"); - Image image = ImageFactory.getInstance().fromFile(file); - try (ZooModel model = criteria.loadModel(); - Predictor predictor = model.newPredictor()) { - Classifications result = predictor.predict(image); - Assert.assertEquals(result.best().getClassName(), "n02123045 tabby, tabby cat"); - } - } -} diff --git a/engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/integration/package-info.java b/engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/integration/package-info.java deleted file mode 100644 index c632faab3df..00000000000 --- a/engines/dlr/dlr-engine/src/test/java/ai/djl/dlr/integration/package-info.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ - -/** Contains classes to interface with the underlying DLR Engine. */ -package ai.djl.dlr.integration; diff --git a/engines/dlr/dlr-engine/src/test/resources/mlrepo/model/cv/image_classification/ai/djl/dlr/resnet/metadata.json b/engines/dlr/dlr-engine/src/test/resources/mlrepo/model/cv/image_classification/ai/djl/dlr/resnet/metadata.json deleted file mode 100644 index 68a3d4731c4..00000000000 --- a/engines/dlr/dlr-engine/src/test/resources/mlrepo/model/cv/image_classification/ai/djl/dlr/resnet/metadata.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "metadataVersion": "0.2", - "resourceType": "model", - "application": "cv/image_classification", - "groupId": "ai.djl.dlr", - "artifactId": "resnet", - "name": "Resnet", - "description": "Resnet image classification", - "website": "https://github.com/neo-ai/neo-ai-dlr", - "licenses": { - "license": { - "name": "The Apache License, Version 2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0" - } - }, - "artifacts": [ - { - "version": "0.0.1", - "snapshot": false, - "name": "resnet50_v1", - "properties": { - "layers": "50", - "flavor": "v1", - "dataset": "imagenet", - "engine": "mxnet", - "os": "osx", - "target": "cpu" - }, - "arguments": { - "width": 224, - "height": 224, - "centerCrop": true, - "resize": true, - "applySoftmax": true - }, - "files": { - "synset": { - "uri": "https://mlrepo.djl.ai/model/cv/image_classification/ai/djl/mxnet/synset.txt", - "sha1Hash": "e03a09a8336d75b7bb008748eadee253a30cb2c2", - "size": 31675 - }, - "module": { - "uri": "0.0.1/resnet50_v1.dylib.gz", - "sha1Hash": "bcb654748c5f0904163b84b3240f7b6f4ff66dee", - "size": 151062 - }, - "parameters": { - "uri": "0.0.1/resnet50_v1.params.gz", - "sha1Hash": "cd8dce9dd75c8dc08aea5a336f357ebab699fcbf", - "size": 88594592 - }, - "graph": { - "uri": "0.0.1/resnet50_v1.json.gz", - "sha1Hash": "7110540e55b3e80d9bc01e08ab92adaa86141240", - "size": 4340 - } - } - }, - { - "version": "0.0.1", - "snapshot": false, - "name": "resnet50_v1", - "properties": { - "layers": "50", - "flavor": "v1", - "dataset": "imagenet", - "engine": "mxnet", - "os": "linux", - "target": "cpu" - }, - "arguments": { - "width": 224, - "height": 224, - "centerCrop": true, - "resize": true, - "applySoftmax": true - }, - "files": { - "synset": { - "uri": "https://mlrepo.djl.ai/model/cv/image_classification/ai/djl/mxnet/synset.txt", - "sha1Hash": "e03a09a8336d75b7bb008748eadee253a30cb2c2", - "size": 31675 - }, - "module": { - "uri": "0.0.1/resnet50_v1.so.gz", - "sha1Hash": "1659f124f5112699ab9668cdb5bfcd857ffd5b6c", - "size": 158944 - }, - "parameters": { - "uri": "0.0.1/resnet50_v1.params.gz", - "sha1Hash": "cd8dce9dd75c8dc08aea5a336f357ebab699fcbf", - "size": 88594592 - }, - "graph": { - "uri": "0.0.1/resnet50_v1.json.gz", - "sha1Hash": "7110540e55b3e80d9bc01e08ab92adaa86141240", - "size": 4340 - } - } - } - ] -} diff --git a/engines/dlr/dlr-native/.gitignore b/engines/dlr/dlr-native/.gitignore deleted file mode 100644 index 1b8aec81c6f..00000000000 --- a/engines/dlr/dlr-native/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -neo-ai-dlr/ -cmake-build-debug/ diff --git a/engines/dlr/dlr-native/CMakeLists.txt b/engines/dlr/dlr-native/CMakeLists.txt deleted file mode 100644 index 4b9e77b38dc..00000000000 --- a/engines/dlr/dlr-native/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 3.6 FATAL_ERROR) -project(djl_dlr) - -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(JAVA_AWT_LIBRARY NotNeeded) -set(JAVA_AWT_INCLUDE_PATH NotNeeded) -find_package(JNI REQUIRED) - -add_subdirectory(neo-ai-dlr) - -add_library(djl_dlr SHARED src/main/native/ai_djl_dlr_jni_DlrLibrary.cc) -target_include_directories(djl_dlr PUBLIC - ${JNI_INCLUDE_DIRS} - neo-ai-dlr/include - build/include) -target_link_libraries(djl_dlr dlr) diff --git a/engines/dlr/dlr-native/README.md b/engines/dlr/dlr-native/README.md deleted file mode 100644 index ba8d5662649..00000000000 --- a/engines/dlr/dlr-native/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# DJL - DLR native Library - -## Introduction -This project builds the JNI layer for Java to call DLR C APIs. -You can find more information in the `src`. - -## Prerequisite -You need to install `cmake` and C++ compiler on your machine in order to build - -### Linux - -``` -apt install cmake g++ -``` - -## CPU Build - -Use the following task to build DLR JNI library: - -### Mac/Linux - -``` -./gradlew compileJNI -``` - -* Note that the windows is not supported. - -This task will send a JNI library copy to `dlr-engine` model to test locally. - -## GPU build - -* GPU is not supported. - -### Format C++ code -It uses clang-format to format the code. - -``` -./gradlew formatCpp -``` diff --git a/engines/dlr/dlr-native/build.gradle b/engines/dlr/dlr-native/build.gradle deleted file mode 100644 index e41ec9d5afd..00000000000 --- a/engines/dlr/dlr-native/build.gradle +++ /dev/null @@ -1,223 +0,0 @@ -plugins { - id 'maven-publish' - id 'signing' -} - -apply from: file("${rootProject.projectDir}/tools/gradle/cpp-formatter.gradle") - -group = "ai.djl.dlr" -boolean isRelease = project.hasProperty("release") || project.hasProperty("staging") -version = "${dlr_version}" + (isRelease ? "" : "-SNAPSHOT") -def BINARY_ROOT = "${project.buildDir}/download" - -def buildJNI(String os) { - exec { - commandLine 'bash', 'build.sh' - } - def engineDir = "${project.parent.projectDir}/dlr-engine" - def classifier = "${os}-x86_64" - def publishDir = "${engineDir}/build/jnilib/${classifier}" - copy { - def tree = fileTree(project.buildDir) - tree.include("libdjl_dlr.*") - from tree.files - into publishDir - } - // for nightly ci - // the reason why we duplicate the folder here is to insert djl_version into the path - // so different versions of JNI wouldn't override each other. We don't also want publishDir - // to have djl_version as engine would require to know that during the System.load() - def ciDir = "${project.projectDir}/jnilib/${djl_version}/${classifier}" - copy { - from publishDir - into ciDir - } -} - -task compileJNI { - doFirst { - if (System.properties['os.name'].toLowerCase(Locale.ROOT).contains("mac")) { - buildJNI("osx") - } else if (System.properties['os.name'].toLowerCase(Locale.ROOT).contains("linux")) { - buildJNI("linux") - } else { - throw new IllegalStateException("Unknown Architecture " + System.properties['os.name']) - } - delete System.getProperty("user.home") + "/.djl.ai/dlr" - } -} - -// Create a placeholder jar without classifier to pass sonatype tests but throws an Exception if loaded -jar { - def placeholder = "${project.buildDir}/placeholder" - // this line is to enforce gradle to build the jar - // otherwise it don't generate the placeholder jar at times - // when there is no java code inside src/main - outputs.dir file("build/libs") - doFirst { - def versionName = project.version - if (!isRelease) { - versionName += String.format("-%s", new Date().format('yyyyMMdd')) - } - def dir = file("${placeholder}/native/lib") - dir.mkdirs() - def propFile = file("${placeholder}/native/lib/dlr.properties") - propFile.text = "placeholder=true\nversion=${versionName}\n" - } - - from placeholder -} - -java { - withJavadocJar() - withSourcesJar() -} - -project.tasks.withType(GenerateModuleMetadata) { - enabled = false -} - -signing { - required(project.hasProperty("staging") || project.hasProperty("snapshot")) - def signingKey = findProperty("signingKey") - def signingPassword = findProperty("signingPassword") - useInMemoryPgpKeys(signingKey, signingPassword) - sign publishing.publications -} - -publishing.repositories { - maven { - if (project.hasProperty("snapshot")) { - name = "snapshot" - url = "https://oss.sonatype.org/content/repositories/snapshots/" - credentials { - username = findProperty("ossrhUsername") - password = findProperty("ossrhPassword") - } - } else if (project.hasProperty("staging")) { - name = "staging" - url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" - credentials { - username = findProperty("ossrhUsername") - password = findProperty("ossrhPassword") - } - } else { - name = "local" - url = "build/repo" - } - } -} - -task downloadDlrNativeLib() { - doLast { - def url = "https://djl-ai.s3.amazonaws.com/publish/dlr-${dlr_version}/native" - def files = [ - "osx/cpu/libdlr.dylib": "cpu/osx/native/lib/libdlr.dylib", - "linux/cpu/libdlr.so" : "cpu/linux/native/lib/libdlr.so" - ] - - files.each { entry -> - project.logger.lifecycle("Downloading ${url}/${entry.key}") - def file = new File("${BINARY_ROOT}/${entry.value}") - file.getParentFile().mkdirs() - new URL("${url}/${entry.key}").withInputStream { i -> file.withOutputStream { it << i } } - } - } -} - -def flavorNames = file(BINARY_ROOT).list() ?: [] -flavorNames.each { flavor -> - - def platformNames = file("${BINARY_ROOT}/${flavor}").list() ?: [] - - def artifactsNames = [] - - platformNames.each { osName -> - tasks.create(name: "${flavor}-${osName}Jar", type: Jar) { - doFirst { - def propFile = file("${BINARY_ROOT}/${flavor}/${osName}/native/lib/dlr.properties") - propFile.delete() - def dsStore = file("${BINARY_ROOT}/${flavor}/${osName}/native/lib/.DS_Store") - dsStore.delete() - - def versionName = String.format("${project.version}-%s", new Date().format('yyyyMMdd')) - def dir = file("${BINARY_ROOT}/${flavor}/${osName}/native/lib") - def sb = new StringBuilder() - sb.append("version=${versionName}\nclassifier=${flavor}-${osName}-x86_64\nlibraries=") - def first = true - for (String name : dir.list().sort()) { - if (first) { - first = false - } else { - sb.append(',') - } - sb.append(name) - } - propFile.text = sb.toString() - def metaInf = new File("${BINARY_ROOT}/${flavor}/${osName}/META-INF") - metaInf.mkdirs() - def licenseFile = new File(metaInf, "LICENSE") - licenseFile.text = new URL("https://raw.githubusercontent.com/neo-ai/neo-ai-dlr/master/LICENSE").text - - def binaryLicenseFile = new File(metaInf, "NOTICE") - binaryLicenseFile.text = new URL("https://raw.githubusercontent.com/neo-ai/neo-ai-dlr/master/NOTICE").text - } - from file("${BINARY_ROOT}/${flavor}/${osName}") - from file("src/main/resources") - archiveClassifier = "${osName}-x86_64" - - manifest { - attributes("Automatic-Module-Name": "ai.djl.dlr_native_${flavor}_${osName}") - } - } - artifactsNames.add(tasks["${flavor}-${osName}Jar"]) - } - - // Only publish if the project directory equals the current directory - // This means that publishing from the main project does not publish the native jars - // and the native jars have to be published separately - if (project.getProjectDir().toString() == System.getProperty("user.dir")) { - publishing.publications.create("${flavor}", MavenPublication) { - artifactId "dlr-native-${flavor}" - from components.java - artifacts = artifactsNames - artifact jar - artifact javadocJar - artifact sourcesJar - pom { - name = "DJL release for DLR native binaries" - description = "Deep Java Library (DJL) provided DLR native library binary distribution" - url = "http://www.djl.ai/engines/dlr/dlr-native" - packaging = "jar" - - licenses { - license { - name = 'The Apache License, Version 2.0' - url = 'https://www.apache.org/licenses/LICENSE-2.0' - } - } - - scm { - connection = "scm:git:git@github.com:deepjavalibrary/djl.git" - developerConnection = "scm:git:git@github.com:deepjavalibrary/djl.git" - url = "https://github.com/deepjavalibrary/djl" - tag = "HEAD" - } - - developers { - developer { - name = "DJL.AI Team" - email = "djl-dev@amazon.com" - organization = "Amazon AI" - organizationUrl = "https://amazon.com" - } - } - } - } - } -} - -clean.doFirst { - delete "${project.projectDir}/jnilib" - delete "${project.projectDir.getParent()}/dlr-engine/jnilib" -} diff --git a/engines/dlr/dlr-native/build.sh b/engines/dlr/dlr-native/build.sh deleted file mode 100755 index d1cddf380d1..00000000000 --- a/engines/dlr/dlr-native/build.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash - -set -e -WORK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -export WORK_DIR -NUM_PROC=1 -if [[ -n $(command -v nproc) ]]; then - NUM_PROC=$(nproc) -elif [[ -n $(command -v sysctl) ]]; then - NUM_PROC=$(sysctl -n hw.ncpu) -fi - -VERSION=v"$(cat ../../../gradle.properties | awk -F '=' '/dlr_version/ {print $2}')" - -if [ ! -d "neo-ai-dlr" ]; -then - git clone https://github.com/neo-ai/neo-ai-dlr.git -b $VERSION --recursive -fi - -if [ ! -d "build" ]; -then - mkdir build -fi -cd build -if [ ! -d "classes" ]; -then - mkdir classes -fi -javac -sourcepath ../../dlr-engine/src/main/java/ ../../dlr-engine/src/main/java/ai/djl/dlr/jni/DlrLibrary.java -h include -d classes -cmake .. -cmake --build . --config Release -- -j "${NUM_PROC}" diff --git a/engines/dlr/dlr-native/gradlew b/engines/dlr/dlr-native/gradlew deleted file mode 120000 index ab9334b002e..00000000000 --- a/engines/dlr/dlr-native/gradlew +++ /dev/null @@ -1 +0,0 @@ -../../../gradlew \ No newline at end of file diff --git a/engines/dlr/dlr-native/src/main/native/ai_djl_dlr_jni_DlrLibrary.cc b/engines/dlr/dlr-native/src/main/native/ai_djl_dlr_jni_DlrLibrary.cc deleted file mode 100644 index 5ce910f5827..00000000000 --- a/engines/dlr/dlr-native/src/main/native/ai_djl_dlr_jni_DlrLibrary.cc +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -#include "ai_djl_dlr_jni_DlrLibrary.h" - -#include - -#include - -#include "dlr.h" - -inline void CheckStatus(JNIEnv* env, int status) { - if (status) { - jclass jexception = env->FindClass("ai/djl/engine/EngineException"); - const char* err = DLRGetLastError(); - env->ThrowNew(jexception, err); - } -} - -JNIEXPORT jint JNICALL Java_ai_djl_dlr_jni_DlrLibrary_getDlrNumInputs(JNIEnv* env, jobject jthis, jlong jhandle) { - int num; - auto* handle = reinterpret_cast(jhandle); - CheckStatus(env, GetDLRNumInputs(handle, &num)); - return num; -} - -JNIEXPORT jint JNICALL Java_ai_djl_dlr_jni_DlrLibrary_getDlrNumWeights(JNIEnv* env, jobject jthis, jlong jhandle) { - int num; - auto* handle = reinterpret_cast(jhandle); - CheckStatus(env, GetDLRNumWeights(handle, &num)); - return num; -} - -JNIEXPORT jstring JNICALL Java_ai_djl_dlr_jni_DlrLibrary_getDlrInputName( - JNIEnv* env, jobject jthis, jlong jhandle, jint jindex) { - const char* name; - auto* handle = reinterpret_cast(jhandle); - CheckStatus(env, GetDLRInputName(handle, jindex, &name)); - return env->NewStringUTF(name); -} - -JNIEXPORT jstring JNICALL Java_ai_djl_dlr_jni_DlrLibrary_getDlrWeightName( - JNIEnv* env, jobject jthis, jlong jhandle, jint jindex) { - const char* name; - auto* handle = reinterpret_cast(jhandle); - CheckStatus(env, GetDLRWeightName(handle, jindex, &name)); - return env->NewStringUTF(name); -} - -JNIEXPORT void JNICALL Java_ai_djl_dlr_jni_DlrLibrary_setDLRInput( - JNIEnv* env, jobject jthis, jlong jhandle, jstring jname, jlongArray jshape, jfloatArray jinput, jint jdim) { - jfloat* input_body = env->GetFloatArrayElements(jinput, JNI_FALSE); - jlong* shape_body = env->GetLongArrayElements(jshape, JNI_FALSE); - const char* name = env->GetStringUTFChars(jname, JNI_FALSE); - ; - auto* handle = reinterpret_cast(jhandle); - CheckStatus(env, SetDLRInput(handle, name, reinterpret_cast(shape_body), input_body, jdim)); - env->ReleaseFloatArrayElements(jinput, input_body, JNI_ABORT); - env->ReleaseLongArrayElements(jshape, shape_body, JNI_ABORT); - env->ReleaseStringUTFChars(jname, name); -} - -JNIEXPORT jlongArray JNICALL Java_ai_djl_dlr_jni_DlrLibrary_getDlrOutputShape( - JNIEnv* env, jobject jthis, jlong jhandle, jint jindex) { - auto* handle = reinterpret_cast(jhandle); - int64_t size; - int dim; - CheckStatus(env, GetDLROutputSizeDim(handle, jindex, &size, &dim)); - jlong shape[dim]; - CheckStatus(env, GetDLROutputShape(handle, jindex, reinterpret_cast(shape))); - jlongArray res = env->NewLongArray(dim); - env->SetLongArrayRegion(res, 0, dim, shape); - return res; -} - -JNIEXPORT jfloatArray JNICALL Java_ai_djl_dlr_jni_DlrLibrary_getDlrOutput( - JNIEnv* env, jobject jthis, jlong jhandle, jint jindex) { - auto* handle = reinterpret_cast(jhandle); - int64_t size; - int dim; - CheckStatus(env, GetDLROutputSizeDim(handle, jindex, &size, &dim)); - float data[size]; - CheckStatus(env, GetDLROutput(handle, jindex, data)); - jfloatArray res = env->NewFloatArray(size); - env->SetFloatArrayRegion(res, 0, size, data); - return res; -} - -JNIEXPORT jint JNICALL Java_ai_djl_dlr_jni_DlrLibrary_getDlrNumOutputs(JNIEnv* env, jobject jthis, jlong jhandle) { - int num; - auto* handle = reinterpret_cast(jhandle); - CheckStatus(env, GetDLRNumOutputs(handle, &num)); - return num; -} - -JNIEXPORT jlong JNICALL Java_ai_djl_dlr_jni_DlrLibrary_createDlrModel( - JNIEnv* env, jobject jthis, jstring jmodel_path, jint jdev_type, jint jdev_id) { - const char* model_path = env->GetStringUTFChars(jmodel_path, JNI_FALSE); - auto* handle = new DLRModelHandle(); - CheckStatus(env, CreateDLRModel(handle, model_path, jdev_type, jdev_id)); - auto jhandle = reinterpret_cast(handle); - return jhandle; -} - -JNIEXPORT void JNICALL Java_ai_djl_dlr_jni_DlrLibrary_deleteDlrModel(JNIEnv* env, jobject jthis, jlong jhandle) { - auto* handle = reinterpret_cast(jhandle); - CheckStatus(env, DeleteDLRModel(handle)); -} - -JNIEXPORT void JNICALL Java_ai_djl_dlr_jni_DlrLibrary_runDlrModel(JNIEnv* env, jobject jthis, jlong jhandle) { - auto* handle = reinterpret_cast(jhandle); - CheckStatus(env, RunDLRModel(handle)); -} - -JNIEXPORT jstring JNICALL Java_ai_djl_dlr_jni_DlrLibrary_getDlrBackend(JNIEnv* env, jobject jthis, jlong jhandle) { - const char* name; - auto* handle = reinterpret_cast(jhandle); - CheckStatus(env, GetDLRBackend(handle, &name)); - return env->NewStringUTF(name); -} - -JNIEXPORT jstring JNICALL Java_ai_djl_dlr_jni_DlrLibrary_getDlrVersion(JNIEnv* env, jobject jthis) { - const char* version; - CheckStatus(env, GetDLRVersion(&version)); - return env->NewStringUTF(version); -} - -JNIEXPORT void JNICALL Java_ai_djl_dlr_jni_DlrLibrary_setDlrNumThreads( - JNIEnv* env, jobject jthis, jlong jhandle, jint jthreads) { - auto* handle = reinterpret_cast(jhandle); - CheckStatus(env, SetDLRNumThreads(handle, jthreads)); -} - -JNIEXPORT void JNICALL Java_ai_djl_dlr_jni_DlrLibrary_useDlrCPUAffinity( - JNIEnv* env, jobject jthis, jlong jhandle, jboolean juse) { - auto* handle = reinterpret_cast(jhandle); - CheckStatus(env, UseDLRCPUAffinity(handle, juse)); -} diff --git a/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/engine/PpPredictor.java b/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/engine/PpPredictor.java index 6aaeda0e2c7..f510f0cd6b3 100644 --- a/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/engine/PpPredictor.java +++ b/engines/paddlepaddle/paddlepaddle-engine/src/main/java/ai/djl/paddlepaddle/engine/PpPredictor.java @@ -20,7 +20,7 @@ /** * {@code PpPredictor} is special implementation of {@link Predictor} for PaddlePaddle. * - *

When creating a new DlrPredictor, we clone Paddle predictor handle to workaround the issue. + *

When creating a new PpPredictor, we clone Paddle predictor handle to workaround the issue. */ public class PpPredictor extends Predictor { diff --git a/gradle.properties b/gradle.properties index 7f703fe6505..dbaa0347498 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,7 +16,6 @@ mxnet_version=1.9.1 pytorch_version=1.13.1 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.3.2 diff --git a/integration/build.gradle b/integration/build.gradle index 798d8165e1d..c4dc5088e60 100644 --- a/integration/build.gradle +++ b/integration/build.gradle @@ -20,8 +20,6 @@ dependencies { if (System.getProperty("ai.djl.default_engine") == "TFLite") { runtimeOnly project(":engines:tflite:tflite-engine") - } else if (System.getProperty("ai.djl.default_engine") == "DLR") { - runtimeOnly project(":engines:dlr:dlr-engine") } else if (System.getProperty("ai.djl.default_engine") == "PaddlePaddle") { runtimeOnly project(":engines:paddlepaddle:paddlepaddle-model-zoo") } diff --git a/jacoco/build.gradle b/jacoco/build.gradle index 418e7857c5b..d9196393283 100644 --- a/jacoco/build.gradle +++ b/jacoco/build.gradle @@ -10,8 +10,6 @@ repositories { dependencies { jacocoAggregation project(":api") jacocoAggregation project(":basicdataset") - jacocoAggregation project(":engines:dlr:dlr-engine") - jacocoAggregation project(":engines:dlr:dlr-native") jacocoAggregation project(":engines:ml:xgboost") jacocoAggregation project(":engines:ml:lightgbm") jacocoAggregation project(":engines:mxnet:mxnet-engine") diff --git a/serving/README.md b/serving/README.md index fb8bd6418cc..7292c9886b7 100644 --- a/serving/README.md +++ b/serving/README.md @@ -14,7 +14,7 @@ You can install extra extensions to enable the following models: - ONNX model - PaddlePaddle model - TFLite model -- Neo DLR (TVM) model - XGBoost model +- LightGBM model - Sentencepiece model - fastText/BlazingText model diff --git a/settings.gradle b/settings.gradle index 8b741d59860..75a1f854ef8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,8 +2,6 @@ rootProject.name = 'djl' include ':api' include ':basicdataset' include ':djl-zero' -include ':engines:dlr:dlr-engine' -include ':engines:dlr:dlr-native' include ':engines:ml:xgboost' include ':engines:ml:lightgbm' include ':engines:mxnet:jnarator' diff --git a/tools/gradle/publish.gradle b/tools/gradle/publish.gradle index ba9be571574..663f847e95b 100644 --- a/tools/gradle/publish.gradle +++ b/tools/gradle/publish.gradle @@ -2,7 +2,6 @@ configure([ project(':api'), project(':basicdataset'), project(':djl-zero'), - project(':engines:dlr:dlr-engine'), project(':engines:ml:xgboost'), project(':engines:ml:lightgbm'), project(':engines:mxnet:mxnet-engine'), diff --git a/website/javadoc.html b/website/javadoc.html index add59a3db53..a6d3efd15ae 100644 --- a/website/javadoc.html +++ b/website/javadoc.html @@ -83,7 +83,6 @@

Javadoc Documentation

DJL core API

DJL DataSet API

DJL Basic ModelZoo

-

DLR Engine for DJL

LightGBM for DJL

XGBoost for DJL

MXNet Engine for DJL

@@ -135,7 +134,7 @@
About Us
- +