{"record":{"id":"7bbbe1387007efdf","repo":"huggingface/candle","slug":"unsupported-auto-pad-s","errorCode":null,"errorMessage":"unsupported auto_pad {s}","messagePattern":"unsupported auto_pad (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":482,"sourceCode":"                    }\n                };\n                values.insert(node.output[0].clone(), output);\n            }\n            \"Dropout\" => {\n                let input = get(&node.input[0])?;\n                // Do not apply dropout at the moment, consider that we're only doing inference.\n                values.insert(node.output[0].clone(), input.clone());\n            }\n            \"MaxPool\" => {\n                // https://github.com/onnx/onnx/blob/main/docs/Operators.md#MaxPool\n                let dilations = get_attr_opt::<[i64]>(node, \"dilations\")?;\n                let kernel_shape = get_attr::<[i64]>(node, \"kernel_shape\")?;\n                let pads = get_attr_opt::<[i64]>(node, \"pads\")?;\n                let strides = get_attr_opt::<[i64]>(node, \"strides\")?;\n                let auto_pad = get_attr_opt::<str>(node, \"auto_pad\")?;\n                match auto_pad {\n                    None | Some(\"NOTSET\") => (),\n                    Some(s) => bail!(\"unsupported auto_pad {s}\"),\n                };\n                if let Some(d) = dilations {\n                    if d.iter().any(|&v| v != 1) {\n                        bail!(\"MaxPool with dilation != 1, {dilations:?}\")\n                    }\n                }\n                if let Some(d) = pads {\n                    if d.iter().any(|&v| v != 0) {\n                        bail!(\"MaxPool with pads != 0, {pads:?}\")\n                    }\n                }\n                let xs = get(&node.input[0])?;\n                let (k1, k2) = match kernel_shape {\n                    [k1, k2] => (*k1 as usize, *k2 as usize),\n                    _ => bail!(\"only 2d MaxPool is supported, kernel shape {kernel_shape:?}\"),\n                };\n                let ys = match strides {\n                    None => xs.max_pool2d((k1, k2))?,","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L464-L500","documentation":"candle-onnx's MaxPool only supports explicit padding: auto_pad must be absent or \"NOTSET\". Any other auto_pad value (SAME_UPPER, SAME_LOWER, VALID) has no implemented lowering and is rejected at eval time.","triggerScenarios":"Evaluating a MaxPool node whose auto_pad attribute is set to something other than NOTSET, e.g. \"SAME_UPPER\".","commonSituations":"Models exported from TensorFlow (which pads with SAME), PyTorch exports with padding='same', or TFLite→ONNX converters that set auto_pad.","solutions":["Set the node's auto_pad attribute to \"NOTSET\" and provide explicit equivalent pads in the pads attribute","Compute the SAME padding manually (pad = max(0, ceil(out/in)*k - in)) and pass it via pads, ensuring pads are all zero if needed by cropping/adjusting the input","Pre-process the model with onnxsim / a graph rewrite that folds auto_pad into explicit pads"],"exampleFix":"# before (protobuf attr)\nauto_pad: \"SAME_UPPER\"\n# after\nauto_pad: \"NOTSET\"\npads: [1, 1, 1, 1]","handlingStrategy":"validation","validationCode":"fn ensure_no_autopad(node_attrs: &std::collections::HashMap<String, candle_onnx::protobuf::attribute_proto::AttributeType>) {\n    if let Some(ap) = node_attrs.get(\"auto_pad\") {\n        assert!(matches!(ap, \"NOTSET\" | \"\"), \"auto_pad {:?} unsupported\", ap);\n    }\n}","typeGuard":"fn autopad_supported(auto_pad: Option<&str>) -> bool { matches!(auto_pad, None | Some(\"NOTSET\")) }","tryCatchPattern":"match simple_eval(&model, inputs) {\n    Ok(v) => v,\n    Err(e) if e.to_string().contains(\"unsupported auto_pad\") => {\n        eprintln!(\"rewrite pooling node with explicit pads: {}\", e); Default::default()\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Export models with auto_pad=NOTSET and explicit pads","Check pool node attributes with a Netron/onnx dump before loading","Use onnxsim to fold auto_pad into pads","Prefer PyTorch export paths that emit explicit pads"],"tags":["onnx","maxpool","unsupported-op"],"backgroundTag":"unsupported-attribute-value","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}