Skip to main content

iris/burn/
mod.rs

1use burn::tensor::backend::Backend;
2
3/// Utility helpers for configuring and running Burn operations.
4pub struct BurnUtils;
5
6impl BurnUtils {
7    #[must_use]
8    pub fn backend_name<B: Backend>() -> String {
9        let device = Default::default();
10        B::name(&device)
11    }
12
13    /// Selects the best device available for this execution.
14    #[must_use]
15    pub fn best_device<B: Backend>() -> B::Device {
16        // Defaults to WGPU or CPU device based on the backend used.
17        Default::default()
18    }
19}
20
21#[cfg(test)]
22mod tests {
23    use super::*;
24    use crate::test_helpers::TestBackend;
25
26    #[test]
27    fn test_burn_utils() {
28        let name = BurnUtils::backend_name::<TestBackend>();
29        assert!(!name.is_empty());
30        let _device = BurnUtils::best_device::<TestBackend>();
31    }
32}