tracel-ai/burn · error

int_select_assign with {other:?} update is not implemented

Error message

int_select_assign with {other:?} update is not implemented

What it means

int_select_assign in burn-tch supports only IndexingUpdateOp::Add and IndexingUpdateOp::Mul (via TchOps::select_assign and select_assign_mul). Any other update op variant reaches the unimplemented!() branch and panics with the op name in the message.

Source

Thrown at crates/burn-tch/src/ops/int_tensor.rs:342

    fn int_select_assign(
        tensor: TchTensor,
        dim: usize,
        indices: TchTensor,
        value: TchTensor,
        update: burn_backend::tensor::IndexingUpdateOp,
    ) -> TchTensor {
        match update {
            burn_backend::tensor::IndexingUpdateOp::Assign => {
                TchOps::select_assign_replace(tensor, dim, indices, value)
            }
            burn_backend::tensor::IndexingUpdateOp::Add => {
                TchOps::select_assign(tensor, dim, indices, value)
            }
            burn_backend::tensor::IndexingUpdateOp::Mul => {
                TchOps::select_assign_mul(tensor, dim, indices, value)
            }
            other => {
                unimplemented!("int_select_assign with {other:?} update is not implemented")
            }
        }
    }

    fn int_mask_where(tensor: TchTensor, mask: TchTensor, source: TchTensor) -> TchTensor {
        TchTensor::binary_ops_tensor(
            tensor,
            source,
            |tensor, source| source.f_where_self(&mask.tensor, tensor).unwrap(),
            |tensor, source| source.f_where_self(&mask.tensor, tensor).unwrap(),
            |tensor, source| source.f_where_self(&mask.tensor, tensor).unwrap(),
        )
    }

    fn int_mask_fill(tensor: TchTensor, mask: TchTensor, value: Scalar) -> TchTensor {
        let value = value.elem::<i64>();
        tensor.unary_ops(
            |mut tensor| tensor.f_masked_fill_(&mask.tensor, value).unwrap(),

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Rewrite the update using Add/Mul semantics (e.g. Sub by adding the negated value)
  2. Implement the assignment with mask_where or manual tensor ops supported by the backend
  3. Update burn/burn-tch to a release implementing the needed op for tch
  4. Contribute the missing match arm mapping the op to torch's index_put/scatter variants

Example fix

// before
tensor.select_assign(dim, indices, value, IndexingUpdateOp::Sub);

// after
tensor.select_assign(dim, indices, -value, IndexingUpdateOp::Add);
Defensive patterns

Strategy: validation

Validate before calling

match op {
    IndexingUpdateOp::Add | IndexingUpdateOp::Mul => { /* safe */ }
    other => panic!("unsupported select_assign op {:?}", other),
}

Prevention

When it happens

Trigger: Assigning values at selected indices of an integer tensor on LibTorch with an IndexingUpdateOp other than Add/Mul (e.g. Sub, Max) via select_assign-style indexing APIs.

Common situations: Porting code that used Sub/Min select-assign from another backend; new IndexingUpdateOp variants added to burn-core that burn-tch hasn't implemented; custom training/inference code doing indexed accumulation with nonstandard updates.

Related errors


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