Fix leaking operator registry (#2645)

Fix https://microsoft.visualstudio.com/OS/_workitems/edit/24354916
This commit is contained in:
Tiago Koji Castro Shibata 2019-12-16 15:41:54 -08:00 committed by GitHub
parent 1f35bcb68d
commit 13c2eb3524
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -126,7 +126,8 @@ void LearningModelSession::Initialize() {
// Register the custom operator registry
auto model = model_.as<winmlp::LearningModel>();
WINML_THROW_IF_FAILED(session->RegisterCustomRegistry(model->GetOperatorRegistry()));
operatorRegistry_.reset(model->GetOperatorRegistry());
WINML_THROW_IF_FAILED(session->RegisterCustomRegistry(operatorRegistry_.get()));
// Register only the transformers not already in ORT
session->RegisterGraphTransformers();

View file

@ -6,6 +6,7 @@
#include "LearningModelSession.g.h"
#include "LearningModelBinding.h"
#include "MLOperatorAuthor.h"
#include "WinML_Lock.h"
#include "WinMLAdapter.h"
@ -102,6 +103,12 @@ struct LearningModelSession : LearningModelSessionT<LearningModelSession> {
private:
com_ptr<winmla::IInferenceSession> inference_session_;
struct IMLOperatorRegistryDeleter {
void operator()(IMLOperatorRegistry* p) {
p->Release();
}
};
std::unique_ptr<IMLOperatorRegistry, IMLOperatorRegistryDeleter> operatorRegistry_;
// reference to the active execution provider. weak
onnxruntime::IExecutionProvider* cached_execution_provider_ = nullptr;