{"record":{"id":"e4dae7915ac47fb7","repo":"huggingface/candle","slug":"only-exclusive-0-is-supported-in-cumsum","errorCode":null,"errorMessage":"only exclusive == 0 is supported in CumSum","messagePattern":"only exclusive == 0 is supported in CumSum","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":1138,"sourceCode":"                        None => {\n                            bail!(\"unsupported 'to' value {dt:?} for cast {}\", node.name)\n                        }\n                    },\n                    Err(_) => {\n                        bail!(\"unsupported 'to' value {dt:?} for cast {}\", node.name)\n                    }\n                };\n                let output = input.to_dtype(dtype)?;\n                values.insert(node.output[0].clone(), output);\n            }\n            // https://github.com/onnx/onnx/blob/main/docs/Operators.md#CumSum\n            \"CumSum\" => {\n                let exclusive = get_attr_opt::<i64>(node, \"exclusive\")?\n                    .copied()\n                    .unwrap_or(0);\n                let reverse = get_attr_opt::<i64>(node, \"reverse\")?.copied().unwrap_or(0);\n                if exclusive != 0 {\n                    bail!(\"only exclusive == 0 is supported in CumSum\")\n                }\n                if reverse != 0 {\n                    bail!(\"only reverse == 0 is supported in CumSum\")\n                }\n                let input = get(&node.input[0])?;\n                let axis = to_vec0_flexible::<u32>(&get(&node.input[1])?.to_dtype(DType::U32)?)?;\n                let output = input.cumsum(axis as usize)?;\n                values.insert(node.output[0].clone(), output);\n            }\n            //  https://github.com/onnx/onnx/blob/main/docs/Operators.md#flatten\n            \"Flatten\" => {\n                let axis = get_attr_opt::<i64>(node, \"axis\")?.copied().unwrap_or(1) as usize;\n                let input = get(&node.input[0])?;\n                let first_part: usize = input.shape().dims().iter().take(axis).product();\n                let end_index = input.shape().dims().iter().product::<usize>();\n                let new_shape = (first_part, end_index / first_part);\n                let output = input.reshape(new_shape)?;\n                values.insert(node.output[0].clone(), output);","sourceCodeStart":1120,"sourceCodeEnd":1156,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L1120-L1156","documentation":"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.","triggerScenarios":"Evaluating a model with a CumSum node having attribute exclusive=1.","commonSituations":"Models exported from frameworks that use exclusive cumulative sums (e.g. certain sequence/probability models); handwritten ONNX graphs using the full CumSum spec.","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)"],"exampleFix":"// before (python, onnx graph surgery)\nnode.attribute.append(onnx.helper.make_attribute('exclusive', 1))\n// after\nnode.attribute.append(onnx.helper.make_attribute('exclusive', 0))","handlingStrategy":"validation","validationCode":"for node in &graph.node {\n    if node.op_type == \"CumSum\" {\n        let exclusive = get_attr_opt::<i64>(node, \"exclusive\").unwrap_or(None).copied().unwrap_or(0);\n        assert_eq!(exclusive, 0, \"CumSum {} uses exclusive=1\", node.name);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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)"],"tags":["onnx","cumsum","unsupported-attribute","limitation"],"backgroundTag":"unsupported-op-attribute","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}