Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
efe2f6a2
Commit
efe2f6a2
authored
Jul 21, 2018
by
Yizhi Liu
Committed by
Tianqi Chen
Jul 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[tvm4j] fix java build (#1471)
parent
ad28f5ca
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
70 additions
and
247 deletions
+70
-247
Makefile
+10
-11
jvm/README.md
+1
-1
jvm/assembly/linux-x86_64-gpu/pom.xml
+0
-55
jvm/assembly/linux-x86_64-gpu/src/main/assembly/assembly.xml
+0
-35
jvm/assembly/linux-x86_64/pom.xml
+3
-3
jvm/assembly/linux-x86_64/src/main/assembly/assembly.xml
+1
-1
jvm/assembly/osx-x86_64/pom.xml
+3
-3
jvm/assembly/osx-x86_64/src/main/assembly/assembly.xml
+1
-1
jvm/assembly/pom.xml
+4
-10
jvm/conf/log4j.properties
+7
-0
jvm/core/pom.xml
+17
-11
jvm/core/src/main/java/ml/dmlc/tvm/Base.java
+2
-8
jvm/core/src/test/java/ml/dmlc/tvm/ModuleTest.java
+10
-2
jvm/core/src/test/scripts/test_add_gpu.py
+3
-0
jvm/native/linux-x86_64-gpu/pom.xml
+0
-92
jvm/native/linux-x86_64/pom.xml
+2
-2
jvm/native/osx-x86_64/pom.xml
+2
-2
jvm/native/pom.xml
+4
-10
No files found.
Makefile
View file @
efe2f6a2
...
...
@@ -85,21 +85,20 @@ cyclean:
# JVM build rules
ifeq
($(OS),Windows_NT)
JVM_PKG_PROFILE
:=
windows
SHARED_LIBRARY_SUFFIX
:=
dll
JVM_PKG_PROFILE
:=
windows
SHARED_LIBRARY_SUFFIX
:=
dll
else
UNAME_S
:=
$(
shell
uname
-s
)
ifeq
($(UNAME_S),
Darwin)
JVM_PKG_PROFILE
:=
osx-x86_64
SHARED_LIBRARY_SUFFIX
:=
dylib
else
JVM_PKG_PROFILE
:=
linux-x86_64
SHARED_LIBRARY_SUFFIX
:=
so
endif
UNAME_S
:=
$(
shell
uname
-s
)
ifeq
($(UNAME_S),
Darwin)
JVM_PKG_PROFILE
:=
osx-x86_64
SHARED_LIBRARY_SUFFIX
:=
dylib
else
JVM_PKG_PROFILE
:=
linux-x86_64
SHARED_LIBRARY_SUFFIX
:=
so
endif
endif
JVM_TEST_ARGS
:=
$
(
if
$(JVM_TEST_ARGS)
,
$(JVM_TEST_ARGS)
,-DskipTests
-Dcheckstyle
.skip
=
true
)
JVM_PKG_PROFILE
:=
$(JVM_PKG_PROFILE)
-gpu
jvmpkg
:
(
cd
$(ROOTDIR)
/jvm
;
\
...
...
jvm/README.md
View file @
efe2f6a2
...
...
@@ -38,7 +38,7 @@ make jvmpkg
(Optional) run unit test by
```
bash
make jvmpkg
JVM_TEST_ARGS
=
"-DskipTests=false"
sh tests/scripts/task_java_unittest.sh
```
After it is compiled and packaged, you can install tvm4j in your local maven repository,
...
...
jvm/assembly/linux-x86_64-gpu/pom.xml
deleted
100644 → 0
View file @
ad28f5ca
<?xml version="1.0" encoding="UTF-8"?>
<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"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
ml.dmlc.tvm
</groupId>
<artifactId>
tvm4j-full-parent
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<groupId>
ml.dmlc.tvm
</groupId>
<artifactId>
tvm4j-full-linux-x86_64-gpu
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
TVM4J Package - Full Linux-x86_64 GPU
</name>
<packaging>
jar
</packaging>
<dependencies>
<dependency>
<groupId>
ml.dmlc.tvm
</groupId>
<artifactId>
tvm4j-core
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
ml.dmlc.tvm
</groupId>
<artifactId>
libtvm4j-linux-x86_64-gpu
</artifactId>
<version>
${project.version}
</version>
<type>
so
</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-assembly-plugin
</artifactId>
<executions>
<execution>
<phase>
package
</phase>
<goals>
<goal>
single
</goal>
</goals>
<configuration>
<appendAssemblyId>
false
</appendAssemblyId>
<descriptors>
<descriptor>
src/main/assembly/assembly.xml
</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
jvm/assembly/linux-x86_64-gpu/src/main/assembly/assembly.xml
deleted
100644 → 0
View file @
ad28f5ca
<assembly>
<id>
full
</id>
<formats>
<format>
jar
</format>
</formats>
<includeBaseDirectory>
false
</includeBaseDirectory>
<files>
<file>
<source>
../../../build/libtvm_runtime.so
</source>
<outputDirectory>
lib/native
</outputDirectory>
<fileMode>
0644
</fileMode>
</file>
</files>
<dependencySets>
<dependencySet>
<includes>
<include>
*:*:jar
</include>
</includes>
<outputDirectory>
/
</outputDirectory>
<useProjectArtifact>
true
</useProjectArtifact>
<unpack>
true
</unpack>
<scope>
runtime
</scope>
</dependencySet>
<dependencySet>
<outputDirectory>
lib/native
</outputDirectory>
<outputFileNameMapping>
libtvm4j.so
</outputFileNameMapping>
<unpack>
false
</unpack>
<useProjectArtifact>
false
</useProjectArtifact>
<useStrictFiltering>
false
</useStrictFiltering>
<includes>
<include>
ml.dmlc.tvm:libtvm4j-linux-x86_64-gpu:so
</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>
jvm/assembly/linux-x86_64
-cpu
/pom.xml
→
jvm/assembly/linux-x86_64/pom.xml
View file @
efe2f6a2
...
...
@@ -11,9 +11,9 @@
</parent>
<groupId>
ml.dmlc.tvm
</groupId>
<artifactId>
tvm4j-full-linux-x86_64
-cpu
</artifactId>
<artifactId>
tvm4j-full-linux-x86_64
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
TVM4J Package - Full Linux-x86_64
CPU-only
</name>
<name>
TVM4J Package - Full Linux-x86_64
</name>
<packaging>
jar
</packaging>
<dependencies>
...
...
@@ -24,7 +24,7 @@
</dependency>
<dependency>
<groupId>
ml.dmlc.tvm
</groupId>
<artifactId>
libtvm4j-linux-x86_64
-cpu
</artifactId>
<artifactId>
libtvm4j-linux-x86_64
</artifactId>
<version>
${project.version}
</version>
<type>
so
</type>
</dependency>
...
...
jvm/assembly/linux-x86_64
-cpu
/src/main/assembly/assembly.xml
→
jvm/assembly/linux-x86_64/src/main/assembly/assembly.xml
View file @
efe2f6a2
...
...
@@ -28,7 +28,7 @@
<useProjectArtifact>
false
</useProjectArtifact>
<useStrictFiltering>
false
</useStrictFiltering>
<includes>
<include>
ml.dmlc.tvm:libtvm4j-linux-x86_64
-cpu
:so
</include>
<include>
ml.dmlc.tvm:libtvm4j-linux-x86_64:so
</include>
</includes>
</dependencySet>
</dependencySets>
...
...
jvm/assembly/osx-x86_64
-cpu
/pom.xml
→
jvm/assembly/osx-x86_64/pom.xml
View file @
efe2f6a2
...
...
@@ -11,9 +11,9 @@
</parent>
<groupId>
ml.dmlc.tvm
</groupId>
<artifactId>
tvm4j-full-osx-x86_64
-cpu
</artifactId>
<artifactId>
tvm4j-full-osx-x86_64
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
TVM4J Package - Full OSX-x86_64
CPU-only
</name>
<name>
TVM4J Package - Full OSX-x86_64
</name>
<packaging>
jar
</packaging>
<dependencies>
...
...
@@ -24,7 +24,7 @@
</dependency>
<dependency>
<groupId>
ml.dmlc.tvm
</groupId>
<artifactId>
libtvm4j-osx-x86_64
-cpu
</artifactId>
<artifactId>
libtvm4j-osx-x86_64
</artifactId>
<version>
${project.version}
</version>
<type>
jnilib
</type>
</dependency>
...
...
jvm/assembly/osx-x86_64
-cpu
/src/main/assembly/assembly.xml
→
jvm/assembly/osx-x86_64/src/main/assembly/assembly.xml
View file @
efe2f6a2
...
...
@@ -28,7 +28,7 @@
<useProjectArtifact>
false
</useProjectArtifact>
<useStrictFiltering>
false
</useStrictFiltering>
<includes>
<include>
ml.dmlc.tvm:libtvm4j-osx-x86_64
-cpu
:jnilib
</include>
<include>
ml.dmlc.tvm:libtvm4j-osx-x86_64:jnilib
</include>
</includes>
</dependencySet>
</dependencySets>
...
...
jvm/assembly/pom.xml
View file @
efe2f6a2
...
...
@@ -18,21 +18,15 @@
<profiles>
<profile>
<id>
osx-x86_64
-cpu
</id>
<id>
osx-x86_64
</id>
<modules>
<module>
osx-x86_64
-cpu
</module>
<module>
osx-x86_64
</module>
</modules>
</profile>
<profile>
<id>
linux-x86_64
-cpu
</id>
<id>
linux-x86_64
</id>
<modules>
<module>
linux-x86_64-cpu
</module>
</modules>
</profile>
<profile>
<id>
linux-x86_64-gpu
</id>
<modules>
<module>
linux-x86_64-gpu
</module>
<module>
linux-x86_64
</module>
</modules>
</profile>
<profile>
...
...
jvm/conf/log4j.properties
0 → 100644
View file @
efe2f6a2
# for development debugging
log4j.rootLogger
=
info, stdout
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target
=
System.out
log4j.appender.stdout.layout
=
org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern
=
%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%c] [%p] - %m%n
jvm/core/pom.xml
View file @
efe2f6a2
...
...
@@ -17,23 +17,16 @@
<profiles>
<profile>
<id>
osx-x86_64
-cpu
</id>
<id>
osx-x86_64
</id>
<properties>
<platform>
osx-x86_64
-cpu
</platform>
<platform>
osx-x86_64
</platform>
<libtvm.so.filename>
libtvm_runtime.dylib
</libtvm.so.filename>
</properties>
</profile>
<profile>
<id>
linux-x86_64
-cpu
</id>
<id>
linux-x86_64
</id>
<properties>
<platform>
linux-x86_64-cpu
</platform>
<libtvm.so.filename>
libtvm_runtime.so
</libtvm.so.filename>
</properties>
</profile>
<profile>
<id>
linux-x86_64-gpu
</id>
<properties>
<platform>
linux-x86_64-gpu
</platform>
<platform>
linux-x86_64
</platform>
<libtvm.so.filename>
libtvm_runtime.so
</libtvm.so.filename>
</properties>
</profile>
...
...
@@ -92,6 +85,7 @@
<argLine>
-Djava.library.path=${project.parent.basedir}/native/${platform}/target
-Dlibtvm.so.path=${project.parent.basedir}/../build/${libtvm.so.filename}
-Dlog4j.configuration=file://${project.parent.basedir}/conf/log4j.properties
</argLine>
</configuration>
<executions>
...
...
@@ -119,5 +113,17 @@
<version>
4.11
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
<version>
1.7.25
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-simple
</artifactId>
<version>
1.7.25
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
jvm/core/src/main/java/ml/dmlc/tvm/Base.java
View file @
efe2f6a2
...
...
@@ -155,14 +155,8 @@ final class Base {
* @throws UnsatisfiedLinkError if loading fails
*/
private
static
void
tryLoadLibraryXPU
(
String
libname
,
String
arch
)
throws
UnsatisfiedLinkError
{
try
{
// try gpu first
System
.
err
.
println
(
String
.
format
(
"Try loading %s-%s-gpu from native path."
,
libname
,
arch
));
System
.
loadLibrary
(
String
.
format
(
"%s-%s-gpu"
,
libname
,
arch
));
}
catch
(
UnsatisfiedLinkError
e
)
{
System
.
err
.
println
(
String
.
format
(
"Try loading %s-%s-cpu from native path."
,
libname
,
arch
));
System
.
loadLibrary
(
String
.
format
(
"%s-%s-cpu"
,
libname
,
arch
));
}
System
.
err
.
println
(
String
.
format
(
"Try loading %s-%s from native path."
,
libname
,
arch
));
System
.
loadLibrary
(
String
.
format
(
"%s-%s"
,
libname
,
arch
));
}
// helper function definitions
...
...
jvm/core/src/test/java/ml/dmlc/tvm/ModuleTest.java
View file @
efe2f6a2
...
...
@@ -19,12 +19,16 @@ package ml.dmlc.tvm;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
static
org
.
junit
.
Assert
.*;
import
java.io.File
;
import
java.util.Random
;
public
class
ModuleTest
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ModuleTest
.
class
);
private
static
String
loadingDir
;
@BeforeClass
...
...
@@ -60,12 +64,16 @@ public class ModuleTest {
public
void
test_load_add_func_gpu
()
{
final
Random
RND
=
new
Random
(
0
);
TVMContext
ctx
=
new
TVMContext
(
"gpu"
,
0
);
if
(!
ctx
.
exist
())
{
logger
.
warn
(
"GPU does not exist. Skip the test."
);
return
;
}
Module
fadd
=
Module
.
load
(
loadingDir
+
File
.
separator
+
"add_gpu.so"
);
Module
faddDev
=
Module
.
load
(
loadingDir
+
File
.
separator
+
"add_gpu.ptx"
);
fadd
.
importModule
(
faddDev
);
TVMContext
ctx
=
new
TVMContext
(
"gpu"
,
0
);
final
int
dim
=
100
;
long
[]
shape
=
new
long
[]{
dim
};
NDArray
arr
=
NDArray
.
empty
(
shape
,
ctx
);
...
...
jvm/core/src/test/scripts/test_add_gpu.py
View file @
efe2f6a2
...
...
@@ -4,6 +4,9 @@ import tvm
from
tvm.contrib
import
cc
,
util
def
test_add
(
target_dir
):
if
not
tvm
.
module
.
enabled
(
"cuda"
):
print
(
"skip
%
s because cuda is not enabled..."
%
__file__
)
return
n
=
tvm
.
var
(
"n"
)
A
=
tvm
.
placeholder
((
n
,),
name
=
'A'
)
B
=
tvm
.
placeholder
((
n
,),
name
=
'B'
)
...
...
jvm/native/linux-x86_64-gpu/pom.xml
deleted
100644 → 0
View file @
ad28f5ca
<?xml version="1.0" encoding="UTF-8"?>
<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"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
ml.dmlc.tvm
</groupId>
<artifactId>
tvm4j-native-parent
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<artifactId>
libtvm4j-linux-x86_64-gpu
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
TVM4J Package - Native Linux-x86_64 GPU
</name>
<url>
http://maven.apache.org
</url>
<packaging>
so
</packaging>
<dependencies>
<dependency>
<groupId>
ml.dmlc.tvm
</groupId>
<artifactId>
tvm4j-core
</artifactId>
<version>
${project.version}
</version>
<type>
jar
</type>
<scope>
compile
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
</plugin>
<plugin>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
native-maven-plugin
</artifactId>
<extensions>
true
</extensions>
<configuration>
<!-- trigger javah -->
<javahOS>
linux
</javahOS>
<compilerProvider>
generic-classic
</compilerProvider>
<compilerExecutable>
${cxx}
</compilerExecutable>
<linkerExecutable>
${cxx}
</linkerExecutable>
<sources>
<source>
<directory>
../src/main/native
</directory>
<fileNames>
<fileName>
ml_dmlc_tvm_native_c_api.cc
</fileName>
</fileNames>
</source>
</sources>
<compilerStartOptions>
<compilerStartOption>
-std=c++0x
</compilerStartOption>
</compilerStartOptions>
<compilerEndOptions>
<compilerEndOption>
-I../../../include
</compilerEndOption>
<compilerEndOption>
${cflags}
</compilerEndOption>
</compilerEndOptions>
<linkerStartOptions>
<linkerStartOption>
-shared
</linkerStartOption>
</linkerStartOptions>
<linkerEndOptions>
<linkerEndOption>
${ldflags}
</linkerEndOption>
</linkerEndOptions>
</configuration>
<executions>
<execution>
<id>
javah
</id>
<phase>
generate-sources
</phase>
<configuration>
<javahOS>
linux
</javahOS>
<javahProvider>
default
</javahProvider>
<javahOutputDirectory>
${project.build.directory}/custom-javah
</javahOutputDirectory>
<workingDirectory>
${basedir}
</workingDirectory>
<javahOutputFileName>
ml_dmlc_tvm_native_c_api.h
</javahOutputFileName>
<javahClassNames>
<javahClassName>
ml.dmlc.tvm.LibInfo
</javahClassName>
</javahClassNames>
</configuration>
<goals>
<goal>
javah
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
jvm/native/linux-x86_64
-cpu
/pom.xml
→
jvm/native/linux-x86_64/pom.xml
View file @
efe2f6a2
...
...
@@ -10,9 +10,9 @@
<relativePath>
../pom.xml
</relativePath>
</parent>
<artifactId>
libtvm4j-linux-x86_64
-cpu
</artifactId>
<artifactId>
libtvm4j-linux-x86_64
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
TVM4J Package - Native Linux-x86_64
CPU-only
</name>
<name>
TVM4J Package - Native Linux-x86_64
</name>
<url>
http://maven.apache.org
</url>
<packaging>
so
</packaging>
...
...
jvm/native/osx-x86_64
-cpu
/pom.xml
→
jvm/native/osx-x86_64/pom.xml
View file @
efe2f6a2
...
...
@@ -10,9 +10,9 @@
<relativePath>
../pom.xml
</relativePath>
</parent>
<artifactId>
libtvm4j-osx-x86_64
-cpu
</artifactId>
<artifactId>
libtvm4j-osx-x86_64
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
TVM4J Package - Native OSX-x86_64
CPU-only
</name>
<name>
TVM4J Package - Native OSX-x86_64
</name>
<url>
http://maven.apache.org
</url>
<packaging>
jnilib
</packaging>
...
...
jvm/native/pom.xml
View file @
efe2f6a2
...
...
@@ -17,21 +17,15 @@
<profiles>
<profile>
<id>
osx-x86_64
-cpu
</id>
<id>
osx-x86_64
</id>
<modules>
<module>
osx-x86_64
-cpu
</module>
<module>
osx-x86_64
</module>
</modules>
</profile>
<profile>
<id>
linux-x86_64
-cpu
</id>
<id>
linux-x86_64
</id>
<modules>
<module>
linux-x86_64-cpu
</module>
</modules>
</profile>
<profile>
<id>
linux-x86_64-gpu
</id>
<modules>
<module>
linux-x86_64-gpu
</module>
<module>
linux-x86_64
</module>
</modules>
</profile>
</profiles>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment