use super::common::*;
#[cfg(feature = "metal")]
pub mod metal_impl {
use super::*;
pub struct MetalBackend {
#[allow(dead_code)]
device_registry: HashMap<String, String>,
}
impl MetalBackend {
pub fn new() -> LinalgResult<Self> {
Ok(Self {
device_registry: HashMap::new(),
})
}
}
impl GpuBackend for MetalBackend {
fn name(&self) -> &str {
"Metal"
}
fn is_available(&self) -> bool {
cfg!(target_os = "macos") || cfg!(target_os = "ios")
}
fn list_devices(&self) -> LinalgResult<Vec<GpuDeviceInfo>> {
Ok(vec![])
}
fn create_context(&self, _device_id: usize) -> LinalgResult<Box<dyn GpuContext>> {
Err(LinalgError::ComputationError(
"Metal backend not fully implemented".to_string(),
))
}
}
}
#[cfg(feature = "metal")]
pub use metal_impl::*;
#[cfg(not(feature = "metal"))]
pub struct MetalBackend;
#[cfg(not(feature = "metal"))]
impl MetalBackend {
pub fn new() -> LinalgResult<Self> {
Err(LinalgError::ComputationError(
"Metal support not compiled in".to_string(),
))
}
}
#[cfg(not(feature = "metal"))]
impl GpuBackend for MetalBackend {
fn name(&self) -> &str {
"Metal (not available)"
}
fn is_available(&self) -> bool {
false
}
fn list_devices(&self) -> LinalgResult<Vec<GpuDeviceInfo>> {
Ok(vec![])
}
fn create_context(&self, _device_id: usize) -> LinalgResult<Box<dyn GpuContext>> {
Err(LinalgError::ComputationError(
"Metal support not compiled in".to_string(),
))
}
}