{"record":{"id":"cee38a24cb8d75a3","repo":"huggingface/candle","slug":"dilations-have-to-be-the-same-on-both-axis-pads","errorCode":null,"errorMessage":"dilations have to be the same on both axis {pads:?} {}","messagePattern":"dilations have to be the same on both axis (.+?) (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":957,"sourceCode":"                            Some([p1, p2]) => {\n                                if p1 != p2 {\n                                    bail!(\n                                        \"strides have to be the same on both axis {pads:?} {}\",\n                                        node.name\n                                    )\n                                }\n                                *p1 as usize\n                            }\n                            Some(s) => {\n                                bail!(\"more strides than expected in conv2d {s:?} {}\", node.name)\n                            }\n                        };\n                        let dilations = match dilations {\n                            None => 1,\n                            Some([p]) => *p as usize,\n                            Some([p1, p2]) => {\n                                if p1 != p2 {\n                                    bail!(\n                                        \"dilations have to be the same on both axis {pads:?} {}\",\n                                        node.name\n                                    )\n                                }\n                                *p1 as usize\n                            }\n                            Some(s) => {\n                                bail!(\"more dilations than expected in conv2d {s:?} {}\", node.name)\n                            }\n                        };\n                        xs.conv2d(ws, pads, strides, dilations, groups as usize)?\n                    }\n                    rank => bail!(\n                        \"unsupported rank for weight matrix {rank} in conv {}\",\n                        node.name\n                    ),\n                };\n                let ys = if node.input.len() > 2 {","sourceCodeStart":939,"sourceCodeEnd":975,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L939-L975","documentation":"For a Conv node with rank-2 weights, when the `dilations` attribute has two values candle-onnx requires both to be identical since it forwards a single dilation scalar to candle's conv2d. Mismatched per-axis dilations (p1 != p2) cause this bail; the message text interpolates `pads` by mistake but the problem is dilations.","triggerScenarios":"simple_eval processes a Conv node with dilations like [2,4] — an atrous/dilated convolution with different rates per axis.","commonSituations":"TensorFlow tf.nn.atrous_conv2d variants with per-axis rates exported to ONNX; segmentation models (DeepLab-style) with asymmetric dilation; converted TFLite graphs.","solutions":["Change the model so both dilation values are equal and re-export","Replace per-axis dilation with a stack of equal-dilation convs or larger kernels in the source model","Patch candle-onnx to pass per-axis dilations to candle's conv2d","Edit the ONNX attribute directly to dilations=[d,d] when the model semantics allow it"],"exampleFix":"// before (TF): Conv2D(..., dilations=[2, 4])\n// after: Conv2D(..., dilations=[2, 2])  # re-export to ONNX","handlingStrategy":"validation","validationCode":"for node in &model.graph.node {\n    if node.op_type == \"Conv\" {\n        if let Some(d) = node.attribute.iter().find(|a| a.name == \"dilations\") {\n            if d.ints.len() == 2 && d.ints[0] != d.ints[1] {\n                panic!(\"node {}: asymmetric dilations {:?} unsupported\", node.name, d.ints);\n            }\n        }\n    }\n}","typeGuard":"fn has_uniform_dilations(attr: &Attribute) -> bool {\n    attr.name != \"dilations\" || attr.ints.iter().all(|&d| d == attr.ints[0])\n}","tryCatchPattern":"match candle_onnx::simple_eval(&model, &inputs) {\n    Err(e) if e.to_string().contains(\"dilations have to be the same\") => {\n        eprintln!(\"model needs symmetric conv dilations: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Use equal dilation rates per axis in dilated convolutions","Lint for asymmetric dilations in exported models","Route models with per-axis dilation to a backend with full support"],"tags":["onnx","conv2d","dilations"],"backgroundTag":"unsupported-onnx-attribute","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}