{"record":{"id":"d3a5b20abc9b820b","repo":"huggingface/candle","slug":"only-2d-maxpool-is-supported-strides-strides","errorCode":null,"errorMessage":"only 2d MaxPool is supported, strides {strides:?}","messagePattern":"only 2d MaxPool is supported, strides (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":504,"sourceCode":"                        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))?,\n                    Some([s1, s2]) => {\n                        xs.max_pool2d_with_stride((k1, k2), (*s1 as usize, *s2 as usize))?\n                    }\n                    Some(strides) => bail!(\"only 2d MaxPool is supported, strides {strides:?}\"),\n                };\n                values.insert(node.output[0].clone(), ys);\n            }\n            \"AveragePool\" => {\n                // https://github.com/onnx/onnx/blob/main/docs/Operators.md#AveragePool\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!(\"AvgPool with dilation != 1, {dilations:?}\")\n                    }","sourceCodeStart":486,"sourceCodeEnd":522,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L486-L522","documentation":"Raised by the ONNX MaxPool evaluator when a 'strides' attribute is present but does not have exactly two entries. Valid strides are None (stride 1) or a pair [s1, s2] passed to max_pool2d_with_stride; any other length (1D/3D pooling) bails.","triggerScenarios":"MaxPool node with strides attribute of length != 2, e.g. [2] or [2, 2, 2].","commonSituations":"1-D/3-D pooling models, same as kernel-rank mismatch; converters emitting per-axis strides for 1-D pooling.","solutions":["Ensure the MaxPool node uses 2D strides (two entries) matching the 2D kernel","Drop the strides attribute if stride 1 is acceptable"],"exampleFix":"# before\nstrides: [2]\n# after\nstrides: [1, 2]","handlingStrategy":"validation","validationCode":"fn ensure_2d_strides(strides: Option<&[i64]>) -> Result<(), String> {\n    match strides {\n        Some(s) if s.len() != 2 => Err(format!(\"strides {:?} not 2d\", s)),\n        _ => Ok(()),\n    }\n}","typeGuard":"fn strides_supported(s: Option<&[i64]>) -> bool { s.map_or(true, |s| s.len() == 2) }","tryCatchPattern":"match simple_eval(&model, inputs) {\n    Ok(v) => v,\n    Err(e) if e.to_string().contains(\"only 2d MaxPool is supported, strides\") => {\n        eprintln!(\"use two-element strides: {}\", e); Default::default()\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Keep strides attributes two-element for spatial pooling","Check stride rank whenever checking kernel rank","Fix exporters to emit 2-D strides for 2-D pooling"],"tags":["onnx","maxpool","unsupported-op"],"backgroundTag":"unsupported-op-rank","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}