Skip to content

Commit

Permalink
* Include IR, optimizer, and version converter for ONNX (pull #622)
Browse files Browse the repository at this point in the history
 * Add build for Mac OS X to presets for ONNX (issue #638)
  • Loading branch information
EmergentOrder authored and saudet committed Oct 31, 2018
1 parent 3b3f34d commit 0c22215
Show file tree
Hide file tree
Showing 7 changed files with 825 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,11 @@ matrix:
env: PROJ=ale OS=macosx-x86_64
install: true
script: ./ci/install-travis.sh
- os: osx
osx_image: xcode8.3
env: PROJ=onnx OS=macosx-x86_64
install: true
script: ./ci/install-travis.sh
- os: osx
osx_image: xcode7.3
env: PROJ=liquidfun OS=macosx-x86_64
Expand Down
15 changes: 13 additions & 2 deletions onnx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ We can use [Maven 3](http://maven.apache.org/) to download and install automatic
<modelVersion>4.0.0</modelVersion>
<groupId>org.bytedeco.javacpp-presets.onnx</groupId>
<artifactId>loadmodel</artifactId>
<version>1.4.3</version>
<version>1.4.4-SNAPSHOT</version>
<properties>
<exec.mainClass>LoadModel</exec.mainClass>
</properties>
<dependencies>
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>onnx-platform</artifactId>
<version>1.3.0-1.4.3</version>
<version>1.3.0-1.4.4-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Expand All @@ -65,6 +65,17 @@ public class LoadModel {
ModelProto model = new ModelProto();
ParseProtoFromBytes(model, new BytePointer(bytes), bytes.length);

check_model(model);

InferShapes(model);

StringVector passes = new StringVector("eliminate_nop_transpose", "eliminate_nop_pad", "fuse_consecutive_transposes", "fuse_transpose_into_gemm");
Optimize(model, passes);

check_model(model);

ConvertVersion(model, 8);

System.out.println(model.graph().input_size());
}
}
Expand Down
9 changes: 7 additions & 2 deletions onnx/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,26 @@ make install
cd ../onnx-$ONNX
rm -df third_party/pybind11
ln -sf $INSTALL_PATH/pybind11-$PYBIND third_party/pybind11
# work around issue in Xcode's version of Clang
sedinplace 's/const std::string /std::string /g' onnx/defs/schema.h

#to build with "Traditional ML" support. Untested.
export ONNX_ML=1
export CMAKE_BUILD_DIR=.setuptools-cmake-build/
export CMAKE_ARGS=-DBUILD_SHARED_LIBS=ON
python3 setup.py --quiet build

mkdir -p ../include/onnx ../include/onnx/common ../include/onnx/defs ../include/onnx/optimizer/ ../include/onnx/version_converter
mkdir -p ../include/onnx ../include/onnx/common ../include/onnx/defs ../include/onnx/optimizer/ ../include/onnx/optimizer/passes ../include/onnx/version_converter ../include/onnx/version_converter/adapters ../include/onnx/shape_inference

cp onnx/*.h ../include/onnx/
cp onnx/common/*.h ../include/onnx/common/
cp onnx/defs/*.h ../include/onnx/defs/
cp onnx/optimizer/*.h ../include/onnx/optimizer/
cp onnx/optimizer/passes/*.h ../include/onnx/optimizer/passes/
cp onnx/version_converter/*.h ../include/onnx/version_converter/
cp onnx/version_converter/adapters/*.h ../include/onnx/version_converter/adapters/
cp onnx/shape_inference/*.h ../include/onnx/shape_inference/
cp $CMAKE_BUILD_DIR/onnx/*.h ../include/onnx/
cp $CMAKE_BUILD_DIR/*.so ../lib
cp $CMAKE_BUILD_DIR/libonnx* ../lib

cd ../..
8 changes: 7 additions & 1 deletion onnx/platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<version>${project.version}</version>
<classifier>${javacpp.platform.linux-x86_64}</classifier>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.macosx-x86_64}</classifier>
</dependency>
</dependencies>

<build>
Expand All @@ -43,7 +49,7 @@
<configuration>
<archive>
<manifestEntries>
<Class-Path>${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86_64.jar</Class-Path>
<Class-Path>${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86_64.jar ${javacpp.moduleId}-macosx-x86_64.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
Expand Down
Loading

0 comments on commit 0c22215

Please sign in to comment.