huggingface/candle · error
only exclusive == 0 is supported in CumSum
Error message
only exclusive == 0 is supported in CumSum
What it means
The CumSum node evaluation only supports the default inclusive, forward-mode cumulative sum. If the node's optional 'exclusive' attribute is set to 1 (exclusive cumsum), evaluation aborts with this error.
Source
Thrown at candle-onnx/src/eval.rs:1138
None => {
bail!("unsupported 'to' value {dt:?} for cast {}", node.name)
}
},
Err(_) => {
bail!("unsupported 'to' value {dt:?} for cast {}", node.name)
}
};
let output = input.to_dtype(dtype)?;
values.insert(node.output[0].clone(), output);
}
// https://github.com/onnx/onnx/blob/main/docs/Operators.md#CumSum
"CumSum" => {
let exclusive = get_attr_opt::<i64>(node, "exclusive")?
.copied()
.unwrap_or(0);
let reverse = get_attr_opt::<i64>(node, "reverse")?.copied().unwrap_or(0);
if exclusive != 0 {
bail!("only exclusive == 0 is supported in CumSum")
}
if reverse != 0 {
bail!("only reverse == 0 is supported in CumSum")
}
let input = get(&node.input[0])?;
let axis = to_vec0_flexible::<u32>(&get(&node.input[1])?.to_dtype(DType::U32)?)?;
let output = input.cumsum(axis as usize)?;
values.insert(node.output[0].clone(), output);
}
// https://github.com/onnx/onnx/blob/main/docs/Operators.md#flatten
"Flatten" => {
let axis = get_attr_opt::<i64>(node, "axis")?.copied().unwrap_or(1) as usize;
let input = get(&node.input[0])?;
let first_part: usize = input.shape().dims().iter().take(axis).product();
let end_index = input.shape().dims().iter().product::<usize>();
let new_shape = (first_part, end_index / first_part);
let output = input.reshape(new_shape)?;
values.insert(node.output[0].clone(), output);View on GitHub (pinned to d5fee525bf)
Solutions
- Set the CumSum node's 'exclusive' attribute to 0 or remove it (exclusive=0 is the default)
- Pre-compute the exclusive variant outside the graph: exclusive_cumsum(x) = inclusive_cumsum(x) - x
- Rewrite the export so cumsum is inclusive (shift/add logic in source framework)
- Patch candle-onnx to implement exclusive cumsum (subtract input from result)
Example fix
// before (python, onnx graph surgery)
node.attribute.append(onnx.helper.make_attribute('exclusive', 1))
// after
node.attribute.append(onnx.helper.make_attribute('exclusive', 0)) Defensive patterns
Strategy: validation
Validate before calling
for node in &graph.node {
if node.op_type == "CumSum" {
let exclusive = get_attr_opt::<i64>(node, "exclusive").unwrap_or(None).copied().unwrap_or(0);
assert_eq!(exclusive, 0, "CumSum {} uses exclusive=1", node.name);
}
} Prevention
- Grep the exported graph for CumSum nodes and check attributes
- Set exclusive=0 at export time or post-process the graph
- If exclusive semantics are needed, compute outside the graph (cumsum - input)
When it happens
Trigger: Evaluating a model with a CumSum node having attribute exclusive=1.
Common situations: Models exported from frameworks that use exclusive cumulative sums (e.g. certain sequence/probability models); handwritten ONNX graphs using the full CumSum spec.
Related errors
- unsupported 'mode' value {mode:?} for Pad node {:?}
- more dilations than expected in conv1d {s:?} {}
- cannot find 'value' attr in 'Constant' for {}
- attribute {} was of type TENSOR, but no tensor was found
- attribute {} of type TENSOR was an invalid data_type number
AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02).
Data as JSON: /api/errors/e4dae7915ac47fb7.
Report an issue: GitHub.