mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-29 20:14:01 +00:00
Layer dev paulm (#2507)
* commetns for dml graph transformer fixed ort value passing using the allocatir info * fixed and coded maps and sequences across the abi * cleaned up w4's cleaned up the model info ABI delayload directml.dll from winml * cleaned up namepsace aliases. renamed _winmla to winmla this was good PR feedback from tiago a while back.
This commit is contained in:
parent
197fd9ea3d
commit
301d407b39
21 changed files with 71 additions and 106 deletions
|
|
@ -67,7 +67,7 @@ extern "C" BOOL WINAPI DllMain(_In_ HINSTANCE hInstance, DWORD dwReason, _In_ vo
|
|||
|
||||
extern "C" HRESULT WINAPI MLCreateOperatorRegistry(_COM_Outptr_ IMLOperatorRegistry** registry) try {
|
||||
*registry = nullptr;
|
||||
winrt::com_ptr<_winmla::IWinMLAdapter> adapter;
|
||||
winrt::com_ptr<winmla::IWinMLAdapter> adapter;
|
||||
WINML_THROW_IF_FAILED(OrtGetWinMLAdapter(adapter.put()));
|
||||
return adapter->GetCustomRegistry(registry);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ CpuOrtSessionBuilder::CreateSessionOptions(
|
|||
HRESULT
|
||||
CpuOrtSessionBuilder::CreateSession(
|
||||
OrtSessionOptions* options,
|
||||
_winmla::IInferenceSession** p_session,
|
||||
winmla::IInferenceSession** p_session,
|
||||
onnxruntime::IExecutionProvider** pp_provider) {
|
||||
RETURN_HR_IF_NULL(E_POINTER, p_session);
|
||||
RETURN_HR_IF_NULL(E_POINTER, pp_provider);
|
||||
|
|
@ -79,15 +79,15 @@ CpuOrtSessionBuilder::CreateSession(
|
|||
ORT_THROW_IF_ERROR(session->RegisterExecutionProvider(std::move(cpu_provider)));
|
||||
|
||||
// assign the session to the out parameter
|
||||
auto sessionptr = wil::MakeOrThrow<_winmla::InferenceSession>(session.release());
|
||||
RETURN_IF_FAILED(sessionptr.CopyTo(_uuidof(_winmla::IInferenceSession), (void**)p_session));
|
||||
auto sessionptr = wil::MakeOrThrow<winmla::InferenceSession>(session.release());
|
||||
RETURN_IF_FAILED(sessionptr.CopyTo(_uuidof(winmla::IInferenceSession), (void**)p_session));
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT
|
||||
CpuOrtSessionBuilder::Initialize(
|
||||
_winmla::IInferenceSession* p_session,
|
||||
winmla::IInferenceSession* p_session,
|
||||
onnxruntime::IExecutionProvider* /*p_provider*/
|
||||
) {
|
||||
ORT_THROW_IF_ERROR(p_session->get()->Initialize());
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Windows::AI::MachineLearning::Adapter {
|
|||
|
||||
class CpuOrtSessionBuilder : public Microsoft::WRL::RuntimeClass <
|
||||
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
|
||||
_winmla::IOrtSessionBuilder> {
|
||||
winmla::IOrtSessionBuilder> {
|
||||
|
||||
public:
|
||||
CpuOrtSessionBuilder();
|
||||
|
|
@ -19,11 +19,11 @@ class CpuOrtSessionBuilder : public Microsoft::WRL::RuntimeClass <
|
|||
|
||||
HRESULT STDMETHODCALLTYPE CreateSession(
|
||||
OrtSessionOptions* options,
|
||||
_winmla::IInferenceSession** p_session,
|
||||
winmla::IInferenceSession** p_session,
|
||||
onnxruntime::IExecutionProvider** pp_provider) override;
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Initialize(
|
||||
_winmla::IInferenceSession* p_session,
|
||||
winmla::IInferenceSession* p_session,
|
||||
onnxruntime::IExecutionProvider* p_provider) override;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ Microsoft::WRL::ComPtr<IDMLDevice> CreateDmlDevice(ID3D12Device* d3d12Device) {
|
|||
|
||||
HRESULT DmlOrtSessionBuilder::CreateSession(
|
||||
OrtSessionOptions* options,
|
||||
_winmla::IInferenceSession** p_session,
|
||||
winmla::IInferenceSession** p_session,
|
||||
onnxruntime::IExecutionProvider** pp_provider) {
|
||||
RETURN_HR_IF_NULL(E_POINTER, p_session);
|
||||
RETURN_HR_IF_NULL(E_POINTER, pp_provider);
|
||||
|
|
@ -126,14 +126,14 @@ HRESULT DmlOrtSessionBuilder::CreateSession(
|
|||
ORT_THROW_IF_ERROR(session->RegisterExecutionProvider(std::move(gpu_provider)));
|
||||
|
||||
// assign the session to the out parameter
|
||||
auto sessionptr = wil::MakeOrThrow<_winmla::InferenceSession>(session.release());
|
||||
RETURN_IF_FAILED(sessionptr.CopyTo(_uuidof(_winmla::IInferenceSession), (void**)p_session));
|
||||
auto sessionptr = wil::MakeOrThrow<winmla::InferenceSession>(session.release());
|
||||
RETURN_IF_FAILED(sessionptr.CopyTo(_uuidof(winmla::IInferenceSession), (void**)p_session));
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT DmlOrtSessionBuilder::Initialize(
|
||||
_winmla::IInferenceSession* p_session,
|
||||
winmla::IInferenceSession* p_session,
|
||||
onnxruntime::IExecutionProvider* p_provider) {
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, p_session);
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, p_provider);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Windows::AI::MachineLearning::Adapter {
|
|||
|
||||
class DmlOrtSessionBuilder : public Microsoft::WRL::RuntimeClass <
|
||||
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
|
||||
_winmla::IOrtSessionBuilder> {
|
||||
winmla::IOrtSessionBuilder> {
|
||||
|
||||
public:
|
||||
DmlOrtSessionBuilder(ID3D12Device* device, ID3D12CommandQueue* queue);
|
||||
|
|
@ -19,11 +19,11 @@ class DmlOrtSessionBuilder : public Microsoft::WRL::RuntimeClass <
|
|||
|
||||
HRESULT STDMETHODCALLTYPE CreateSession(
|
||||
OrtSessionOptions* options,
|
||||
_winmla::IInferenceSession** p_session,
|
||||
winmla::IInferenceSession** p_session,
|
||||
onnxruntime::IExecutionProvider** pp_provider) override;
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Initialize(
|
||||
_winmla::IInferenceSession* p_session,
|
||||
winmla::IInferenceSession* p_session,
|
||||
onnxruntime::IExecutionProvider* p_provider) override;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ GetTensorType(
|
|||
has_unsupported_image_metadata);
|
||||
|
||||
if (is_tensor_improperly_annotated_as_image) {
|
||||
TraceLoggingWrite(_winmla::winml_trace_logging_provider,
|
||||
TraceLoggingWrite(winmla::winml_trace_logging_provider,
|
||||
"WinMLInputValidation",
|
||||
TraceLoggingKeyword(WINML_PROVIDER_KEYWORD_DEFAULT),
|
||||
TraceLoggingLevel(WINEVENT_LEVEL_WARNING),
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ void Windows::AI::MachineLearning::CWinMLLogSink::SendImpl(
|
|||
switch (message.Severity()) {
|
||||
case (onnxruntime::logging::Severity::kFATAL): //Telemetry
|
||||
TraceLoggingWrite(
|
||||
_winmla::winml_trace_logging_provider,
|
||||
winmla::winml_trace_logging_provider,
|
||||
"WinMLLogSink",
|
||||
TelemetryPrivacyDataTag(PDT_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(WINML_PROVIDER_KEYWORD_DEFAULT),
|
||||
|
|
@ -29,7 +29,7 @@ void Windows::AI::MachineLearning::CWinMLLogSink::SendImpl(
|
|||
break;
|
||||
case (onnxruntime::logging::Severity::kERROR): //Telemetry
|
||||
TraceLoggingWrite(
|
||||
_winmla::winml_trace_logging_provider,
|
||||
winmla::winml_trace_logging_provider,
|
||||
"WinMLLogSink",
|
||||
TelemetryPrivacyDataTag(PDT_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(WINML_PROVIDER_KEYWORD_DEFAULT),
|
||||
|
|
@ -43,7 +43,7 @@ void Windows::AI::MachineLearning::CWinMLLogSink::SendImpl(
|
|||
break;
|
||||
case (onnxruntime::logging::Severity::kWARNING):
|
||||
TraceLoggingWrite(
|
||||
_winmla::winml_trace_logging_provider,
|
||||
winmla::winml_trace_logging_provider,
|
||||
"WinMLLogSink",
|
||||
TraceLoggingKeyword(WINML_PROVIDER_KEYWORD_DEFAULT),
|
||||
TraceLoggingLevel(WINEVENT_LEVEL_WARNING),
|
||||
|
|
@ -55,7 +55,7 @@ void Windows::AI::MachineLearning::CWinMLLogSink::SendImpl(
|
|||
break;
|
||||
case (onnxruntime::logging::Severity::kINFO):
|
||||
TraceLoggingWrite(
|
||||
_winmla::winml_trace_logging_provider,
|
||||
winmla::winml_trace_logging_provider,
|
||||
"WinMLLogSink",
|
||||
TraceLoggingKeyword(WINML_PROVIDER_KEYWORD_DEFAULT),
|
||||
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
|
||||
|
|
@ -69,7 +69,7 @@ void Windows::AI::MachineLearning::CWinMLLogSink::SendImpl(
|
|||
__fallthrough; //Default is Verbose too.
|
||||
default:
|
||||
TraceLoggingWrite(
|
||||
_winmla::winml_trace_logging_provider,
|
||||
winmla::winml_trace_logging_provider,
|
||||
"WinMLLogSink",
|
||||
TraceLoggingKeyword(WINML_PROVIDER_KEYWORD_DEFAULT),
|
||||
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
|
||||
|
|
@ -87,7 +87,7 @@ void Windows::AI::MachineLearning::CWinMLLogSink::SendImpl(
|
|||
void Windows::AI::MachineLearning::CWinMLLogSink::SendProfileEvent(onnxruntime::profiling::EventRecord& eventRecord) const {
|
||||
if (eventRecord.cat == onnxruntime::profiling::EventCategory::NODE_EVENT) {
|
||||
TraceLoggingWrite(
|
||||
_winmla::winml_trace_logging_provider,
|
||||
winmla::winml_trace_logging_provider,
|
||||
"OnnxRuntimeProfiling",
|
||||
TraceLoggingKeyword(WINML_PROVIDER_KEYWORD_LOTUS_PROFILING),
|
||||
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
|
||||
|
|
@ -102,7 +102,7 @@ void Windows::AI::MachineLearning::CWinMLLogSink::SendProfileEvent(onnxruntime::
|
|||
TraceLoggingString(eventRecord.args["provider"].c_str(), "Execution Provider"));
|
||||
} else {
|
||||
TraceLoggingWrite(
|
||||
_winmla::winml_trace_logging_provider,
|
||||
winmla::winml_trace_logging_provider,
|
||||
"OnnxRuntimeProfiling",
|
||||
TraceLoggingKeyword(WINML_PROVIDER_KEYWORD_LOTUS_PROFILING),
|
||||
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
|
||||
|
|
|
|||
|
|
@ -141,27 +141,4 @@ private:
|
|||
std::shared_ptr<onnxruntime::InferenceSession> session_;
|
||||
};
|
||||
|
||||
// header only code to enable smart pointers on abstract ort objects
|
||||
template <typename T>
|
||||
class OrtObject {
|
||||
public:
|
||||
OrtObject() {
|
||||
p_ = nullptr;
|
||||
}
|
||||
|
||||
OrtObject(T* m) {
|
||||
p_ = m;
|
||||
}
|
||||
|
||||
virtual ~OrtObject() {
|
||||
if (p_ != nullptr) {
|
||||
ReleaseOrtObject(p_);
|
||||
}
|
||||
}
|
||||
T* get() { return p_; }
|
||||
private:
|
||||
T* p_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Windows::AI::MachineLearning::Adapter
|
||||
|
|
@ -346,7 +346,7 @@ static void GPUTensorize(
|
|||
com_ptr<LearningModelSession> spSession,
|
||||
void* pAllocatedResource,
|
||||
WinML::BindingContext& context) {
|
||||
com_ptr<_winmla::IWinMLAdapter> adapter;
|
||||
com_ptr<winmla::IWinMLAdapter> adapter;
|
||||
WINML_THROW_IF_FAILED(OrtGetWinMLAdapter(adapter.put()));
|
||||
|
||||
auto d3dResource =
|
||||
|
|
@ -505,7 +505,7 @@ HRESULT ImageFeatureValue::GetOrtValue(WinML::BindingContext& context, OrtValue*
|
|||
auto provider = spSession->GetExecutionProvider();
|
||||
|
||||
// and the adapter
|
||||
com_ptr<_winmla::IWinMLAdapter> adapter;
|
||||
com_ptr<winmla::IWinMLAdapter> adapter;
|
||||
WINML_THROW_IF_FAILED(OrtGetWinMLAdapter(adapter.put()));
|
||||
|
||||
// create the OrtValue
|
||||
|
|
@ -552,7 +552,7 @@ HRESULT ImageFeatureValue::UpdateSourceResourceData(BindingContext& context, Ort
|
|||
auto spSession = context.session.as<LearningModelSession>();
|
||||
auto spDevice = spSession->Device().as<LearningModelDevice>();
|
||||
|
||||
com_ptr<_winmla::IWinMLAdapter> adapter;
|
||||
com_ptr<winmla::IWinMLAdapter> adapter;
|
||||
WINML_THROW_IF_FAILED(OrtGetWinMLAdapter(adapter.put()));
|
||||
|
||||
// Get the output tensor raw data
|
||||
|
|
|
|||
|
|
@ -253,9 +253,9 @@ LearningModel::LoadFromStream(
|
|||
}
|
||||
WINML_CATCH_ALL
|
||||
|
||||
_winmla::IModelProto*
|
||||
winmla::IModelProto*
|
||||
LearningModel::DetachModelProto() {
|
||||
com_ptr<_winmla::IModelProto> detached_model_proto;
|
||||
com_ptr<winmla::IModelProto> detached_model_proto;
|
||||
if (model_proto_ != nullptr) {
|
||||
detached_model_proto.attach(model_proto_.detach());
|
||||
|
||||
|
|
@ -265,15 +265,15 @@ LearningModel::DetachModelProto() {
|
|||
return detached_model_proto.detach();
|
||||
}
|
||||
|
||||
_winmla::IModelProto*
|
||||
winmla::IModelProto*
|
||||
LearningModel::CopyModelProto() {
|
||||
if (model_proto_ == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
com_ptr<_winmla::IWinMLAdapter> adapter;
|
||||
com_ptr<winmla::IWinMLAdapter> adapter;
|
||||
WINML_THROW_IF_FAILED(OrtGetWinMLAdapter(adapter.put()));
|
||||
com_ptr<_winmla::IModelProto> model_proto;
|
||||
com_ptr<winmla::IModelProto> model_proto;
|
||||
WINML_THROW_IF_FAILED(adapter->CreateModelProto(model_proto_.get(), model_proto.put()));
|
||||
|
||||
return model_proto.detach();
|
||||
|
|
|
|||
|
|
@ -91,35 +91,22 @@ struct LearningModel : LearningModelT<LearningModel> {
|
|||
|
||||
public:
|
||||
/* Non-ABI methods */
|
||||
bool
|
||||
IsDisposed();
|
||||
|
||||
IMLOperatorRegistry*
|
||||
GetOperatorRegistry();
|
||||
|
||||
_winmla::IModelProto*
|
||||
DetachModelProto();
|
||||
|
||||
_winmla::IModelProto*
|
||||
CopyModelProto();
|
||||
bool IsDisposed();
|
||||
IMLOperatorRegistry* GetOperatorRegistry();
|
||||
winmla::IModelProto* DetachModelProto();
|
||||
winmla::IModelProto* CopyModelProto();
|
||||
|
||||
private:
|
||||
void
|
||||
Initialize();
|
||||
|
||||
void
|
||||
LogCreationEvent(
|
||||
bool fromStream = false);
|
||||
|
||||
void
|
||||
ModelUseFP16(
|
||||
void Initialize();
|
||||
void LogCreationEvent(bool fromStream = false);
|
||||
void ModelUseFP16(
|
||||
winml::ILearningModelFeatureDescriptor descriptor,
|
||||
bool& use_fp16);
|
||||
|
||||
private:
|
||||
com_ptr<_winmla::IWinMLAdapter> adapter_;
|
||||
com_ptr<_winmla::IModelProto> model_proto_;
|
||||
com_ptr<_winmla::IModelInfo> model_info_;
|
||||
com_ptr<winmla::IWinMLAdapter> adapter_;
|
||||
com_ptr<winmla::IModelProto> model_proto_;
|
||||
com_ptr<winmla::IModelInfo> model_info_;
|
||||
ILearningModelOperatorProvider operator_provider_;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -613,7 +613,8 @@ void LearningModelBinding::BindUnboundOutputs()
|
|||
|
||||
// Add all unbound outputs to binding collection
|
||||
for (const auto& unbound_output : unbound_output_names) {
|
||||
WINML_THROW_IF_FAILED(BindOutput(unbound_output, Ort::Value(nullptr)));
|
||||
Ort::Value out(nullptr);
|
||||
WINML_THROW_IF_FAILED(BindOutput(unbound_output, out));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ struct LearningModelBinding : LearningModelBindingT<LearningModelBinding, ILearn
|
|||
|
||||
std::unordered_map<std::string, ProviderInfo> m_providers;
|
||||
|
||||
com_ptr<_winmla::IWinMLAdapter> adapter_;
|
||||
com_ptr<winmla::IWinMLAdapter> adapter_;
|
||||
std::vector<std::string> input_names_;
|
||||
std::vector<Ort::Value> inputs_;
|
||||
std::vector<std::string> output_names_;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ LearningModelSession::LearningModelSession(
|
|||
}
|
||||
WINML_CATCH_ALL
|
||||
|
||||
_winmla::IModelProto*
|
||||
winmla::IModelProto*
|
||||
LearningModelSession::GetOptimizedModel() {
|
||||
// Get the model proto
|
||||
|
||||
|
|
@ -61,9 +61,9 @@ LearningModelSession::GetOptimizedModel() {
|
|||
return GetOptimizedModel(should_close_model);
|
||||
}
|
||||
|
||||
_winmla::IModelProto*
|
||||
winmla::IModelProto*
|
||||
LearningModelSession::GetOptimizedModel(bool should_close_model) {
|
||||
com_ptr<_winmla::IModelProto> model_proto;
|
||||
com_ptr<winmla::IModelProto> model_proto;
|
||||
|
||||
{
|
||||
// Lock the model detach/copy since multiple threads can access concurrently
|
||||
|
|
@ -81,7 +81,7 @@ LearningModelSession::GetOptimizedModel(bool should_close_model) {
|
|||
}
|
||||
|
||||
// Ensure that the model is runnable on the device
|
||||
com_ptr<_winmla::IWinMLAdapter> adapter;
|
||||
com_ptr<winmla::IWinMLAdapter> adapter;
|
||||
WINML_THROW_IF_FAILED(OrtGetWinMLAdapter(adapter.put()));
|
||||
WINML_THROW_IF_FAILED(adapter->EnsureModelDeviceCompatibility(model_, model_proto.get(), device_.as<winmlp::LearningModelDevice>()->GetD3DDeviceCache()->IsFloat16Supported()));
|
||||
|
||||
|
|
@ -94,16 +94,16 @@ void LearningModelSession::Initialize() {
|
|||
_winmlt::EventCategory::kSessionCreation);
|
||||
|
||||
// Get the optimized model proto from the learning model
|
||||
com_ptr<_winmla::IModelProto> model_proto;
|
||||
com_ptr<winmla::IModelProto> model_proto;
|
||||
model_proto.attach(GetOptimizedModel());
|
||||
|
||||
// Create the session builder
|
||||
auto device_impl = device_.as<winmlp::LearningModelDevice>();
|
||||
|
||||
com_ptr<_winmla::IWinMLAdapter> adapter;
|
||||
com_ptr<winmla::IWinMLAdapter> adapter;
|
||||
WINML_THROW_IF_FAILED(OrtGetWinMLAdapter(adapter.put()));
|
||||
|
||||
com_ptr<_winmla::IOrtSessionBuilder> session_builder;
|
||||
com_ptr<winmla::IOrtSessionBuilder> session_builder;
|
||||
WINML_THROW_IF_FAILED(adapter->CreateOrtSessionBuilder(
|
||||
device_impl->GetD3DDevice(),
|
||||
device_impl->GetDeviceQueue(),
|
||||
|
|
@ -121,7 +121,7 @@ void LearningModelSession::Initialize() {
|
|||
session_options_.BatchSizeOverride()));
|
||||
}
|
||||
|
||||
com_ptr<_winmla::IInferenceSession> session;
|
||||
com_ptr<winmla::IInferenceSession> session;
|
||||
WINML_THROW_IF_FAILED(session_builder->CreateSession(
|
||||
options, session.put(), &cached_execution_provider_));
|
||||
|
||||
|
|
@ -397,7 +397,7 @@ void LearningModelSession::ApplyEvaluationProperties() try {
|
|||
if (evaluation_properties_) {
|
||||
auto is_debug_output_enabled = evaluation_properties_.HasKey(c_enable_debug_output);
|
||||
if (is_debug_output_enabled) {
|
||||
com_ptr<_winmla::IWinMLAdapter> adapter;
|
||||
com_ptr<winmla::IWinMLAdapter> adapter;
|
||||
WINML_THROW_IF_FAILED(OrtGetWinMLAdapter(adapter.put()));
|
||||
adapter->EnableDebugOutput();
|
||||
}
|
||||
|
|
@ -425,7 +425,7 @@ LearningModelSession::GetExecutionProvider() {
|
|||
return cached_execution_provider_;
|
||||
}
|
||||
|
||||
_winmla::IInferenceSession*
|
||||
winmla::IInferenceSession*
|
||||
LearningModelSession::GetIInferenceSession() {
|
||||
return inference_session_.get();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ struct LearningModelSession : LearningModelSessionT<LearningModelSession> {
|
|||
onnxruntime::IExecutionProvider*
|
||||
GetExecutionProvider();
|
||||
|
||||
_winmla::IInferenceSession*
|
||||
winmla::IInferenceSession*
|
||||
GetIInferenceSession();
|
||||
|
||||
void
|
||||
|
|
@ -78,10 +78,10 @@ struct LearningModelSession : LearningModelSessionT<LearningModelSession> {
|
|||
void
|
||||
Initialize();
|
||||
|
||||
_winmla::IModelProto*
|
||||
winmla::IModelProto*
|
||||
GetOptimizedModel();
|
||||
|
||||
_winmla::IModelProto*
|
||||
winmla::IModelProto*
|
||||
GetOptimizedModel(bool should_close_model);
|
||||
|
||||
uint64_t
|
||||
|
|
@ -101,7 +101,7 @@ struct LearningModelSession : LearningModelSessionT<LearningModelSession> {
|
|||
ToggleProfiler();
|
||||
|
||||
private:
|
||||
com_ptr<_winmla::IInferenceSession> inference_session_;
|
||||
com_ptr<winmla::IInferenceSession> inference_session_;
|
||||
|
||||
// reference to the active execution provider. weak
|
||||
onnxruntime::IExecutionProvider* cached_execution_provider_ = nullptr;
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ struct MapBase : winrt::implements<
|
|||
}
|
||||
|
||||
template <typename TLotusKey, typename TLotusValue>
|
||||
static onnxruntime::MLDataType GetLotusType(_winmla::IWinMLAdapter* adapter) {
|
||||
static onnxruntime::MLDataType GetLotusType(winmla::IWinMLAdapter* adapter) {
|
||||
return adapter->GetMapType(TensorKindFrom<TLotusKey>::Type, TensorKindFrom<TLotusValue>::Type);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,13 +217,13 @@ struct SequenceBase : public winrt::implements<
|
|||
*ort_value = Ort::Value::CreateSequence(sequence_values).release();
|
||||
return S_OK;
|
||||
|
||||
/* winrt::com_ptr<_winmla::IWinMLAdapter> adapter;
|
||||
/* winrt::com_ptr<winmla::IWinMLAdapter> adapter;
|
||||
RETURN_IF_FAILED(OrtGetWinMLAdapter(adapter.put()));
|
||||
auto lotus_type = adapter->GetVectorMapType(
|
||||
TensorKindFrom<ValidLotusType<T>::TKey>::Type,
|
||||
TensorKindFrom<ValidLotusType<T>::TValue>::Type);
|
||||
|
||||
winrt::com_ptr<_winmla::IOrtValue> ml_value_out;
|
||||
winrt::com_ptr<winmla::IOrtValue> ml_value_out;
|
||||
adapter->CreateOrtValue(lotus_data_.get(), lotus_type, ml_value_out.put());
|
||||
|
||||
*ml_value = ml_value_out.detach();*/
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ class Tensor {
|
|||
|
||||
TensorBufferPtr m_buffer;
|
||||
std::vector<int64_t> shape_;
|
||||
winrt::com_ptr<_winmla::IWinMLAdapter> adapter_;
|
||||
winrt::com_ptr<winmla::IWinMLAdapter> adapter_;
|
||||
|
||||
public:
|
||||
Tensor() = delete;
|
||||
|
||||
Tensor(
|
||||
_winmla::IWinMLAdapter* adapter,
|
||||
winmla::IWinMLAdapter* adapter,
|
||||
std::vector<int64_t> const& shape,
|
||||
winrt::Windows::Storage::Streams::IBuffer buffer) : shape_(shape),
|
||||
m_buffer(
|
||||
|
|
@ -50,7 +50,7 @@ class Tensor {
|
|||
}
|
||||
|
||||
Tensor(
|
||||
_winmla::IWinMLAdapter* adapter,
|
||||
winmla::IWinMLAdapter* adapter,
|
||||
std::vector<int64_t> const& shape) : shape_(shape),
|
||||
m_buffer(
|
||||
TensorBuffer::Create(
|
||||
|
|
@ -64,7 +64,7 @@ class Tensor {
|
|||
}
|
||||
|
||||
Tensor(
|
||||
_winmla::IWinMLAdapter* adapter,
|
||||
winmla::IWinMLAdapter* adapter,
|
||||
std::vector<int64_t> const&& shape) : shape_(std::move(shape)),
|
||||
m_buffer(
|
||||
TensorBuffer::Create(
|
||||
|
|
|
|||
|
|
@ -834,7 +834,7 @@ struct TensorBase : TBase {
|
|||
std::shared_ptr<TensorResources<T>> m_resources;
|
||||
std::vector<winrt::weak_ref<TensorMemoryBufferReference<T>>> m_outstandingReferences;
|
||||
bool m_isClosed = false;
|
||||
winrt::com_ptr<_winmla::IWinMLAdapter> adapter_;
|
||||
winrt::com_ptr<winmla::IWinMLAdapter> adapter_;
|
||||
};
|
||||
|
||||
} // namespace Windows::AI::MachineLearning
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ struct DMLResource {
|
|||
winrt::com_ptr<ID3D12Resource> DXResource;
|
||||
UINT64 resource_width_;
|
||||
void* ExecutionProviderAllocatedResource = nullptr;
|
||||
winrt::com_ptr<_winmla::IWinMLAdapter> adapter_;
|
||||
winrt::com_ptr<winmla::IWinMLAdapter> adapter_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
|
@ -47,7 +47,7 @@ struct TensorResources {
|
|||
try {
|
||||
// Lazily allocate the cpu resource on call to GetBuffer
|
||||
if (CpuResource == nullptr) {
|
||||
winrt::com_ptr<_winmla::IWinMLAdapter> adapter;
|
||||
winrt::com_ptr<winmla::IWinMLAdapter> adapter;
|
||||
WINML_THROW_IF_FAILED(OrtGetWinMLAdapter(adapter.put()));
|
||||
CpuResource = std::make_shared<WinML::Tensor<T>>(adapter.get(), shape);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ namespace winml = ::winrt::Windows::AI::MachineLearning;
|
|||
namespace winrt::Windows::AI::MachineLearning::implementation {}
|
||||
namespace winmlp = ::winrt::Windows::AI::MachineLearning::implementation;
|
||||
|
||||
namespace Windows::AI::MachineLearning::Adapter {}
|
||||
namespace winmla = ::Windows::AI::MachineLearning::Adapter;
|
||||
|
||||
namespace Windows::AI::MachineLearning {}
|
||||
namespace WinML = ::Windows::AI::MachineLearning;
|
||||
|
||||
namespace Windows::AI::MachineLearning::Telemetry {}
|
||||
namespace _winmlt = ::Windows::AI::MachineLearning::Telemetry;
|
||||
|
||||
namespace Windows::AI::MachineLearning::Adapter {}
|
||||
namespace _winmla = ::Windows::AI::MachineLearning::Adapter;
|
||||
Loading…
Reference in a new issue