{"record":{"id":"ab8c384ec6aced11","repo":"huggingface/candle","slug":"more-dilations-than-expected-in-conv2d-s","errorCode":null,"errorMessage":"more dilations than expected in conv2d {s:?} {}","messagePattern":"more dilations than expected in conv2d (.+?) (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":965,"sourceCode":"                            }\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 {\n                    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);","sourceCodeStart":947,"sourceCodeEnd":983,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L947-L983","documentation":"candle-onnx handles Conv nodes with weight rank 1 (conv1d), 2 (conv2d) or 4 (via batched-matmul path); any other weight rank has no mapped implementation, so the catch-all match arm bails with this message including the actual rank.","triggerScenarios":"A Conv node whose weight (W) input is 3D, 5D, or otherwise not rank 1/2/4, e.g. a 3D convolution exported with the generic Conv op.","commonSituations":"3D convolutions (video/volumetric models) exported to ONNX; models exported with squeezed/reshaped weights; converters that emit non-standard weight ranks.","solutions":["Rewrite the model to use supported ops (e.g. express 3D conv as 2D convs or matmuls) and re-export","Reshape weights to rank 4 and adjust the graph accordingly when semantics permit","Use onnxruntime or another backend that supports arbitrary-rank Conv for this model","Contribute/patch conv3d support in candle-onnx"],"exampleFix":"// before: 3D conv weights shape [64, 32, 3, 3, 3]\n// after: reshape to [64, 32*3, 3, 3] and use two stacked 2D convs, then re-export","handlingStrategy":"validation","validationCode":"for node in &model.graph.node {\n    if node.op_type == \"Conv\" {\n        let w_name = &node.input[1];\n        let w = model.graph.initializer.iter().find(|t| &t.name == w_name);\n        if let Some(t) = w {\n            let rank = t.dims.len();\n            if !matches!(rank, 1 | 2 | 4) {\n                panic!(\"node {}: conv weight rank {} unsupported\", node.name, rank);\n            }\n        }\n    }\n}","typeGuard":"fn conv_weight_rank_ok(dims: &[i64]) -> bool {\n    matches!(dims.len(), 1 | 2 | 4)\n}","tryCatchPattern":"match candle_onnx::simple_eval(&model, &inputs) {\n    Err(e) if e.to_string().contains(\"unsupported rank for weight matrix\") => {\n        eprintln!(\"model uses an unsupported conv weight rank: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Inspect conv weight shapes with Netron before choosing candle-onnx","Avoid 3D/5D convolutions in models targeted at candle-onnx","Rewrite unsupported convs into supported ops during export"],"tags":["onnx","conv","unsupported-rank"],"backgroundTag":"unsupported-onnx-attribute","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}