-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor folders * Remove unused import * move app_fs_ext to storage_ext * Fix storage_ext import * Fix pathbuf * Fix import * No need for verbose output in CI * Tweak imports
- Loading branch information
Showing
29 changed files
with
773 additions
and
731 deletions.
There are no files selected for viewing
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,3 @@ | ||
mod audio_manager; | ||
|
||
pub use audio_manager::{AudioManager, AudioStream}; |
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
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,51 @@ | ||
use log::info; | ||
use std::collections::VecDeque; | ||
use std::fmt::Display; | ||
use std::path::PathBuf; | ||
|
||
use crate::cli::loading_bar::LoadingBarFactory; | ||
use crate::cli::storage_ext::StorageExt; | ||
use crate::cli::PROJECT_FS; | ||
use crate::storage::Storage; | ||
|
||
pub async fn download_many<T: Display>( | ||
remote_file_spec: Vec<(T, T)>, | ||
force_download: bool, | ||
on_download_msg: &str, | ||
on_finished_msg: &str, | ||
) -> anyhow::Result<VecDeque<PathBuf>> { | ||
let mut has_to_download = force_download; | ||
for (_, local_filename) in remote_file_spec.iter() { | ||
has_to_download = has_to_download || !PROJECT_FS.exists(&local_filename.to_string()).await? | ||
} | ||
|
||
if has_to_download { | ||
info!("{on_download_msg}"); | ||
} | ||
let m = LoadingBarFactory::multi(); | ||
let mut tasks = vec![]; | ||
for (remote_file, local_filename) in remote_file_spec { | ||
let remote_file = remote_file.to_string(); | ||
let local_filename = local_filename.to_string(); | ||
let bar = m.add(LoadingBarFactory::download_bar(&local_filename)); | ||
tasks.push(tokio::spawn(async move { | ||
PROJECT_FS | ||
.fetch_remote_data_file( | ||
&remote_file, | ||
&local_filename, | ||
force_download, | ||
bar.into_update_callback(), | ||
) | ||
.await | ||
})); | ||
} | ||
let mut results = VecDeque::new(); | ||
for task in tasks { | ||
results.push_back(task.await??); | ||
} | ||
m.clear()?; | ||
if has_to_download { | ||
info!("{on_finished_msg}"); | ||
} | ||
Ok(results) | ||
} |
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,46 @@ | ||
use anyhow::anyhow; | ||
use log::{error, info}; | ||
use ort::execution_providers::{ | ||
CUDAExecutionProvider, CoreMLExecutionProvider, ExecutionProvider, ExecutionProviderDispatch, | ||
TensorRTExecutionProvider, | ||
}; | ||
use ort::session::Session; | ||
|
||
pub fn init_gpu() -> anyhow::Result<(&'static str, ExecutionProviderDispatch)> { | ||
let mut dummy_builder = Session::builder()?; | ||
|
||
if cfg!(feature = "tensorrt") { | ||
let provider = TensorRTExecutionProvider::default(); | ||
match provider.register(&mut dummy_builder) { | ||
Ok(_) => { | ||
info!("{} detected", provider.as_str()); | ||
return Ok(("TensorRT", provider.build())); | ||
} | ||
Err(err) => error!("Could not load {}: {}", provider.as_str(), err), | ||
} | ||
} | ||
if cfg!(feature = "cuda") { | ||
let provider = CUDAExecutionProvider::default(); | ||
match provider.register(&mut dummy_builder) { | ||
Ok(_) => { | ||
info!("{} detected", provider.as_str()); | ||
return Ok(("Cuda", provider.build())); | ||
} | ||
Err(err) => error!("Could not load {}: {}", provider.as_str(), err), | ||
} | ||
} | ||
if cfg!(feature = "coreml") { | ||
let provider = CoreMLExecutionProvider::default().with_ane_only(); | ||
match provider.register(&mut dummy_builder) { | ||
Ok(_) => { | ||
info!("{} detected", provider.as_str()); | ||
return Ok(("CoreML", provider.build())); | ||
} | ||
Err(err) => error!("Could not load {}: {}", provider.as_str(), err), | ||
} | ||
} | ||
|
||
Err(anyhow!( | ||
"No hardware accelerator was detected, try running the program without the --gpu flag", | ||
)) | ||
} |
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.