Skip to content

Commit 2507a17

Browse files
committed
feat: select adapter id for DirectML
1 parent 3bb05ac commit 2507a17

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

fastdeploy/runtime/backends/ort/ort_backend.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ bool OrtBackend::BuildOption(const OrtBackendOption& option) {
9898
"DML", ORT_API_VERSION, reinterpret_cast<const void**>(&ortDmlApi));
9999
OrtStatus* onnx_dml_status =
100100
ortDmlApi->SessionOptionsAppendExecutionProvider_DML(session_options_,
101-
0);
101+
option_.device_id);
102102
if (onnx_dml_status != nullptr) {
103103
FDERROR
104104
<< "DirectML is not support in your machine, the program will exit."

fastdeploy/runtime/runtime_option.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ void RuntimeOption::UseAscend() {
141141
paddle_lite_option.device = device;
142142
}
143143

144-
void RuntimeOption::UseDirectML() { device = Device::DIRECTML; }
144+
void RuntimeOption::UseDirectML(int adapter_id) {
145+
device = Device::DIRECTML;
146+
device_id = adapter_id;
147+
}
145148

146149
void RuntimeOption::UseSophgo() {
147150
device = Device::SOPHGOTPUD;

fastdeploy/runtime/runtime_option.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct FASTDEPLOY_DECL RuntimeOption {
8282
void UseAscend();
8383

8484
/// Use onnxruntime DirectML to inference
85-
void UseDirectML();
85+
void UseDirectML(int adapter_id = 0);
8686

8787
/// Use Sophgo to inference
8888
void UseSophgo();

0 commit comments

Comments
 (0)