use ort::session::builder::SessionBuilder;
#[allow(dead_code)]
pub fn gpu_execution_provider() -> Option<&'static str> {
#[cfg(feature = "gpu-cuda")]
{
return Some("CUDAExecutionProvider");
}
#[cfg(feature = "gpu-coreml")]
{
return Some("CoreMLExecutionProvider");
}
#[cfg(feature = "gpu-directml")]
{
return Some("DmlExecutionProvider");
}
#[cfg(feature = "gpu-rocm")]
{
return Some("ROCMExecutionProvider");
}
#[allow(unreachable_code)]
None
}
pub fn apply_gpu_ep(builder: &mut SessionBuilder) -> std::result::Result<(), ort::Error> {
#[cfg(feature = "gpu-cuda")]
{
tracing::info!("registering CUDAExecutionProvider");
return builder.with_execution_providers([ort::ep::CUDA::default().build()]);
}
#[cfg(feature = "gpu-coreml")]
{
tracing::info!("registering CoreMLExecutionProvider");
return builder.with_execution_providers([ort::ep::CoreML::default().build()]);
}
#[cfg(feature = "gpu-directml")]
{
tracing::info!("registering DmlExecutionProvider");
return builder.with_execution_providers([ort::ep::DirectML::default().build()]);
}
#[cfg(feature = "gpu-rocm")]
{
tracing::info!("registering ROCMExecutionProvider");
return builder.with_execution_providers([ort::ep::ROCm::default().build()]);
}
#[allow(unreachable_code)]
{
let _ = builder;
Ok(())
}
}