Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nGraph Preset initial commit #642

Merged
merged 53 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
f7b2a98
nGraph Preset initial commit
EmergentOrder Nov 19, 2018
a1b76fe
Don't need to patch tensor
EmergentOrder Nov 19, 2018
176d8dc
Add RuntimeTensor
EmergentOrder Nov 19, 2018
d263539
Add RuntimeTensor part 2
EmergentOrder Nov 19, 2018
960a2e4
Add runtime::Backend
EmergentOrder Nov 19, 2018
5a75072
Add ONNXIFI nGraph Backend
EmergentOrder Nov 20, 2018
69b4190
Add nGraph to .travis.yml
EmergentOrder Nov 20, 2018
4cd4b5a
Add Backend Manager
EmergentOrder Nov 20, 2018
0ffa40c
Use download instead of git clone; define nGraph version; add header
EmergentOrder Nov 27, 2018
9e813d2
Build and install ncurses
EmergentOrder Nov 27, 2018
73cca96
add symlink for libtinfo
EmergentOrder Nov 27, 2018
94f3dc2
Add paths and flags
EmergentOrder Nov 27, 2018
adbc398
Fix reference to onnx; use INSTALL_PATH for ngraph install
EmergentOrder Nov 28, 2018
e5a3ba3
Don't patch element_type.hpp
EmergentOrder Nov 28, 2018
08aee10
Add ngraph to top-level pom.xml and cppbuild.sh; use CentOS 7 for ngr…
EmergentOrder Nov 30, 2018
2495374
Add from<X> functions; skip BackendManager functions
EmergentOrder Nov 30, 2018
f5f01ec
Update generated ngraph.java
EmergentOrder Nov 30, 2018
41526e3
Add ngraph to top-level platform pom and remove macosx (for now) from…
EmergentOrder Nov 30, 2018
16f937e
Fix typo
EmergentOrder Dec 1, 2018
7a9f8ad
Link cpu_backend to resolve 'undefined symbol'
EmergentOrder Dec 1, 2018
e56c4be
Don't copy headers and so files unless necessary; link codegen lib
EmergentOrder Dec 1, 2018
63ff040
Fix build by restoring onnxifi.h
EmergentOrder Dec 1, 2018
308d20c
Relocate onnxifi.h
EmergentOrder Dec 1, 2018
88b31b6
Relocate onnxifi.h
EmergentOrder Dec 1, 2018
549baa0
Restore libonnxifi.so
EmergentOrder Dec 1, 2018
f395c40
Update generated ngraph.java
EmergentOrder Dec 1, 2018
b8eb5a4
Update nGraph version; attempt to fix issue with libtbb
EmergentOrder Dec 1, 2018
7a1d725
Update backend_manager.hpp patch for nGraph 0.10.1
EmergentOrder Dec 1, 2018
7f036ce
Update backend_manager.hpp patch for nGraph 0.10.1 take 2
EmergentOrder Dec 1, 2018
d53651a
Update nGraph version in platform pom; Patch ngraph cpu runtime to no…
EmergentOrder Dec 1, 2018
a76964b
use ; re-enable TBB
EmergentOrder Dec 2, 2018
bd55477
Fix libtbb
EmergentOrder Dec 2, 2018
efd7c95
Build nGraph without unit tests
EmergentOrder Dec 4, 2018
396e9d9
Disable tools build
EmergentOrder Dec 5, 2018
14bf2ee
Clean up
EmergentOrder Dec 6, 2018
6201366
Copy .so files so that hopefully Travis can find them
EmergentOrder Dec 7, 2018
22aa148
Make Travis happy
EmergentOrder Dec 8, 2018
aa43ade
Temporarily disable other travis and appveyor builds
EmergentOrder Dec 9, 2018
21451e6
use libtbb.so.2
EmergentOrder Dec 9, 2018
82139ad
link TBB correctly
EmergentOrder Dec 14, 2018
d38fa61
Add node, tensor, value_info, etc.
EmergentOrder Dec 20, 2018
5c2be50
add ngraph/op/constant.hpp
EmergentOrder Dec 28, 2018
f7cfd8d
Merge branch 'master' of https://github.com/bytedeco/javacpp-presets …
EmergentOrder Jan 4, 2019
854097d
Bump to trigger Travis build
EmergentOrder Jan 4, 2019
7bf06c7
Add onnx.hpp and modify it to accept a data string rather than an inp…
EmergentOrder Jan 15, 2019
18b7f53
Merge branch 'ngraph' of https://github.com/EmergentOrder/javacpp-pre…
EmergentOrder Jan 15, 2019
bd6a279
Restore appveyor and travis builds
EmergentOrder Jan 16, 2019
263e670
Merge remote-tracking branch 'upstream/master' into ngraph
saudet Jan 17, 2019
ac6fb32
Clean up, fix formatting a bit, and add license files
saudet Jan 17, 2019
18a733d
Add README.md and adjust presets to support example
saudet Jan 17, 2019
aefcb8d
Add required dependencies on MKL-DNN and ncurses
saudet Jan 17, 2019
b46bd6c
Update presets for nGraph 0.11.1
saudet Jan 17, 2019
556cb83
Merge remote-tracking branch 'upstream/master' into ngraph
saudet Jan 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ matrix:
env: PROJ=onnx OS=linux-x86_64
install: true
script: ./ci/install-travis.sh
- os: linux
env: PROJ=ngraph OS=linux-x86_64
install: true
script: ./ci/install-travis.sh
- os: linux
env: PROJ=liquidfun OS=linux-x86_64
install: true
Expand Down
2 changes: 1 addition & 1 deletion ci/install-travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then export JAVA_HOME=$(/usr/libexec/java_hom
if [[ "$OS" == "linux-x86" ]] || [[ "$OS" == "linux-x86_64" ]] || [[ "$OS" =~ android ]]; then
CENTOS_VERSION=6
SCL_ENABLE="devtoolset-6 python27"
if [[ "cpython mxnet tensorflow onnx skia " =~ "$PROJ " ]] || [[ "$OS" =~ android ]]; then
if [[ "cpython mxnet tensorflow onnx ngraph skia " =~ "$PROJ " ]] || [[ "$OS" =~ android ]]; then
CENTOS_VERSION=7
SCL_ENABLE="python36-devel python36-setuptools"
fi
Expand Down
2 changes: 1 addition & 1 deletion cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function sedinplace {
}

if [[ -z ${PROJECTS:-} ]]; then
PROJECTS=(opencv ffmpeg flycapture spinnaker libdc1394 libfreenect libfreenect2 librealsense videoinput artoolkitplus chilitags flandmark hdf5 mkl mkl-dnn openblas arpack-ng cminpack fftw gsl cpython llvm libpostal leptonica tesseract caffe cuda mxnet tensorflow tensorrt ale onnx liquidfun skia systems)
PROJECTS=(opencv ffmpeg flycapture spinnaker libdc1394 libfreenect libfreenect2 librealsense videoinput artoolkitplus chilitags flandmark hdf5 mkl mkl-dnn openblas arpack-ng cminpack fftw gsl cpython llvm libpostal leptonica tesseract caffe cuda mxnet tensorflow tensorrt ale onnx ngraph liquidfun skia systems)
fi

for PROJECT in ${PROJECTS[@]}; do
Expand Down
11 changes: 11 additions & 0 deletions ngraph/CMakeLists.txt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- CMakeLists.txt.ORIG 2018-12-01 16:28:12.228687268 -0500
+++ CMakeLists.txt 2018-12-01 16:28:28.676543930 -0500
@@ -195,7 +195,7 @@
endif()

add_dependencies(cpu_backend ext_mkldnn ext_eigen)
- target_link_libraries(cpu_backend PUBLIC ngraph libmkldnn libeigen libjson libtbb)
saudet marked this conversation as resolved.
Show resolved Hide resolved
+ target_link_libraries(cpu_backend PUBLIC ngraph libmkldnn libeigen libjson)
if (NOT NGRAPH_DEX_ONLY)
target_link_libraries(cpu_backend PUBLIC codegen)
endif()
30 changes: 30 additions & 0 deletions ngraph/backend.hpp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--- backend.hpp.orig 2018-11-09 20:11:42.216762981 -0500
+++ backend.hpp 2018-11-09 20:08:37.998002342 -0500
@@ -33,18 +33,18 @@
class Backend
{
public:
- Backend(const Backend&) = delete;
- Backend& operator=(const Backend&) = delete;
+// Backend(const Backend&) = delete;
+// Backend& operator=(const Backend&) = delete;

- Backend(Backend&&) = default;
- Backend& operator=(Backend&&) = default;
+// Backend(Backend&&) = default;
+// Backend& operator=(Backend&&) = default;

- Backend() = delete;
+// Backend() = delete;

- explicit Backend(const std::string& type)
- : m_type{type}
- {
- }
+
+
+
+

const std::string& get_type() const { return m_type; }
bool compile(const std::shared_ptr<Function>& function) const
11 changes: 11 additions & 0 deletions ngraph/backend_manager.hpp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- backend_manager.hpp.ORIG 2018-12-01 14:38:11.990225050 -0500
+++ backend_manager.hpp 2018-12-01 14:38:55.181672255 -0500
@@ -19,7 +19,7 @@
#include <cstddef> // std::size_t, std::uintptr_t
#include <map> // std::map
#include <mutex> // std::mutex
-#include <onnxifi.h>
+#include "onnxifi.h"

#include "backend.hpp"
#include "ngraph/runtime/backend.hpp"
94 changes: 94 additions & 0 deletions ngraph/cppbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash
# This file is meant to be included by the parent cppbuild.sh script
if [[ -z "$PLATFORM" ]]; then
pushd ..
bash cppbuild.sh "$@" ngraph
popd
exit
fi

if [[ $PLATFORM == windows* ]]; then
#No Windows support yet
echo "Error: Platform \"$PLATFORM\" is not supported"
exit 1
fi

export NGRAPH="0.10.1"
export NCURSES=6.1

download https://github.com/NervanaSystems/ngraph/archive/v$NGRAPH.tar.gz v$NGRAPH.tar.gz
download https://ftp.gnu.org/pub/gnu/ncurses/ncurses-$NCURSES.tar.gz ncurses.tar.gz
mkdir -p "$PLATFORM"
cd "$PLATFORM"
INSTALL_PATH=`pwd`

echo "Decompressing archives..."
tar --totals -xf ../v$NGRAPH.tar.gz
tar --totals -xf ../ncurses.tar.gz

export LIBRARY_PATH="$INSTALL_PATH/lib"
export PATH="$PATH:$INSTALL_PATH/bin"
export CFLAGS="-I$INSTALL_PATH/include"
export CXXFLAGS="-I$INSTALL_PATH/include"

cd ncurses-$NCURSES
./configure "--prefix=$INSTALL_PATH" "--with-shared" CFLAGS=-fPIC CXXFLAGS=-fPIC
make -j $MAKEJ V=0
make install

cd ..

cd lib

ln -s libncurses.so.6 libtinfo.so.6
ln -s libncurses.so.6 libtinfo.so

cd ..

cd ngraph-$NGRAPH
rm -rf build
mkdir build && cd build
#-DNGRAPH_TBB_ENABLE=FALSE


patch ../src/ngraph/frontend/onnx_import/onnx.cpp ../../../../onnx.cpp.patch
patch ../src/ngraph/frontend/onnx_import/onnx.hpp ../../../../onnx.hpp.patch

#patch ../src/ngraph/runtime/cpu/CMakeLists.txt ../../../../CMakeLists.txt.patch
$CMAKE .. -DNGRAPH_UNIT_TEST_ENABLE=FALSE -DNGRAPH_TOOLS_ENABLE=FALSE -DNGRAPH_ONNX_IMPORT_ENABLE=ON -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DNGRAPH_USE_PREBUILT_LLVM=TRUE -DNGRAPH_ONNXIFI_ENABLE=TRUE
make -j $MAKEJ
make install

#mkdir -p ../../include/ngraph ../../include/ngraph/op ../../include/ngraph/pass ../../include/ngraph/state ../../include/ngraph/codegen ../../include/ngraph/op/util ../../include/ngraph/autodiff/ ../../include/ngraph/descriptor ../../include/ngraph/descriptor/layout ../../include/ngraph/runtime ../../include/ngraph/runtime/cpu ../../include/ngraph/type ../../include/onnx ../../lib

#mkdir ../../include/onnx

cp -r ../src/ngraph/frontend/onnx_import/core/ ../../include/
cp -r ../src/ngraph/frontend/onnx_import/utils/ ../../include/
cp -r ../src/ngraph/frontend/onnx_import/utils/ ../../include/ngraph/frontend/onnx_import/op/
cp -r ../src/ngraph/frontend/onnx_import/exceptions.hpp ../../include/


patch ../../include/ngraph/frontend/onnxifi/backend.hpp ../../../../backend.hpp.patch
patch ../../include/ngraph/frontend/onnxifi/backend_manager.hpp ../../../../backend_manager.hpp.patch
saudet marked this conversation as resolved.
Show resolved Hide resolved
#patch ../src/ngraph/descriptor/tensor.hpp ../../../../tensor.hpp.patch


#execstack -c ../../lib/libtbb.so.2

cp src/ngraph/frontend/onnxifi/libonnxifi-ngraph.so ../../lib/
cp src/ngraph/libngraph.so ../../lib/
cp src/ngraph/libcpu_backend.so ../../lib/
cp src/ngraph/codegen/libcodegen.so ../../lib/
cp src/ngraph/runtime/cpu/tbb_build/tbb_release/libtbb.so.2 ../../lib/
cp onnx/bin/libonnxifi.so ../../lib/

ln -sf libtbb.so.2 ../../lib/libtbb.so

cp onnx/src/onnx/onnxifi.h ../../include/ngraph/frontend/onnxifi/
#cp onnx/src/onnx/onnxifi.h ../../include/onnx/
#cp ../src/ngraph/frontend/onnx_import/onnx.hpp ../../include/ngraph/
#cp ../src/ngraph/frontend/onnxifi/backend.hpp ../../include/ngraph/frontend/onnxifi/
#cp ../src/ngraph/frontend/onnxifi/backend_manager.hpp ../../include/ngraph/frontend/onnxifi/

cd ../../..
41 changes: 41 additions & 0 deletions ngraph/element_type.hpp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--- cppbuild/linux-x86_64/include/ngraph/type/element_type.hpp 2018-11-09 08:30:42.628084431 -0500
+++ element_type.hpp 2018-11-09 08:34:47.872535397 -0500
@@ -110,38 +110,6 @@
std::string m_cname{"dynamic"};
};

- template <typename T>
- const Type& from()
- {
- throw std::invalid_argument("Unknown type");
- }
- template <>
- const Type& from<char>();
- template <>
- const Type& from<bool>();
- template <>
- const Type& from<float>();
- template <>
- const Type& from<double>();
- template <>
- const Type& from<int8_t>();
- template <>
- const Type& from<int16_t>();
- template <>
- const Type& from<int32_t>();
- template <>
- const Type& from<int64_t>();
- template <>
- const Type& from<uint8_t>();
- template <>
- const Type& from<uint16_t>();
- template <>
- const Type& from<uint32_t>();
- template <>
- const Type& from<uint64_t>();
- template <>
- const Type& from<ngraph::bfloat16>();
-
std::ostream& operator<<(std::ostream& out, const ngraph::element::Type& obj);
}
}
70 changes: 70 additions & 0 deletions ngraph/onnx.cpp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
--- onnx.cpp.ORIG 2019-01-15 13:26:42.108157168 -0500
+++ onnx.cpp 2019-01-15 13:41:27.859816460 -0500
@@ -31,18 +31,10 @@
{
namespace error
{
- struct file_open : ngraph_error
+ struct data_parse : ngraph_error
{
- explicit file_open(const std::string& path)
- : ngraph_error{"failure opening file:" + path}
- {
- }
- };
-
- struct stream_parse : ngraph_error
- {
- explicit stream_parse(std::istream&)
- : ngraph_error{"failure parsing data from the stream"}
+ explicit data_parse(const std::string& data)
+ : ngraph_error{"failure parsing data from the string"}
{
}
};
@@ -50,13 +42,13 @@
} // namespace error
} // namespace detail

