From e31784b6cffc591dbe99165e0a21a6aaefd34426 Mon Sep 17 00:00:00 2001 From: "Tang, Cheng" Date: Tue, 15 Jun 2021 18:52:26 -0700 Subject: [PATCH] decouple the python module construction from pybind_state (#8060) * fix broken tests * decouple the module construction to a seperate file --- onnxruntime/python/onnxruntime_pybind_module.cc | 16 ++++++++++++++++ onnxruntime/python/onnxruntime_pybind_state.cc | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 onnxruntime/python/onnxruntime_pybind_module.cc diff --git a/onnxruntime/python/onnxruntime_pybind_module.cc b/onnxruntime/python/onnxruntime_pybind_module.cc new file mode 100644 index 0000000000..bd844ea873 --- /dev/null +++ b/onnxruntime/python/onnxruntime_pybind_module.cc @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#include + +namespace onnxruntime { +namespace python { +namespace py = pybind11; + +void CreatePybindStateModule(py::module& m); + +PYBIND11_MODULE(onnxruntime_pybind11_state, m) { + CreatePybindStateModule(m); +} +} +} \ No newline at end of file diff --git a/onnxruntime/python/onnxruntime_pybind_state.cc b/onnxruntime/python/onnxruntime_pybind_state.cc index 229fa4604e..1238f9e1e1 100644 --- a/onnxruntime/python/onnxruntime_pybind_state.cc +++ b/onnxruntime/python/onnxruntime_pybind_state.cc @@ -1610,7 +1610,7 @@ static struct { void addObjectMethodsForTraining(py::module& m); #endif -PYBIND11_MODULE(onnxruntime_pybind11_state, m) { +void CreatePybindStateModule(py::module& m){ m.doc() = "pybind11 stateful interface to ONNX runtime"; RegisterExceptions(m);