diff --git a/onnxruntime/python/onnxruntime_pybind_mlvalue.h b/onnxruntime/python/onnxruntime_pybind_mlvalue.h index 9025b1eab4..85f8777aa3 100644 --- a/onnxruntime/python/onnxruntime_pybind_mlvalue.h +++ b/onnxruntime/python/onnxruntime_pybind_mlvalue.h @@ -28,6 +28,8 @@ MLDataType NumpyTypeToOnnxRuntimeType(int numpy_type); void CreateGenericMLValue(const onnxruntime::InputDefList* input_def_list, const AllocatorPtr& alloc, const std::string& name_input, py::object& value, OrtValue* p_mlvalue); +void GetPyObjFromTensor(const Tensor& rtensor, py::object& obj, const DataTransferManager* data_transfer_manager = nullptr); + template struct DecRefFn { void operator()(T* pyobject) const { diff --git a/onnxruntime/python/onnxruntime_pybind_state.cc b/onnxruntime/python/onnxruntime_pybind_state.cc index 1724489159..f29e740820 100644 --- a/onnxruntime/python/onnxruntime_pybind_state.cc +++ b/onnxruntime/python/onnxruntime_pybind_state.cc @@ -189,7 +189,7 @@ void AddNonTensor(const OrtValue& val, std::vector& pyobjs) { pyobjs.push_back(py::cast(val.Get())); } -void GetPyObjFromTensor(const Tensor& rtensor, py::object& obj, const DataTransferManager* data_transfer_manager = nullptr) { +void GetPyObjFromTensor(const Tensor& rtensor, py::object& obj, const DataTransferManager* data_transfer_manager) { std::vector npy_dims; const TensorShape& shape = rtensor.Shape(); diff --git a/onnxruntime/python/onnxruntime_pybind_state_common.h b/onnxruntime/python/onnxruntime_pybind_state_common.h index 3855b480a8..b1b7637f2b 100644 --- a/onnxruntime/python/onnxruntime_pybind_state_common.h +++ b/onnxruntime/python/onnxruntime_pybind_state_common.h @@ -7,7 +7,10 @@ #include "core/framework/session_options.h" #include "core/session/environment.h" + namespace onnxruntime { +class InferenceSession; + namespace python { using namespace onnxruntime; @@ -46,6 +49,8 @@ class SessionObjectInitializer { Environment& get_env(); +void InitializeSession(InferenceSession* sess, const std::vector& provider_types); + } } diff --git a/orttraining/orttraining/python/orttraining_pybind_state.cc b/orttraining/orttraining/python/orttraining_pybind_state.cc index 0885cd058b..a9d52c7a80 100644 --- a/orttraining/orttraining/python/orttraining_pybind_state.cc +++ b/orttraining/orttraining/python/orttraining_pybind_state.cc @@ -12,6 +12,8 @@ #include "orttraining/core/session/training_session.h" #include "orttraining/core/graph/optimizer_config.h" #include "orttraining/core/framework/mpi_setup.h" +#include "python/onnxruntime_pybind_mlvalue.h" + namespace onnxruntime { namespace python { @@ -19,13 +21,6 @@ namespace py = pybind11; using namespace onnxruntime; using namespace onnxruntime::logging; -// BEGIN: forward declaration for stuff in onnxruntime_pybind_state -void InitializeSession(InferenceSession* sess, const std::vector& provider_types); -void GetPyObjFromTensor(const Tensor& rtensor, py::object& obj, const DataTransferManager* data_transfer_manager = nullptr); -void CreateGenericMLValue(const onnxruntime::InputDefList* input_def_list, const AllocatorPtr& alloc, const std::string& name_input, - py::object& value, OrtValue* p_mlvalue); -// END: forward declaration - struct TrainingParameters { std::string loss_output_name; std::unordered_set weights_to_train;