- std::vector<std::shared_ptr<Function>> load_onnx_model(std::istream& sin,
+ std::vector<std::shared_ptr<Function>> load_onnx_model(const std::string& data,
const Weights& weights)
{
onnx::ModelProto model_proto;
- if (!model_proto.ParseFromIstream(&sin))
+ if (!model_proto.ParseFromString(data))
{
- throw detail::error::stream_parse{sin};
+ throw detail::error::data_parse{data};
}
std::vector<std::shared_ptr<Function>> output_functions;
Model model{model_proto};
@@ -69,28 +61,6 @@
return output_functions;
}

- std::vector<std::shared_ptr<Function>> load_onnx_model(const std::string& path,
- const Weights& weights)
- {
- std::ifstream ifs{path, std::ios::in | std::ios::binary};
- if (!ifs.is_open())
- {
- throw detail::error::file_open{path};
- }
- return load_onnx_model(ifs, weights);
- }
-
- std::shared_ptr<Function> import_onnx_function(std::istream& sin, const Weights& weights)
- {
- return load_onnx_model(sin, weights).front();
- }
-
- std::shared_ptr<Function> import_onnx_function(const std::string& path,
- const Weights& weights)
- {
- return load_onnx_model(path, weights).front();
- }
-
void register_operator(const std::string& name,
std::int64_t version,
const std::string& domain,
48 changes: 48 additions & 0 deletions ngraph/onnx.hpp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--- onnx.hpp.ORIG 2019-01-15 13:26:36.332226565 -0500
+++ onnx.hpp 2019-01-15 13:41:54.215455942 -0500
@@ -50,44 +50,8 @@
/// the model will take precedence).
/// \return The function returns a vector of nGraph functions. The number of functions
/// depends on number of outputs from ONNX graph.
- std::vector<std::shared_ptr<Function>> load_onnx_model(std::istream& sin,
+ std::vector<std::shared_ptr<Function>> load_onnx_model(const std::string& data,
const Weights& weights = {});
- /// \brief Convert an ONNX model to nGraph functions
- /// The function translated serialized ONNX model to nGraph functions. The ONNX model
- /// is read from ONNX file.
- /// \param filename file name (relative or absolute path name),
- /// \param weights weights associated with the model. If weights are embedded into
- /// the model this parameter shall be empty. Having weights in a model
- /// and providing through this parameters is invalid (the weights from
- /// the model will take precedence).
- /// \return The function returns a vector of nGraph functions. The number of functions
- /// depends on number of outputs from ONNX graph.
- std::vector<std::shared_ptr<Function>> load_onnx_model(const std::string& filename,
- const Weights& weights = {});
-
- /// \brief Convert an ONNX model to nGraph function
- /// The function translated serialized ONNX model to nGraph function. The serialized
- /// ONNX model is read from input stream.
- /// \param sin input stream (e.g. file stream, memory stream, etc),
- /// \param weights weights associated with the model. If weights are embedded into
- /// the model this parameter shall be empty. Having weights in a model
- /// and providing through this parameters is invalid (the weights from
- /// the model will take precedence).
- /// \return The function returns a nGraph function representing single output from graph.
- std::shared_ptr<Function> import_onnx_function(std::istream& sin,
- const Weights& weights = {});
-
- /// \brief Convert an ONNX model to nGraph functions
- /// The function translated serialized ONNX model to nGraph functions. The ONNX model
- /// is read from ONNX file.
- /// \param filename file name (relative or absolute path name),
- /// \param weights weights associated with the model. If weights are embedded into
- /// the model this parameter shall be empty. Having weights in a model
- /// and providing through this parameters is invalid (the weights from
- /// the model will take precedence).
- /// \return The function returns a nGraph function representing single output from graph.
- std::shared_ptr<Function> import_onnx_function(const std::string& filename,
- const Weights& weights = {});

} // namespace onnx_import

56 changes: 56 additions & 0 deletions ngraph/platform/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp-presets</artifactId>
<version>1.4.4-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>

<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>ngraph-platform</artifactId>
<version>0.10.1-${project.parent.version}</version>
<name>JavaCPP Presets Platform for nGraph</name>

<properties>
<javacpp.moduleId>ngraph</javacpp.moduleId>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.linux-x86_64}</classifier>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<configuration>
<archive>
<manifestEntries>
<Class-Path>${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86_64.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Loading