gpt_sovits/
onnx_builder.rs1use {
2 crate::error::GSVError,
3 ort::{
4 execution_providers::CPUExecutionProvider,
5 session::{Session, builder::GraphOptimizationLevel},
6 },
7 std::path::Path,
8};
9
10pub fn create_onnx_cpu_session<P>(path: P) -> Result<Session, GSVError>
11where
12 P: AsRef<Path>,
13{
14 Ok(Session::builder()?
15 .with_execution_providers([CPUExecutionProvider::default()
16 .with_arena_allocator(true)
17 .build()])?
18 .with_optimization_level(GraphOptimizationLevel::Level3)?
19 .with_intra_threads(8)?
20 .with_prepacking(true)?
21 .with_config_entry("session.enable_mem_reuse", "1")?
22 .with_independent_thread_pool()?
23 .with_intra_op_spinning(true)?
24 .commit_from_file(path)?)
25}