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(
OUTPUT ${CMAKE_BINARY_DIR}/python/dist/
POST_BUILD
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/)
......
......@@ -32,5 +32,5 @@ else:
flags = sys.getdlopenflags() | ctypes.RTLD_GLOBAL
sys.setdlopenflags(flags)
from _pyngraph_onnx_import import import_onnx_model
from _pyngraph_onnx_import import import_onnx_model_file
from _pyngraph import import_onnx_model
from _pyngraph import import_onnx_model_file
......@@ -14,13 +14,13 @@
// limitations under the License.
//*****************************************************************************
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <iterator>
#include <sstream>
#include <string>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "ngraph/axis_set.hpp" // ngraph::AxisSet
#include "pyngraph/axis_set.hpp"
......
......@@ -13,13 +13,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <iterator>
#include <sstream>
#include <string>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <iterator>
#include <sstream>
#include <string>
#include "ngraph/coordinate_diff.hpp" // ngraph::CoordinateDiff
#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");
// you may not use this file except in compliance with the License.
......
......@@ -14,10 +14,12 @@
// limitations under the License.
//*****************************************************************************
#include <istream>
#include <memory>
#if defined(NGRAPH_ONNX_IMPORT_ENABLE)
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <istream>
#include <memory>
#include <string>
#include <vector>
......@@ -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_file", &import_onnx_model_file);
}
#endif
......@@ -15,9 +15,11 @@
//*****************************************************************************
#pragma once
#if defined(NGRAPH_ONNX_IMPORT_ENABLE)
#include <pybind11/pybind11.h>
namespace py = pybind11;
void regmodule_pyngraph_onnx_import(py::module m);
#endif
......@@ -14,13 +14,13 @@
// limitations under the License.
//*****************************************************************************
#include <stdexcept>
#include <vector>
#include <pybind11/buffer_info.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <stdexcept>
#include <vector>
#include "ngraph/op/constant.hpp"
#include "ngraph/shape.hpp"
#include "pyngraph/ops/constant.hpp"
......
......@@ -22,6 +22,9 @@
#include "pyngraph/function.hpp"
#include "pyngraph/node.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/regmodule_pyngraph_op.hpp"
#include "pyngraph/ops/util/regmodule_pyngraph_op_util.hpp"
......@@ -54,6 +57,9 @@ PYBIND11_MODULE(_pyngraph, m)
regclass_pyngraph_ParameterVector(m);
py::module m_op = m.def_submodule("op", "Package ngraph.impl.op that wraps ngraph::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(m_op);
regmodule_pyngraph_runtime(m);
......
......@@ -14,13 +14,13 @@
// limitations under the License.
//*****************************************************************************
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <iterator>
#include <sstream>
#include <string>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "ngraph/shape.hpp" // ngraph::Shape
#include "pyngraph/shape.hpp"
......
......@@ -13,13 +13,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <iterator>
#include <sstream>
#include <string>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <iterator>
#include <sstream>
#include <string>
#include "ngraph/strides.hpp" // ngraph::Strides
#include "pyngraph/strides.hpp"
......
six
numpy
numpy==1.15.4; python_version == "3.4"
numpy; python_version != "3.4"
typing
......@@ -267,6 +267,8 @@ library_dirs = [NGRAPH_CPP_LIBRARY_DIR]
libraries = ['ngraph']
extra_compile_args = []
if NGRAPH_ONNX_IMPORT_ENABLE in ['TRUE', 'ON', True]:
extra_compile_args.append('-DNGRAPH_ONNX_IMPORT_ENABLE')
extra_link_args = []
......@@ -291,6 +293,18 @@ data_files = [
),
]
if NGRAPH_ONNX_IMPORT_ENABLE in ['TRUE', 'ON', True]:
onnx_sources = [
'pyngraph/onnx_import/onnx_import.cpp',
]
onnx_sources = [PYNGRAPH_ROOT_DIR + '/' + source for source in onnx_sources]
sources = sources + onnx_sources
package_dir['ngraph.impl.onnx_import'] = (
PYNGRAPH_ROOT_DIR + '/ngraph/impl/onnx_import'
)
packages.append('ngraph.impl.onnx_import')
ext_modules = [
Extension(
'_pyngraph',
......@@ -299,36 +313,12 @@ ext_modules = [
define_macros=[('VERSION_INFO', __version__)],
library_dirs=library_dirs,
libraries=libraries,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
language='c++',
),
]
if NGRAPH_ONNX_IMPORT_ENABLE in ['TRUE', 'ON', True]:
onnx_sources = [
'pyngraph/pyngraph_onnx_import.cpp',
'pyngraph/onnx_import/onnx_import.cpp',
]
onnx_sources = [PYNGRAPH_ROOT_DIR + '/' + source for source in onnx_sources]
package_dir['ngraph.impl.onnx_import'] = (
PYNGRAPH_ROOT_DIR + '/ngraph/impl/onnx_import'
)
packages.append('ngraph.impl.onnx_import')
ext_modules.append(
Extension(
'_pyngraph_onnx_import',
sources=onnx_sources,
include_dirs=include_dirs,
define_macros=[('VERSION_INFO', __version__)],
library_dirs=library_dirs,
libraries=libraries,
extra_link_args=extra_link_args,
language='c++',
),
)
def add_platform_specific_link_args(link_args):
"""Add linker flags specific for actual OS."""
......
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