-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Ryo Yamashita <[email protected]> Co-authored-by: Nanashi. <[email protected]>
- Loading branch information
1 parent
eb6768f
commit fb24f4f
Showing
52 changed files
with
3,929 additions
and
2,756 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::*; | ||
|
||
#[derive(Getters, Debug, Serialize, Deserialize)] | ||
pub struct SupportedDevices { | ||
cpu: bool, | ||
cuda: bool, | ||
dml: bool, | ||
} | ||
|
||
impl SupportedDevices { | ||
/// サポートされているデバイス情報を取得する | ||
pub fn get_supported_devices() -> Result<Self> { | ||
let mut cuda_support = false; | ||
let mut dml_support = false; | ||
for provider in onnxruntime::session::get_available_providers() | ||
.map_err(|e| Error::GetSupportedDevices(e.into()))? | ||
.iter() | ||
{ | ||
match provider.as_str() { | ||
"CUDAExecutionProvider" => cuda_support = true, | ||
"DmlExecutionProvider" => dml_support = true, | ||
_ => {} | ||
} | ||
} | ||
|
||
Ok(SupportedDevices { | ||
cpu: true, | ||
cuda: cuda_support, | ||
dml: dml_support, | ||
}) | ||
} | ||
|
||
pub fn to_json(&self) -> serde_json::Value { | ||
serde_json::to_value(self).expect("should not fail") | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
#[rstest] | ||
fn supported_devices_get_supported_devices_works() { | ||
let result = SupportedDevices::get_supported_devices(); | ||
// 環境によって結果が変わるので、関数呼び出しが成功するかどうかの確認のみ行う | ||
assert!(result.is_ok(), "{result:?}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.