Skip to content

Commit d5e0d36

Browse files
authored
OPENNLP-1516 - Provide a ONNX runtime GPU module for opennlp-dl (#558)
* OPENNLP-1516 - Provide a ONNX runtime module for opennlp-dl
1 parent 9505661 commit d5e0d36

File tree

5 files changed

+149
-1
lines changed

5 files changed

+149
-1
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ You can also follow our [mailing lists](http://opennlp.apache.org/mailing-lists.
5858

5959
## Overview
6060

61-
Currently the library has different packages:
61+
Currently, the library has different packages:
6262

6363
* `opennlp-tools` : The core toolkit.
6464
* `opennlp-uima` : A set of [Apache UIMA](https://uima.apache.org) annotators.
6565
* `opennlp-brat-annotator` : A set of annotators for [BRAT](http://brat.nlplab.org/)
6666
* `opennlp-morfologik-addon` : An addon for Morfologik
67+
* `opennlp-dl` : OpenNLP interface implementations for ONNX models using the `onnxruntime` dependency.
68+
* `opennlp-dl-gpu` : Replaces `onnxruntime` with the `onnxruntime_gpu` dependency to support GPU acceleration.
6769
* `opennlp-sandbox`: Other projects in progress are found in the [sandbox](https://github.com/apache/opennlp-sandbox)
6870

6971
## Getting Started

opennlp-dl-gpu/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# OpenNLP DL (GPU)
2+
3+
This module brings in `onnxruntime_gpu` bindings to the existing `opennlp-dl` module. If you are planning to run with GPU acceleration, please use this BOM.
4+
5+
You can use it in your code by adding the following as a dependency:
6+
7+
```xml
8+
<dependency>
9+
<groupId>org.apache.opennlp</groupId>
10+
<artifactId>opennlp-dl-gpu</artifactId>
11+
<version>${opennlp.version}</version>
12+
</dependency>
13+
```

opennlp-dl-gpu/pom.xml

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
<parent>
25+
<groupId>org.apache.opennlp</groupId>
26+
<artifactId>opennlp</artifactId>
27+
<version>2.3.2-SNAPSHOT</version>
28+
<relativePath>../pom.xml</relativePath>
29+
</parent>
30+
<groupId>org.apache.opennlp</groupId>
31+
<artifactId>opennlp-dl-gpu</artifactId>
32+
<name>Apache OpenNLP DL (GPU)</name>
33+
34+
<dependencies>
35+
<dependency>
36+
<groupId>org.apache.opennlp</groupId>
37+
<artifactId>opennlp-dl</artifactId>
38+
<version>${project.version}</version>
39+
<exclusions>
40+
<exclusion>
41+
<groupId>com.microsoft.onnxruntime</groupId>
42+
<artifactId>onnxruntime</artifactId>
43+
</exclusion>
44+
</exclusions>
45+
</dependency>
46+
<dependency>
47+
<groupId>com.microsoft.onnxruntime</groupId>
48+
<artifactId>onnxruntime_gpu</artifactId>
49+
<version>${onnxruntime.version}</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.junit.jupiter</groupId>
53+
<artifactId>junit-jupiter-api</artifactId>
54+
<scope>test</scope>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.junit.jupiter</groupId>
58+
<artifactId>junit-jupiter-engine</artifactId>
59+
<scope>test</scope>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.slf4j</groupId>
63+
<artifactId>slf4j-simple</artifactId>
64+
<scope>test</scope>
65+
</dependency>
66+
<dependency>
67+
<groupId>org.apache.opennlp</groupId>
68+
<artifactId>opennlp-dl</artifactId>
69+
<version>${project.version}</version>
70+
<type>test-jar</type>
71+
<scope>test</scope>
72+
</dependency>
73+
</dependencies>
74+
75+
<build>
76+
<plugins>
77+
<plugin>
78+
<groupId>org.apache.maven.plugins</groupId>
79+
<artifactId>maven-surefire-plugin</artifactId>
80+
<configuration>
81+
<dependenciesToScan>
82+
<dependency>org.apache.opennlp:opennlp-dl</dependency>
83+
</dependenciesToScan>
84+
</configuration>
85+
</plugin>
86+
</plugins>
87+
</build>
88+
89+
<profiles>
90+
<profile>
91+
<id>eval-tests</id>
92+
<properties>
93+
<opennlp.forkCount>0.5C</opennlp.forkCount>
94+
</properties>
95+
<build>
96+
<plugins>
97+
<plugin>
98+
<groupId>org.apache.maven.plugins</groupId>
99+
<artifactId>maven-surefire-plugin</artifactId>
100+
<configuration>
101+
<argLine>-Xmx4g</argLine>
102+
<includes>
103+
<include>**/*Test.java</include>
104+
<include>**/*Eval.java</include>
105+
</includes>
106+
<dependenciesToScan>
107+
<dependency>org.apache.opennlp:opennlp-dl</dependency>
108+
</dependenciesToScan>
109+
</configuration>
110+
</plugin>
111+
</plugins>
112+
</build>
113+
</profile>
114+
</profiles>
115+
</project>

opennlp-dl/pom.xml

+17
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,21 @@
6666
<scope>test</scope>
6767
</dependency>
6868
</dependencies>
69+
70+
<build>
71+
<plugins>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-jar-plugin</artifactId>
75+
<executions>
76+
<execution>
77+
<goals>
78+
<goal>test-jar</goal>
79+
</goals>
80+
</execution>
81+
</executions>
82+
</plugin>
83+
</plugins>
84+
</build>
85+
6986
</project>

pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@
561561
<module>opennlp-docs</module>
562562
<module>opennlp-distr</module>
563563
<module>opennlp-dl</module>
564+
<module>opennlp-dl-gpu</module>
564565
</modules>
565566

566567
</project>

0 commit comments

Comments
 (0)