Skip to content

Commit

Permalink
feat: select adapter id for DirectML
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Nov 20, 2024
1 parent 3bb05ac commit 2507a17
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fastdeploy/runtime/backends/ort/ort_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ bool OrtBackend::BuildOption(const OrtBackendOption& option) {
"DML", ORT_API_VERSION, reinterpret_cast<const void**>(&ortDmlApi));
OrtStatus* onnx_dml_status =
ortDmlApi->SessionOptionsAppendExecutionProvider_DML(session_options_,
0);
option_.device_id);
if (onnx_dml_status != nullptr) {
FDERROR
<< "DirectML is not support in your machine, the program will exit."
Expand Down
5 changes: 4 additions & 1 deletion fastdeploy/runtime/runtime_option.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ void RuntimeOption::UseAscend() {
paddle_lite_option.device = device;
}

void RuntimeOption::UseDirectML() { device = Device::DIRECTML; }
void RuntimeOption::UseDirectML(int adapter_id) {
device = Device::DIRECTML;
device_id = adapter_id;
}

void RuntimeOption::UseSophgo() {
device = Device::SOPHGOTPUD;
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/runtime/runtime_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct FASTDEPLOY_DECL RuntimeOption {
void UseAscend();

/// Use onnxruntime DirectML to inference
void UseDirectML();
void UseDirectML(int adapter_id = 0);

/// Use Sophgo to inference
void UseSophgo();
Expand Down

0 comments on commit 2507a17

Please sign in to comment.