Skip to content

Commit 6cb525f

Browse files
mszhanyiankitm3k
authored andcommitted
Not using predefined marco to check EP (microsoft#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.
1 parent c66bac5 commit 6cb525f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

onnxruntime/core/session/lora_adapters.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,16 @@ namespace {
6262
struct DataTransfer {
6363
std::unique_ptr<IExecutionProvider> ep;
6464
std::unique_ptr<IDataTransfer> data_transfer;
65+
bool is_dml = false;
6566
Status CopyTensor(const Tensor& src, Tensor& dst) const {
6667
return data_transfer->CopyTensor(src, dst);
6768
}
6869
Status Sync() const {
69-
#if USE_DML
70-
return ep->Sync();
71-
#else
72-
return Status::OK();
73-
#endif
70+
if (is_dml) {
71+
return ep->Sync();
72+
} else {
73+
return Status::OK();
74+
}
7475
}
7576
};
7677
} // namespace
@@ -94,6 +95,7 @@ static Status GetDataTransfer(const OrtMemoryInfo& mem_info, [[maybe_unused]] Da
9495
#ifdef USE_DML
9596
auto ep_factory = onnxruntime::DMLProviderFactoryCreator::Create(ConfigOptions{}, 0, false, false, false);
9697
dt.ep = ep_factory->CreateProvider();
98+
dt.is_dml = true;
9799
dt.data_transfer = dt.ep->GetDataTransfer();
98100
#else
99101
status = ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "DML provider is not enabled in this build");

0 commit comments

Comments
 (0)