Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sherpa-onnx/csrc/provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Provider StringToProvider(std::string s) {
return Provider::kTRT;
} else if (s == "directml") {
return Provider::kDirectML;
} else if (s == "rocm") {
return Provider::KROCM;
} else {
SHERPA_ONNX_LOGE("Unsupported string: %s. Fallback to cpu", s.c_str());
return Provider::kCPU;
Expand Down
1 change: 1 addition & 0 deletions sherpa-onnx/csrc/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum class Provider {
kNNAPI = 4, // NnapiExecutionProvider
kTRT = 5, // TensorRTExecutionProvider
kDirectML = 6, // DmlExecutionProvider
KROCM = 7 // ROCMExecutionProvider
};

/**
Expand Down
15 changes: 15 additions & 0 deletions sherpa-onnx/csrc/session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,21 @@ Ort::SessionOptions GetSessionOptionsImpl(
}
break;
}
case Provider::KROCM: {
if (std::find(available_providers.begin(), available_providers.end(),
"ROCMExecutionProvider") != available_providers.end()) {
OrtROCMProviderOptions options;
options.device_id =
provider_config != nullptr ? provider_config->device : 0;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
provider_config != nullptr ? provider_config->device : 0;
provider_config? provider_config->device : 0;

sess_opts.AppendExecutionProvider_ROCM(options);
} else {
SHERPA_ONNX_LOGE(
"Please compile with ort enable ROCM EP. Available "
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some doc to describe how to build sherpa-onnx with ROCM support?

Do we need to change the toplevel CMakeLists.txt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not to change the CMaleLists.txt , only need to set env SHERPA_ONNXRUNTIME_INCLUDE_DIR , SHERPA_ONNXRUNTIME_LIB_DIR before use cmake to build .
hygon prebuilt onnxruntime :
https://cancon.hpccube.com:65024/4/main/onnxruntime/DAS1.6
amd prebuilt onnxruntime :
I will built and upload .

Copy link
Copy Markdown
Collaborator

@csukuangfj csukuangfj Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you follow
https://github.com/k2-fsa/sherpa-onnx/blob/master/cmake/onnxruntime-win-x64-directml.cmake
to support rocm?

It will simplify how users use rocm.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. but currently , I did not find onnxruntime-rocm on nuget ,conan or vcpkg . I will build a onnxruntime-rocm and update Cmake.

"providers: %s. Fallback to cpu!",
os.str().c_str());
}
break;
}
case Provider::kDirectML: {
#if defined(_WIN32) && SHERPA_ONNX_ENABLE_DIRECTML == 1
sess_opts.DisableMemPattern();
Expand Down
Loading