Skip to content

Commit

Permalink
Update Java build with:
Browse files Browse the repository at this point in the history
* An initial README.md file

* Copy of license files and libraries for GFortran

* Support for MXNET_LIBRARY_PATH
  • Loading branch information
saudet committed Jan 25, 2021
1 parent d1d5926 commit 0966818
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
32 changes: 32 additions & 0 deletions java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--- Licensed to the Apache Software Foundation (ASF) under one -->
<!--- or more contributor license agreements. See the NOTICE file -->
<!--- distributed with this work for additional information -->
<!--- regarding copyright ownership. The ASF licenses this file -->
<!--- to you under the Apache License, Version 2.0 (the -->
<!--- "License"); you may not use this file except in compliance -->
<!--- with the License. You may obtain a copy of the License at -->

<!--- http://www.apache.org/licenses/LICENSE-2.0 -->

<!--- Unless required by applicable law or agreed to in writing, -->
<!--- software distributed under the License 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. -->

MXNet Java Package
====================
This directory and nested files contain MXNet Java package and language binding.

## Installation
To install requirements for MXNet Java package, visit MXNet [Install Instruction](https://mxnet.apache.org/get_started)

## Running the unit tests
For running unit tests, you will need the [Gradle build system](https://gradle.org/). To install:
* https://gradle.org/install/

Once ```gradle``` is installed, run the following from MXNet java subdirectory (please make sure the installation path of ```gradle``` is included in your ```$PATH``` environment variable):
```
gradle clean build test -Dorg.gradle.jvmargs=-Xmx2048m
```
11 changes: 11 additions & 0 deletions java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,18 @@ javacppBuildCompiler {
copyLibs = true
}

task copyLicenses(type: Copy) {
from(["$projectDir/..", "$projectDir/../tools/dependencies/"]) {
include 'DISCLAIMER-WIP'
include 'LICENSE'
include 'NOTICE'
include 'LICENSE.binary.dependencies'
}
into "$buildDir/resources/main/META-INF"
}

jar {
dependsOn copyLicenses
manifest {
attributes 'Class-Path': configurations.runtimeClasspath.collect { it.getName() }.join(' ')
}
Expand Down
10 changes: 9 additions & 1 deletion java/build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/bin/bash
set -e

if [[ -n "$MXNET_LIBRARY_PATH" ]]; then
echo Found MXNET_LIBRARY_PATH=$MXNET_LIBRARY_PATH
mkdir -p build/$PLATFORM$PLATFORM_EXTENSION/lib
cp -RLf ../include build/$PLATFORM$PLATFORM_EXTENSION/include
cp $MXNET_LIBRARY_PATH build/$PLATFORM$PLATFORM_EXTENSION/lib
exit 0
fi

mkdir -p build/$PLATFORM$PLATFORM_EXTENSION/cmake
pushd build/$PLATFORM$PLATFORM_EXTENSION/cmake

if [[ -d "C:/msys64" ]] && [[ -z ${OpenBLAS_home:-} ]]; then
export OpenBLAS_HOME=C:/msys64/mingw64/include/OpenBlas/
export OpenBLAS_HOME=C:/msys64/mingw64/include/OpenBLAS/
export OpenBLAS=C:/msys64/mingw64/lib/
fi

Expand Down
9 changes: 7 additions & 2 deletions java/src/main/java/org/apache/mxnet/internal/c_api/mxnet.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@
define = {"DMLC_USE_CXX11 1", "MSHADOW_USE_CBLAS 1", "MSHADOW_IN_CXX11 1", "MSHADOW_USE_CUDA 0", "MSHADOW_USE_F16C 0", "MXNET_USE_TVM_OP 0"},
include = {"dlpack/dlpack.h", "mxnet/c_api.h", "mxnet/runtime/c_runtime_api.h", "nnvm/c_api.h"},
link = "mxnet",
linkpath = "/usr/local/lib/"
linkpath = {"/usr/lib64/", "/usr/lib/", "/usr/local/lib/"},
preload = {"[email protected]", "[email protected]", "[email protected]"},
preloadpath = {"/usr/local/lib/gcc/10/", "/usr/local/lib/gcc/9/", "/usr/local/lib/gcc/8/",
"/usr/local/lib/gcc/7/", "/usr/local/lib/gcc/6/", "/usr/local/lib/gcc/5/"}
),
@Platform(
value = "windows",
link = "libmxnet"
link = "libmxnet",
preload = {"libwinpthread-1", "libgcc_s_seh-1", "libgfortran-5", "libgfortran-4", "libgfortran-3", "libopenblas"},
preloadpath = "C:/msys64/mingw64/bin/"
)
},
target = "org.apache.mxnet.internal.c_api",
Expand Down

0 comments on commit 0966818

Please sign in to comment.