Skip to content

Commit

Permalink
Merge pull request #2561 from MaaXYZ/feat/directml
Browse files Browse the repository at this point in the history
feat: select adapter id for DirectML
  • Loading branch information
Jiang-Jia-Jun authored Jan 10, 2025
2 parents f968fdf + ec3d4c7 commit 17d204b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fastdeploy/fastdeploy_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class FASTDEPLOY_DECL FastDeployModel {
std::vector<Backend> valid_timvx_backends = {};
/** Model's valid directml backends. This member defined all the onnxruntime directml backends have successfully tested for the model
*/
std::vector<Backend> valid_directml_backends = {};
std::vector<Backend> valid_directml_backends = {Backend::ORT};
/** Model's valid ascend backends. This member defined all the cann backends have successfully tested for the model
*/
std::vector<Backend> valid_ascend_backends = {};
Expand Down
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 17d204b

Please sign in to comment.