{"record":{"id":"2b22a2c7f70eff5b","repo":"huggingface/candle","slug":"empty-concat","errorCode":null,"errorMessage":"empty concat","messagePattern":"empty concat","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":994,"sourceCode":"                    let bs = get(&node.input[2])?;\n                    let mut bs_shape = vec![1; ys.rank()];\n                    bs_shape[1] = bs.elem_count();\n                    ys.broadcast_add(&bs.reshape(bs_shape)?)?\n                } else {\n                    ys\n                };\n                values.insert(node.output[0].clone(), ys);\n            }\n            \"Concat\" => {\n                // https://github.com/onnx/onnx/blob/main/docs/Operators.md#Concat\n                let inputs = node\n                    .input\n                    .iter()\n                    .map(|n| Ok(get(n.as_str())?.clone()))\n                    .collect::<Result<Vec<Value>>>()?;\n                let axis: i64 = *get_attr(node, \"axis\")?;\n                if inputs.is_empty() {\n                    bail!(\"empty concat\")\n                };\n                // Find minimum rank among inputs and squeeze trailing singleton dims to match\n                let min_rank = inputs.iter().map(|t| t.rank()).min().unwrap();\n                let inputs: Vec<_> = inputs\n                    .into_iter()\n                    .map(|t| {\n                        let mut t = t;\n                        while t.rank() > min_rank {\n                            let last_dim = t.rank() - 1;\n                            if t.dims()[last_dim] == 1 {\n                                t = t.squeeze(last_dim).unwrap_or(t);\n                            } else {\n                                break;\n                            }\n                        }\n                        t\n                    })\n                    .collect();","sourceCodeStart":976,"sourceCodeEnd":1012,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L976-L1012","documentation":"The Concat operator evaluator gathers all input tensors of the node; if the node declares no inputs, the minimum-rank computation that follows (inputs.iter().map(...).min().unwrap()) would panic, so the evaluator bails with 'empty concat' instead.","triggerScenarios":"Running simple_eval on an ONNX graph containing a Concat node with an empty or missing input list — typically a malformed or corrupted model.","commonSituations":"Programmatically generated ONNX graphs (graph surgery, quantization passes, model pruning tools) that dropped all Concat inputs; hand-built graphs via onnx.helper with inputs forgotten.","solutions":["Fix the graph so the Concat node lists at least one input (with all inputs sharing the same rank except on the concat axis)","Regenerate the model correctly with onnx.helper, passing inputs=[...] to make_node","Run the ONNX checker (onnx.checker.check_model) to catch malformed nodes before inference","Remove the dead Concat node if it is unused graph surgery residue"],"exampleFix":"// before\nnode = onnx.helper.make_node('Concat', inputs=[], outputs=['y'], axis=0)\n// after\nnode = onnx.helper.make_node('Concat', inputs=['a', 'b'], outputs=['y'], axis=0)","handlingStrategy":"validation","validationCode":"for node in &model.graph.node {\n    if node.op_type == \"Concat\" && node.input.is_empty() {\n        panic!(\"Concat node '{}' has no inputs\", node.name);\n    }\n}","typeGuard":null,"tryCatchPattern":"match candle_onnx::simple_eval(&model, &inputs) {\n    Err(e) if e.to_string().contains(\"empty concat\") => {\n        eprintln!(\"malformed graph: Concat without inputs: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Run onnx.checker.check_model on every model before inference","Validate generated graphs in graph-surgery pipelines","Remove unused nodes produced by pruning/quantization tools"],"tags":["onnx","concat","malformed-model"],"backgroundTag":"malformed-onnx-graph","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}