Commit 3442879f authored by Sang Ik Lee's avatar Sang Ik Lee Committed by Robert Kimball

Don't create a separate .so for python onnx importer. (#2782)

* Don't create a separate .so for python onnx importer.

* Pass outer make's -j values to sub make used in python_wheel.
parent 733fbd90
...@@ -38,7 +38,7 @@ add_custom_command( ...@@ -38,7 +38,7 @@ add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/python/dist/ OUTPUT ${CMAKE_BINARY_DIR}/python/dist/
POST_BUILD POST_BUILD
WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR}
COMMAND make -C ../ DESTDIR=python/_install install && bash build_wheel.sh COMMAND $(MAKE) -C ../ DESTDIR=python/_install install && bash build_wheel.sh
) )
add_custom_target(python_wheel DEPENDS ngraph ${CMAKE_BINARY_DIR}/python/dist/) add_custom_target(python_wheel DEPENDS ngraph ${CMAKE_BINARY_DIR}/python/dist/)
......
...@@ -32,5 +32,5 @@ else: ...@@ -32,5 +32,5 @@ else:
flags = sys.getdlopenflags() | ctypes.RTLD_GLOBAL flags = sys.getdlopenflags() | ctypes.RTLD_GLOBAL
sys.setdlopenflags(flags) sys.setdlopenflags(flags)
from _pyngraph_onnx_import import import_onnx_model from _pyngraph import import_onnx_model
from _pyngraph_onnx_import import import_onnx_model_file from _pyngraph import import_onnx_model_file
...@@ -14,13 +14,13 @@ ...@@ -14,13 +14,13 @@
// limitations under the License. // limitations under the License.
//***************************************************************************** //*****************************************************************************
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <iterator> #include <iterator>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "ngraph/axis_set.hpp" // ngraph::AxisSet #include "ngraph/axis_set.hpp" // ngraph::AxisSet
#include "pyngraph/axis_set.hpp" #include "pyngraph/axis_set.hpp"
......
...@@ -13,13 +13,14 @@ ...@@ -13,13 +13,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//***************************************************************************** //*****************************************************************************
#include <iterator>
#include <sstream>
#include <string>
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
#include <pybind11/stl.h> #include <pybind11/stl.h>
#include <iterator>
#include <sstream>
#include <string>
#include "ngraph/coordinate_diff.hpp" // ngraph::CoordinateDiff #include "ngraph/coordinate_diff.hpp" // ngraph::CoordinateDiff
#include "pyngraph/coordinate_diff.hpp" #include "pyngraph/coordinate_diff.hpp"
......
//***************************************************************************** //*****************************************************************************
// Copyright 2017-2018 Intel Corporation // Copyright 2017-2019 Intel Corporation
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
......
...@@ -14,10 +14,12 @@ ...@@ -14,10 +14,12 @@
// limitations under the License. // limitations under the License.
//***************************************************************************** //*****************************************************************************
#include <istream> #if defined(NGRAPH_ONNX_IMPORT_ENABLE)
#include <memory>
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
#include <pybind11/stl.h> #include <pybind11/stl.h>
#include <istream>
#include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -43,3 +45,4 @@ void regmodule_pyngraph_onnx_import(py::module mod) ...@@ -43,3 +45,4 @@ void regmodule_pyngraph_onnx_import(py::module mod)
mod.def("import_onnx_model", &import_onnx_model); mod.def("import_onnx_model", &import_onnx_model);
mod.def("import_onnx_model_file", &import_onnx_model_file); mod.def("import_onnx_model_file", &import_onnx_model_file);
} }
#endif
...@@ -15,9 +15,11 @@ ...@@ -15,9 +15,11 @@
//***************************************************************************** //*****************************************************************************
#pragma once #pragma once
#if defined(NGRAPH_ONNX_IMPORT_ENABLE)
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
namespace py = pybind11; namespace py = pybind11;
void regmodule_pyngraph_onnx_import(py::module m); void regmodule_pyngraph_onnx_import(py::module m);
#endif
...@@ -14,13 +14,13 @@ ...@@ -14,13 +14,13 @@
// limitations under the License. // limitations under the License.
//***************************************************************************** //*****************************************************************************
#include <stdexcept>
#include <vector>
#include <pybind11/buffer_info.h> #include <pybind11/buffer_info.h>
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
#include <pybind11/stl.h> #include <pybind11/stl.h>
#include <stdexcept>
#include <vector>
#include "ngraph/op/constant.hpp" #include "ngraph/op/constant.hpp"
#include "ngraph/shape.hpp" #include "ngraph/shape.hpp"
#include "pyngraph/ops/constant.hpp" #include "pyngraph/ops/constant.hpp"
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
#include "pyngraph/function.hpp" #include "pyngraph/function.hpp"
#include "pyngraph/node.hpp" #include "pyngraph/node.hpp"
#include "pyngraph/node_vector.hpp" #include "pyngraph/node_vector.hpp"
#if defined(NGRAPH_ONNX_IMPORT_ENABLE)
#include "pyngraph/onnx_import/onnx_import.hpp"
#endif
#include "pyngraph/ops/op.hpp" #include "pyngraph/ops/op.hpp"
#include "pyngraph/ops/regmodule_pyngraph_op.hpp" #include "pyngraph/ops/regmodule_pyngraph_op.hpp"
#include "pyngraph/ops/util/regmodule_pyngraph_op_util.hpp" #include "pyngraph/ops/util/regmodule_pyngraph_op_util.hpp"
...@@ -54,6 +57,9 @@ PYBIND11_MODULE(_pyngraph, m) ...@@ -54,6 +57,9 @@ PYBIND11_MODULE(_pyngraph, m)
regclass_pyngraph_ParameterVector(m); regclass_pyngraph_ParameterVector(m);
py::module m_op = m.def_submodule("op", "Package ngraph.impl.op that wraps ngraph::op"); py::module m_op = m.def_submodule("op", "Package ngraph.impl.op that wraps ngraph::op");
regclass_pyngraph_op_Op(m_op); regclass_pyngraph_op_Op(m_op);
#if defined(NGRAPH_ONNX_IMPORT_ENABLE)
regmodule_pyngraph_onnx_import(m);
#endif
regmodule_pyngraph_op_util(m_op); regmodule_pyngraph_op_util(m_op);
regmodule_pyngraph_op(m_op); regmodule_pyngraph_op(m_op);
regmodule_pyngraph_runtime(m); regmodule_pyngraph_runtime(m);
......
...@@ -14,13 +14,13 @@ ...@@ -14,13 +14,13 @@
// limitations under the License. // limitations under the License.
//***************************************************************************** //*****************************************************************************
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <iterator> #include <iterator>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "ngraph/shape.hpp" // ngraph::Shape #include "ngraph/shape.hpp" // ngraph::Shape
#include "pyngraph/shape.hpp" #include "pyngraph/shape.hpp"
......
...@@ -13,13 +13,14 @@ ...@@ -13,13 +13,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//***************************************************************************** //*****************************************************************************
#include <iterator>
#include <sstream>
#include <string>
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
#include <pybind11/stl.h> #include <pybind11/stl.h>
#include <iterator>
#include <sstream>
#include <string>
#include "ngraph/strides.hpp" // ngraph::Strides #include "ngraph/strides.hpp" // ngraph::Strides
#include "pyngraph/strides.hpp" #include "pyngraph/strides.hpp"
......
six six
numpy numpy==1.15.4; python_version == "3.4"
numpy; python_version != "3.4"
typing typing
...@@ -267,6 +267,8 @@ library_dirs = [NGRAPH_CPP_LIBRARY_DIR] ...@@ -267,6 +267,8 @@ library_dirs = [NGRAPH_CPP_LIBRARY_DIR]
libraries = ['ngraph'] libraries = ['ngraph']
extra_compile_args = [] extra_compile_args = []
if NGRAPH_ONNX_IMPORT_ENABLE in ['TRUE', 'ON', True]:
extra_compile_args.append('-DNGRAPH_ONNX_IMPORT_ENABLE')
extra_link_args = [] extra_link_args = []
...@@ -291,43 +293,31 @@ data_files = [ ...@@ -291,43 +293,31 @@ data_files = [
), ),
] ]
ext_modules = [
Extension(
'_pyngraph',
sources=sources,
include_dirs=include_dirs,
define_macros=[('VERSION_INFO', __version__)],
library_dirs=library_dirs,
libraries=libraries,
extra_link_args=extra_link_args,
language='c++',
),
]
if NGRAPH_ONNX_IMPORT_ENABLE in ['TRUE', 'ON', True]: if NGRAPH_ONNX_IMPORT_ENABLE in ['TRUE', 'ON', True]:
onnx_sources = [ onnx_sources = [
'pyngraph/pyngraph_onnx_import.cpp',
'pyngraph/onnx_import/onnx_import.cpp', 'pyngraph/onnx_import/onnx_import.cpp',
] ]
onnx_sources = [PYNGRAPH_ROOT_DIR + '/' + source for source in onnx_sources] onnx_sources = [PYNGRAPH_ROOT_DIR + '/' + source for source in onnx_sources]
sources = sources + onnx_sources
package_dir['ngraph.impl.onnx_import'] = ( package_dir['ngraph.impl.onnx_import'] = (
PYNGRAPH_ROOT_DIR + '/ngraph/impl/onnx_import' PYNGRAPH_ROOT_DIR + '/ngraph/impl/onnx_import'
) )
packages.append('ngraph.impl.onnx_import') packages.append('ngraph.impl.onnx_import')
ext_modules.append( ext_modules = [
Extension( Extension(
'_pyngraph_onnx_import', '_pyngraph',
sources=onnx_sources, sources=sources,
include_dirs=include_dirs, include_dirs=include_dirs,
define_macros=[('VERSION_INFO', __version__)], define_macros=[('VERSION_INFO', __version__)],
library_dirs=library_dirs, library_dirs=library_dirs,
libraries=libraries, libraries=libraries,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args, extra_link_args=extra_link_args,
language='c++', language='c++',
), ),
) ]
def add_platform_specific_link_args(link_args): def add_platform_specific_link_args(link_args):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment