From 5200e098aa86fe493059abb962d732fadbefc44d Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 31 Oct 2024 08:46:13 +0800 Subject: [PATCH] Not using predefined marco to check EP (#22654) ### Description We'll build CUDA EP and DML EP in one package. As a result, USE_DML and USE_CUDA will coexist. We can't use predefined macros to check EP any more ### Motivation and Context Other changes are in test code, so I make this change of core runtime into one PR. --- onnxruntime/core/session/lora_adapters.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/onnxruntime/core/session/lora_adapters.cc b/onnxruntime/core/session/lora_adapters.cc index a095027a1d..599c41f79a 100644 --- a/onnxruntime/core/session/lora_adapters.cc +++ b/onnxruntime/core/session/lora_adapters.cc @@ -62,15 +62,16 @@ namespace { struct DataTransfer { std::unique_ptr ep; std::unique_ptr data_transfer; + bool is_dml = false; Status CopyTensor(const Tensor& src, Tensor& dst) const { return data_transfer->CopyTensor(src, dst); } Status Sync() const { -#if USE_DML - return ep->Sync(); -#else - return Status::OK(); -#endif + if (is_dml) { + return ep->Sync(); + } else { + return Status::OK(); + } } }; } // namespace @@ -94,6 +95,7 @@ static Status GetDataTransfer(const OrtMemoryInfo& mem_info, [[maybe_unused]] Da #ifdef USE_DML auto ep_factory = onnxruntime::DMLProviderFactoryCreator::Create(ConfigOptions{}, 0, false, false, false); dt.ep = ep_factory->CreateProvider(); + dt.is_dml = true; dt.data_transfer = dt.ep->GetDataTransfer(); #else status = ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "DML provider is not enabled in this build");