mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-07 17:15:29 +00:00
fix python ep default ordering. (#4335)
* fix python ep default ordering. cpu provider should be last. * add comment. * add test case to ensure no regressions for get_all_providers(). * expand on get_all_providers() api documentation
This commit is contained in:
parent
151ef1c8a5
commit
a3b466cdf1
2 changed files with 11 additions and 7 deletions
|
|
@ -302,12 +302,12 @@ inline void RegisterExecutionProvider(InferenceSession* sess, onnxruntime::IExec
|
|||
OrtPybindThrowIfError(sess->RegisterExecutionProvider(std::move(p)));
|
||||
}
|
||||
|
||||
// ordered by default priority. highest to lowest.
|
||||
// ordered by default priority from highest to lowest. kCpuExecutionProvider should always be last.
|
||||
const std::vector<std::string>& GetAllProviders() {
|
||||
static std::vector<std::string> all_providers = {kTensorrtExecutionProvider, kCudaExecutionProvider, kDnnlExecutionProvider,
|
||||
kNGraphExecutionProvider, kOpenVINOExecutionProvider, kNupharExecutionProvider,
|
||||
kVitisAIExecutionProvider, kCpuExecutionProvider, kMIGraphXExecutionProvider,
|
||||
kAclExecutionProvider, kArmNNExecutionProvider};
|
||||
static std::vector<std::string> all_providers = {kTensorrtExecutionProvider, kCudaExecutionProvider, kMIGraphXExecutionProvider,
|
||||
kNGraphExecutionProvider, kOpenVINOExecutionProvider, kDnnlExecutionProvider,
|
||||
kNupharExecutionProvider, kVitisAIExecutionProvider, kArmNNExecutionProvider,
|
||||
kAclExecutionProvider, kCpuExecutionProvider};
|
||||
return all_providers;
|
||||
}
|
||||
|
||||
|
|
@ -402,7 +402,9 @@ void addGlobalMethods(py::module& m, const Environment& env) {
|
|||
"Sets the default logging severity. 0:Verbose, 1:Info, 2:Warning, 3:Error, 4:Fatal");
|
||||
m.def(
|
||||
"get_all_providers", []() -> const std::vector<std::string>& { return GetAllProviders(); },
|
||||
"Return list of Execution Providers that this version of Onnxruntime can support.");
|
||||
"Return list of Execution Providers that this version of Onnxruntime can support. "
|
||||
"The order of elements represents the default priority order of Execution Providers"
|
||||
" from highest to lowest.");
|
||||
m.def(
|
||||
"get_available_providers", []() -> const std::vector<std::string>& { return GetAvailableProviders(); },
|
||||
"Return list of available Execution Providers available in this installed version of Onnxruntime.");
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ class TestInferenceSession(unittest.TestCase):
|
|||
|
||||
def testGetProviders(self):
|
||||
self.assertTrue('CPUExecutionProvider' in onnxrt.get_available_providers())
|
||||
self.assertTrue('CPUExecutionProvider' in onnxrt.get_all_providers())
|
||||
# get_all_providers() returns the default EP order from highest to lowest.
|
||||
# CPUExecutionProvider should always be last.
|
||||
self.assertTrue('CPUExecutionProvider' == onnxrt.get_all_providers()[-1])
|
||||
sess = onnxrt.InferenceSession(get_name("mul_1.onnx"))
|
||||
self.assertTrue('CPUExecutionProvider' in sess.get_providers())
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue