mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-13 18:08:13 +00:00
Throw Winml_err_invalid_binding if binding gpu resource on cpu device (#2589)
* Throw Winml_err_invalid_binding if binding gpu resource on cpu device * PR comments. No need to query executionprovider for is gpu device
This commit is contained in:
parent
09c9caab2d
commit
b248f2979a
2 changed files with 6 additions and 1 deletions
|
|
@ -138,7 +138,7 @@ void LearningModelSession::Initialize() {
|
|||
model_proto = nullptr;
|
||||
|
||||
// Initialize the session
|
||||
session_builder->Initialize(session.get(), cached_execution_provider_);
|
||||
WINML_THROW_IF_FAILED(session_builder->Initialize(session.get(), cached_execution_provider_));
|
||||
|
||||
// Cache the constructed session
|
||||
inference_session_ = session;
|
||||
|
|
|
|||
|
|
@ -105,6 +105,11 @@ struct TensorBase : TBase {
|
|||
auto provider = session_impl->GetExecutionProvider();
|
||||
WINML_THROW_IF_FAILED(adapter_->GetProviderMemoryInfo(provider, dml_memory.put()));
|
||||
|
||||
auto spSession = context.session.as<winrt::Windows::AI::MachineLearning::implementation::LearningModelSession>();
|
||||
auto spDevice = spSession->Device().as<winrt::Windows::AI::MachineLearning::implementation::LearningModelDevice>();
|
||||
WINML_THROW_HR_IF_TRUE_MSG(WINML_ERR_INVALID_BINDING,
|
||||
spDevice->IsCpuDevice(),
|
||||
"Cannot create GPU tensor on CPU device");
|
||||
// create the OrtValue as a tensor letting ort know that we own the data buffer
|
||||
auto value = Ort::Value::CreateTensor(
|
||||
dml_memory,
|
||||
|
|
|
|||
Loading…
Reference in a new issue