Fix custom ops scenario tests (#2562)

* Do not shutdown protobuf after ort environment gets destroyed. Lazy load lotus environment first time it is needed

* comment typo

* pr comment  about calling phoenix singleton

* Make lotus_environment static in winmladapter
This commit is contained in:
Ryan Lai 2019-12-05 15:41:01 -08:00 committed by GitHub
parent 8294fa72a4
commit 9933b8a5d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -262,12 +262,15 @@ class WinMLAdapter : public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
IWinMLAdapter> {
private:
std::shared_ptr<WinML::LotusEnvironment> lotus_environment_;
// TODO: Making this static is only temporary. A fix addressing the resulting the memory leaks is needed.
static std::shared_ptr<WinML::LotusEnvironment> lotus_environment_;
public:
WinMLAdapter() : lotus_environment_(PheonixSingleton<WinML::LotusEnvironment>()) {
WinMLAdapter() {
if (lotus_environment_ == nullptr) {
lotus_environment_ = PheonixSingleton<WinML::LotusEnvironment>();
}
}
// factory methods for creating an ort model from a path
HRESULT STDMETHODCALLTYPE CreateModelProto(
const char* path,
@ -644,6 +647,7 @@ class WinMLAdapter : public Microsoft::WRL::RuntimeClass<
}
WINML_CATCH_ALL_COM
}; // namespace Windows::AI::MachineLearning::Adapter
std::shared_ptr<WinML::LotusEnvironment> WinMLAdapter::lotus_environment_ = nullptr;
extern "C" HRESULT STDMETHODCALLTYPE OrtGetWinMLAdapter(IWinMLAdapter** adapter) try {
// make an adapter instance