{"record":{"id":"cc106374292b12f1","repo":"huggingface/candle","slug":"unsupported-number-of-inputs-for-pad-node","errorCode":null,"errorMessage":"unsupported number of inputs {} for Pad node {:?}, expected 2","messagePattern":"unsupported number of inputs (.+?) for Pad node (.+?), expected 2","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":1195,"sourceCode":"                        sub_graph.output.len(),\n                        node.output.len()\n                    );\n                }\n                let branch_out = simple_eval_(sub_graph, values)?;\n                for (i, out) in node.output.iter().enumerate() {\n                    values.insert(\n                        out.clone(),\n                        branch_out.get(&sub_graph.output[i].name).unwrap().clone(),\n                    );\n                }\n            }\n            // https://github.com/onnx/onnx/blob/main/docs/Operators.md#pad\n            \"Pad\" => {\n                let mode = get_attr_opt(node, \"mode\")?.unwrap_or(\"constant\");\n                let data = get(&node.input[0])?;\n                let pads = get(&node.input[1])?;\n                if node.input.len() > 2 {\n                    bail!(\n                        \"unsupported number of inputs {} for Pad node {:?}, expected 2\",\n                        node.input.len(),\n                        node.name\n                    );\n                }\n                if pads.rank() != 1 {\n                    bail!(\"Pad expects 'pads' input to be 1D vector: {pads:?}\");\n                }\n                if pads.dim(0).unwrap() != 2 * data.rank() {\n                    bail!(\"Pad expects 'pads' input len to be 2 * rank of 'data' input: pads: {}, data rank: {}\", pads, data.rank());\n                }\n\n                let pads = pads.to_vec1::<i64>()?;\n                let (pads_pre, pads_post) = pads.split_at(pads.len() / 2);\n\n                match mode {\n                    \"reflect\" => {\n                        let mut out = data.clone();","sourceCodeStart":1177,"sourceCodeEnd":1213,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L1177-L1213","documentation":"The Pad node implementation accepts only the 'data' and 'pads' inputs (2 inputs). The ONNX spec allows an optional third 'constant_value' input; candle-onnx does not support it and bails if more than 2 inputs are present.","triggerScenarios":"Evaluating a model with a Pad node having 3 (or more) inputs, i.e. an explicit constant_value (input[2]) or axes (input[3]) input.","commonSituations":"Models exported with opset >= 11 where the exporter emits the constant_value input; newer exporters (opset >= 18) also emitting the axes input.","solutions":["Rewrite the graph to bake the constant value into the node's 'value' attribute form, or use mode-implicit zero padding","Remove the constant_value input and rely on the default (0) if that matches the intended value","Pre-process with onnx python: convert Pad to an older opset form using the 'value' attribute","Patch candle-onnx to read input[2] as constant_value"],"exampleFix":"// before (opset 11)\nPad(data, pads, constant_value)\n// after (opset 2 style)\nPad(data, pads)  # with attribute value=0.0","handlingStrategy":"validation","validationCode":"for node in &graph.node {\n    if node.op_type == \"Pad\" {\n        assert!(node.input.len() <= 2, \"Pad {} has {} inputs\", node.name, node.input.len());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Export Pad with opset <= 10 attribute form or drop the constant_value input","Use candle tensor pad_constant() outside the graph instead of ONNX Pad","Check exporter opset settings (opset >= 11 emits value/axes inputs)"],"tags":["onnx","pad","unsupported-input","opset"],"backgroundTag":"unsupported-op-arity","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}