Skip to content

Commit 17d204b

Browse files
Merge pull request #2561 from MaaXYZ/feat/directml
feat: select adapter id for DirectML
2 parents f968fdf + ec3d4c7 commit 17d204b

4 files changed

Lines changed: 7 additions & 4 deletions

File tree

fastdeploy/fastdeploy_model.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class FASTDEPLOY_DECL FastDeployModel {
4747
std::vector<Backend> valid_timvx_backends = {};
4848
/** Model's valid directml backends. This member defined all the onnxruntime directml backends have successfully tested for the model
4949
*/
50-
std::vector<Backend> valid_directml_backends = {};
50+
std::vector<Backend> valid_directml_backends = {Backend::ORT};
5151
/** Model's valid ascend backends. This member defined all the cann backends have successfully tested for the model
5252
*/
5353
std::vector<Backend> valid_ascend_backends = {};

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)