{"record":{"id":"f21a3f3b00c2d455","repo":"huggingface/candle","slug":"unsupported-mode-value-mode-for-pad-node","errorCode":null,"errorMessage":"unsupported 'mode' value {mode:?} for Pad node {:?}","messagePattern":"unsupported 'mode' value (.+?) for Pad node (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":1237,"sourceCode":"                                std::iter::repeat((min..max).chain((min + 1..=max).rev())).flatten()\n                            }\n                            let idx = if dim > 1 {\n                                let cycle_len = dim * 2 - 2;\n                                let skip = cycle_len - ((pads_pre[i] as usize) % cycle_len);\n                                let idx = zigzag(0, (dim - 1) as i64)\n                                    .skip(skip)\n                                    .take((pads_pre[i] as usize) + dim + (pads_post[i] as usize));\n                                Tensor::from_iter(idx, out.device())?\n                            } else {\n                                Tensor::full(0i64, (dim,), out.device())?\n                            };\n\n                            out = out.index_select(&idx, i)?;\n                        }\n\n                        values.insert(node.output[0].clone(), out);\n                    }\n                    _ => bail!(\n                        \"unsupported 'mode' value {mode:?} for Pad node {:?}\",\n                        node.name\n                    ),\n                }\n            }\n            // https://github.com/onnx/onnx/blob/main/docs/Operators.md#slice\n            \"Slice\" => {\n                let data = get(&node.input[0])?;\n                let starts = get(&node.input[1])?;\n                let ends = get(&node.input[2])?;\n                let default_axes;\n                let default_steps;\n                let axes: &Tensor;\n                let steps: &Tensor;\n                // If axes are omitted, they are set to [0, ..., r-1]. If steps are omitted,\n                // they are set to [1, ..., 1] of length len(starts)\n                match node.input.len() {\n                    3 => {","sourceCodeStart":1219,"sourceCodeEnd":1255,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L1219-L1255","documentation":"Pad supports only the modes implemented in the match arms above this bail! (e.g. 'constant', 'reflect', etc.). An unrecognized or unimplemented 'mode' attribute value falls through to the default arm and throws this error.","triggerScenarios":"Evaluating a Pad node with mode set to a string not handled by candle-onnx, such as 'edge' or 'wrap', or a typo/None-ish value.","commonSituations":"Models using torch.nn.functional.pad with mode='replicate'/'circular' exported as 'edge'/'wrap'; exporter writing a nonstandard mode string.","solutions":["Change the Pad node's mode attribute to one supported by candle-onnx (e.g. 'constant')","Pre-pad the tensor in host code (candle tensor ops) and remove the Pad node from the graph","Approximate edge/wrap padding with Slice+Concat nodes that candle-onnx supports","Patch eval.rs to add the missing mode arm"],"exampleFix":"// before\nonnx.helper.make_attribute('mode', 'wrap')\n// after\nonnx.helper.make_attribute('mode', 'constant')","handlingStrategy":"validation","validationCode":"const SUPPORTED_PAD_MODES: [&str; 1] = [\"constant\"];\nfor node in &graph.node {\n    if node.op_type == \"Pad\" {\n        let mode = get_attr_opt::<String>(node, \"mode\").unwrap_or(None).unwrap_or_else(|| \"constant\".into());\n        assert!(SUPPORTED_PAD_MODES.contains(&mode.as_str()), \"Pad mode '{}' unsupported\", mode);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use mode='constant' in exported models","Implement edge/wrap padding via Slice+Concat in the graph","Host-side pad with candle's Tensor::pad before inference"],"tags":["onnx","pad","unsupported-attribute","limitation"],"backgroundTag":"unsupported-op-attribute","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}