tracel-ai/burn · error

float_select_assign with {other:?} update is not implemented

Error message

float_select_assign with {other:?} update is not implemented

What it means

burn-flex's `float_select_assign` only supports update (`value`) tensors with float dtypes; any other dtype category hits the `other` arm and panics with `unimplemented!("float_select_assign with {other:?} update is not implemented")`.

Source

Thrown at crates/burn-flex/src/ops/float.rs:452

                DType::F32 => {
                    crate::ops::gather_scatter::select_mul::<f32>(tensor, dim, indices, value)
                }
                DType::F64 => {
                    crate::ops::gather_scatter::select_mul::<f64>(tensor, dim, indices, value)
                }
                DType::F16 => {
                    crate::ops::gather_scatter::select_mul::<f16>(tensor, dim, indices, value)
                }
                DType::BF16 => {
                    crate::ops::gather_scatter::select_mul::<bf16>(tensor, dim, indices, value)
                }
                _ => panic!(
                    "float_select_assign: unsupported dtype {:?}",
                    tensor.dtype()
                ),
            },
            other => {
                unimplemented!("float_select_assign with {other:?} update is not implemented")
            }
        }
    }

    fn float_slice(tensor: FloatTensor<Flex>, slices: &[Slice]) -> FloatTensor<Flex> {
        crate::ops::slice::slice(tensor, slices)
    }

    fn float_slice_assign(
        tensor: FloatTensor<Flex>,
        slices: &[Slice],
        value: FloatTensor<Flex>,
    ) -> FloatTensor<Flex> {
        crate::ops::slice::slice_assign(tensor, slices, value)
    }

    fn float_mask_where(
        tensor: FloatTensor<Flex>,

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Cast the value tensor to the float dtype of the target tensor before assigning: `values.cast(DType::F32)`
  2. Verify the value tensor is produced by float ops
  3. Add a dtype assertion at the call site
  4. Avoid mixing int/bool results as assign targets

Example fix

// before
let out = tensor.select_assign(dim, indices, mask_i32);
// after
let out = tensor.select_assign(dim, indices, mask_i32.cast(DType::F32));
Defensive patterns

Strategy: type-guard

Validate before calling

assert!(matches!(values.dtype(), DType::F32 | DType::F64 | DType::BF16 | DType::F16), "float_select_assign requires a float update tensor");

Type guard

fn is_float_dtype(d: DType) -> bool {
    matches!(d, DType::F32 | DType::F64 | DType::BF16 | DType::F16)
}

Try / catch

// Rust panics abort; validate before calling
if !is_float_dtype(values.dtype()) {
    values = values.cast(tensor.dtype());
}
let out = tensor.select_assign(dim, indices, values);

Prevention

When it happens

Trigger: Calling `Tensor::select_assign` / `float_select_assign` on a float tensor while supplying an int, uint, or bool `values` tensor.

Common situations: Assigning integer labels or boolean masks into float tensors during data preprocessing; mixing tensors produced by int ops (argmax, comparisons) directly as select values.

Related errors


AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05). Data as JSON: /api/errors/0816489308b74bd2. Report an issue: GitHub.