MCPcopy Create free account
hub / github.com/evilsocket/cake / create_backend

Function create_backend

cake-core/src/backends/mod.rs:688–715  ·  view source on GitHub ↗

Create the appropriate backend for the given device.

(device: &Device)

Source from the content-addressed store, hash-verified

686
687/// Create the appropriate backend for the given device.
688pub fn create_backend(device: &Device) -> Arc<dyn ComputeBackend> {
689 match device {
690 #[cfg(feature = "cuda")]
691 Device::Cuda(_) => Arc::new(CudaBackend::new(device.clone())),
692 #[cfg(feature = "metal")]
693 Device::Metal(_) => Arc::new(MetalBackend::new(device.clone())),
694 _ => {
695 // No GPU device — try ROCm first (native AMD), then Vulkan (wgpu)
696 #[cfg(feature = "rocm")]
697 match RocmBackend::new() {
698 Ok(r) => {
699 log::info!("using ROCm backend (rocBLAS GEMM)");
700 return Arc::new(r);
701 }
702 Err(e) => log::warn!("ROCm init failed ({e}), trying next backend"),
703 }
704 #[cfg(feature = "vulkan")]
705 match VulkanBackend::new() {
706 Ok(vk) => {
707 log::info!("using Vulkan backend for GPU-accelerated ops");
708 return Arc::new(vk);
709 }
710 Err(e) => log::warn!("Vulkan init failed ({e}), falling back to CPU"),
711 }
712 Arc::new(CpuBackend::new())
713 }
714 }
715}

Callers 15

fused_silu_mul_gpuFunction · 0.85
fused_rms_norm_gated_gpuFunction · 0.85
fused_exp_mul_gpuFunction · 0.85
fused_sub_mul_gpuFunction · 0.85
fused_add3_gpuFunction · 0.85
fused_add_scaled_gpuFunction · 0.85
fused_add_rms_norm_gpuFunction · 0.85

Calls 1

cloneMethod · 0.45

Tested by 15

backendFunction · 0.68
test_fp8_to_f32Function · 0.68
try_metal_backendFunction · 0.68