Skip to content

Commit

Permalink
Add initial PaddlePaddle engine implementation
Browse files Browse the repository at this point in the history
Change-Id: Iecbd1b74789e1c88462cda9cd8d0c606a19ad41e
  • Loading branch information
frankfliu authored and lanking520 committed Dec 19, 2020
1 parent 4b4eef1 commit 34e9b27
Show file tree
Hide file tree
Showing 24 changed files with 661 additions and 0 deletions.
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ tensorflow_version=2.3.1
tflite_version=2.3.1
dlr_version=1.6.0
onnxruntime_version=1.4.0
paddlepaddle_version=1.8.5
sentencepiece_version=0.1.92
fasttext_version=0.9.2
mkl_dnn_version=0.21.2-1.5.2
Expand Down
11 changes: 11 additions & 0 deletions paddlepaddle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# PaddlePaddle Engine

This directory contains the Deep Java Library (DJL) EngineProvider for PaddlePaddle.

It is based off the [PaddlePaddle](http://www.paddlepaddle.org/).

## Modules

- [PaddlePaddle Engine](paddlepaddle-engine/README.md) - The DJL implementation for PaddlePaddle Engine
- [PaddlePaddle Model Zoo](paddlepaddle-model-zoo/README.md) - A ModelZoo containing models exported from PaddlePaddle
- [PaddlePaddle native library](paddlepaddle-native/README.md) - A utility module for building the paddlepaddle-native jars containing the native binaries
161 changes: 161 additions & 0 deletions paddlepaddle/paddlepaddle-engine/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# DJL - PaddlePaddle engine implementation

## Overview

This module contains the Deep Java Library (DJL) EngineProvider for PaddlePaddle.

We don't recommend that developers use classes in this module directly.
Use of these classes will couple your code with PaddlePaddle and make switching between frameworks difficult.

## Documentation

The latest javadocs can be found on the [djl.ai website](https://javadoc.io/doc/ai.djl.paddlepaddle/paddlepaddle-engine/latest/index.html).

You can also build the latest javadocs locally using the following command:

```sh
# for Linux/macOS:
./gradlew javadoc

# for Windows:
..\..\gradlew javadoc
```
The javadocs output is built in the `build/doc/javadoc` folder.


## Installation
You can pull the PaddlePaddle engine from the central Maven repository by including the following dependency:

```xml
<dependency>
<groupId>ai.djl.paddlepaddle</groupId>
<artifactId>paddlepaddle-engine</artifactId>
<version>0.8.0</version>
<scope>runtime</scope>
</dependency>
```

Besides the `paddlepaddle-engine` library, you may also need to include the PaddlePaddle native library in your project.
All current provided PaddlePaddle native libraries come from PaddlePaddle pip package:

- https://pypi.org/project/paddlepaddle/#files
- https://pypi.org/project/paddlepaddle-gpu/#files

Choose a native library based on your platform and needs:

### Automatic (Recommended)

We offer an automatic option that will download the 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.

```xml
<dependency>
<groupId>ai.djl.paddlepaddle</groupId>
<artifactId>paddlepaddle-native-auto</artifactId>
<version>1.8.5</version>
<scope>runtime</scope>
</dependency>
```

### macOS
For macOS, you can use the following library:

- ai.djl.paddlepaddle:paddlepaddle-native-mkl:1.8.5:osx-x86_64

This package takes advantage of the Intel MKL library to boost performance.

```xml
<dependency>
<groupId>ai.djl.paddlepaddle</groupId>
<artifactId>paddlepaddle-native-mkl</artifactId>
<classifier>osx-x86_64</classifier>
<version>1.8.5</version>
<scope>runtime</scope>
</dependency>
```

### Linux
For the Linux platform, you can choose between CPU, GPU. If you have Nvidia [CUDA](https://en.wikipedia.org/wiki/CUDA)
installed on your GPU machine, you can use one of the following library:

#### Linux GPU

- ai.djl.paddlepaddle:paddlepaddle-native-cu102:1.8.5:linux-x86_64 - CUDA 10.2
- ai.djl.paddlepaddle:paddlepaddle-native-cu101:1.8.5:linux-x86_64 - CUDA 10.1

```xml
<dependency>
<groupId>ai.djl.paddlepaddle</groupId>
<artifactId>paddlepaddle-native-cu102</artifactId>
<classifier>linux-x86_64</classifier>
<version>1.8.5</version>
<scope>runtime</scope>
</dependency>
```

```xml
<dependency>
<groupId>ai.djl.paddlepaddle</groupId>
<artifactId>paddlepaddle-native-cu101</artifactId>
<classifier>linux-x86_64</classifier>
<version>1.8.5</version>
<scope>runtime</scope>
</dependency>
```

#### Linux CPU

- ai.djl.paddlepaddle:paddlepaddle-native-cpu:1.8.5:linux-x86_64

```xml
<dependency>
<groupId>ai.djl.paddlepaddle</groupId>
<artifactId>paddlepaddle-native-cpu</artifactId>
<classifier>linux-x86_64</classifier>
<scope>runtime</scope>
<version>1.8.5</version>
</dependency>
```

### Windows

For the Windows platform, you can use CPU package.

#### Windows GPU

- ai.djl.paddlepaddle:paddlepaddle-native-cu102:1.8.5:win-x86_64 - CUDA 10.2
- ai.djl.paddlepaddle:paddlepaddle-native-cu101:1.8.5:win-x86_64 - CUDA 10.1

```xml
<dependency>
<groupId>ai.djl.paddlepaddle</groupId>
<artifactId>paddlepaddle-native-cu102</artifactId>
<classifier>win-x86_64</classifier>
<version>1.8.5</version>
<scope>runtime</scope>
</dependency>
```

```xml
<dependency>
<groupId>ai.djl.paddlepaddle</groupId>
<artifactId>paddlepaddle-native-cu101</artifactId>
<classifier>win-x86_64</classifier>
<version>1.8.5</version>
<scope>runtime</scope>
</dependency>
```

### Windows CPU

- ai.djl.paddlepaddle:paddlepaddle-native-cpu:1.8.5:win-x86_64

```xml
<dependency>
<groupId>ai.djl.paddlepaddle</groupId>
<artifactId>paddlepaddle-native-cpu</artifactId>
<classifier>win-x86_64</classifier>
<scope>runtime</scope>
<version>1.8.5</version>
</dependency>
```
29 changes: 29 additions & 0 deletions paddlepaddle/paddlepaddle-engine/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
group "ai.djl.paddlepaddle"

repositories {
jcenter()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}

dependencies {
api project(":api")

testImplementation("org.testng:testng:${testng_version}") {
exclude group: "junit", module: "junit"
}
testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
}

publishing {
publications {
maven(MavenPublication) {
pom {
name = "DJL Engine Adapter for PaddlePaddle"
description = "Deep Java Library (DJL) Engine Adapter for PaddlePaddle"
url = "http://www.djl.ai/paddlepaddle/${project.name}"
}
}
}
}
1 change: 1 addition & 0 deletions paddlepaddle/paddlepaddle-engine/gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* 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 implementations of interfaces within the DJL API for the PaddlePaddle Engine.
*/
package ai.djl.paddlepaddle.engine;
14 changes: 14 additions & 0 deletions paddlepaddle/paddlepaddle-engine/src/main/javadoc/overview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<p>This document is the API specification for the Deep Java Library (DJL) PaddlePaddle Engine.</p>

<p>
The PaddlePaddle Engine module contains the PaddlePaddle implementation of the DJL EngineProvider.
See <a href="https://github.com/awslabs/djl/tree/master/paddlepaddle/paddlepaddle-engine">here</a> for more details.
</p>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"name": "ai.djl.paddlepaddle.engine.TfEngineProvider",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"resources": [
{
"pattern": "META-INF/services/ai.djl.engine.EngineProvider"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ai.djl.paddlepaddle.engine.TfEngineProvider
43 changes: 43 additions & 0 deletions paddlepaddle/paddlepaddle-model-zoo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# DJL - PaddlePaddle model zoo

The PaddlePaddle model zoo contains symbolic models that can be used for inference.
All the models in this model zoo contain pre-trained parameters for their specific datasets.

## Documentation

The latest javadocs can be found on the [djl.ai website](https://javadoc.io/doc/ai.djl.paddlepaddle/paddlepaddle-model-zoo/latest/index.html).

You can also build the latest javadocs locally using the following command:

```sh
# for Linux/macOS:
./gradlew javadoc

# for Windows:
..\..\gradlew javadoc
```
The javadocs output is built in the build/doc/javadoc folder.

## Installation
You can pull the [ai.djl.paddlepaddle:paddlepaddle-model-zoo](https://search.maven.org/artifact/ai.djl.paddlepaddle/paddlepaddle-model-zoo)
from the central Maven repository by including the following dependency:

```xml
<dependency>
<groupId>ai.djl.paddlepaddle</groupId>
<artifactId>paddlepaddle-model-zoo</artifactId>
<version>0.8.0</version>
</dependency>
```

## Pre-trained models

The PaddlePaddle model zoo contains Computer Vision (CV) models.

* CV
* Image Classification
* Object Detection

### How to find a pre-trained model in model zoo

Please see [DJL Model Zoo](../../model-zoo/README.md)
39 changes: 39 additions & 0 deletions paddlepaddle/paddlepaddle-model-zoo/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
group 'ai.djl.paddlepaddle'

repositories {
mavenLocal()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}

dependencies {
api project(":paddlepaddle:paddlepaddle-engine")

testImplementation("org.testng:testng:${testng_version}") {
exclude group: "junit", module: "junit"
}
testRuntimeOnly "ai.djl.paddlepaddle:paddlepaddle-native-auto:${paddlepaddle_version}-SNAPSHOT"
testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
}

task syncS3(type: Exec) {
commandLine "sh", "-c", "find . -name .DS_Store | xargs rm && aws s3 sync src/test/resources/mlrepo s3://djl-ai/mlrepo --acl public-read"

standardOutput = new ByteArrayOutputStream()
ext.output = {
return standardOutput.toString()
}
}

publishing {
publications {
maven(MavenPublication) {
pom {
name = "DJL model zoo for PaddlePaddle"
description = "DJL model zoo for PaddlePaddle"
url = "http://www.djl.ai/paddlepaddle/${project.name}"
}
}
}
}
1 change: 1 addition & 0 deletions paddlepaddle/paddlepaddle-model-zoo/gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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 PaddlePaddle pre-trained models. */
package ai.djl.paddlepaddle.zoo;
14 changes: 14 additions & 0 deletions paddlepaddle/paddlepaddle-model-zoo/src/main/javadoc/overview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<p>This document is the API specification for the Deep Java Library (DJL) PaddlePaddle Model Zoo.</p>

<p>
The PaddlePaddle Model Zoo module contains PaddlePaddle pretrained modules that can be used for inference.
See <a href="https://github.com/awslabs/djl/tree/master/paddlepaddle/paddlepaddle-model-zoo">here</a> for more details.
</p>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"name": "ai.djl.paddlepaddle.zoo.PpZooProvider",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true
},
{
"name": "ai.djl.paddlepaddle.zoo.PpModelZoo",
"allDeclaredFields": true
}
]
Loading

0 comments on commit 34e9b27

Please sign in to comment.