onnxruntime/onnxruntime/python/onnxruntime_pybind_state_common.cc
ashbhandare b1a75d0e98
Enable passing initial optimizer state while creating training session (#5869)
* Support to pass initial optimizer states to optimizer graph builder

* Changes for passing init optim state to training session config

* Pass optimizer state through cpp and python frontend

* Cleanup

* Review comments

* Fix windows and mac CI

* Review comments

* review comments

* Review comments

* Frontend review changes

* Fix CI
2020-12-08 21:20:51 -05:00

27 lines
735 B
C++

#include "onnxruntime_pybind_exceptions.h"
#include "onnxruntime_pybind_state_common.h"
namespace onnxruntime {
namespace python {
namespace py = pybind11;
const std::string onnxruntime::python::SessionObjectInitializer::default_logger_id = "Default";
void ThrowIfPyErrOccured() {
if (PyErr_Occurred()) {
PyObject *ptype, *pvalue, *ptraceback;
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
PyObject* pStr = PyObject_Str(ptype);
std::string sType = py::reinterpret_borrow<py::str>(pStr);
Py_XDECREF(pStr);
pStr = PyObject_Str(pvalue);
sType += ": ";
sType += py::reinterpret_borrow<py::str>(pStr);
Py_XDECREF(pStr);
throw Fail(sType);
}
}
} // namespace python
} // namespace onnxruntime