burn-cubecl-fusion: missing FloatKind::F64 arm causes panic with f64 precision on CPU backend
enhancementfusion
**Describe the bug**
Using burn-cpu (CubeCL CPU backend) with Cpu<f64, i32> and fusion enabled (default features) panics at runtime with "Unsupported precision for fusion: f64". The panic occurs in burn-cubecl-fusion-0.21.0/src/engine/codegen/ir.rs line 787, in the From<ElemType> for FuseType implementation. The FloatKind::F64 arm is missing from the match, even though FuseType::F64 is already defined (line 579) and the reverse conversion FuseType::F64 → ElemType::Float(FloatKind::F64) exists (line 828).
Version: burn 0.21.0
**To reproduce**
```rust
// Cargo.toml
// burn = { version = "0.21.0", features = ["std", "cpu", "autodiff"] }
use burn::backend::Autodiff;
use burn_cpu::{Cpu, CpuDevice};
use burn::tensor::{Tensor, TensorData, DType};
type MyBackend = Autodiff<Cpu<f64, i32>>;
fn main() {
let device = CpuDevice::default();
let t = Tensor::<MyBackend, 1>::from_data(
TensorData::from(&[1.0_f64, 2.0, 3.0][..]),
(&device, DType::F64),
)
.require_grad();
let out = t.clone().powf_scalar(2.0).sum();
let grads = out.backward();
let grad = t.grad(&grads).unwrap();
println!("{:?}", grad.to_data());
}
```
Panics on the backward pass with:
thread 'DSU-0-0' panicked at burn-cubecl-fusion-0.21.0/src/engine/codegen/ir.rs:787:22:
Unsupported precision for fusion: f64
**Suggested Fix**
Add the missing FloatKind::F64 => Self::F64 arm in burn-cubecl-fusion/src/engine/codegen/ir.rs, line 786:
```rust
ElemType::Float(kind) => match kind {
FloatKind::F16 => Self::F16,
FloatKind::BF16 => Self::BF16,
FloatKind::F32 => Self::F32,
FloatKind::F64 => Self::F64, // add this
FloatKind::Flex32 => Self::Flex32,
_ => panic!("Unsupported precision for fusion: {value}"),
},
```
0 条评论