{"record":{"id":"b66220c56ea662ac","repo":"huggingface/candle","slug":"unsupported-resize-mode","errorCode":null,"errorMessage":"Unsupported resize mode: {}","messagePattern":"Unsupported resize mode: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":2350,"sourceCode":"                    (None, Some(sizes_tensor)) => sizes_tensor\n                        .to_vec1::<i64>()?\n                        .iter()\n                        .map(|&d| d as usize)\n                        .collect::<Vec<_>>(),\n                    (None, None) => bail!(\"Either scales or sizes should be present\"),\n                };\n\n                let coordinate_transformation_mode =\n                    get_attr_opt::<str>(node, \"coordinate_transformation_mode\")?\n                        .unwrap_or(\"half_pixel\");\n                // Interpolation mode: nearest, linear, or cubic.\n                let mode = get_attr_opt::<str>(node, \"mode\")?.unwrap_or(\"nearest\");\n                // How to determine the \"nearest\" pixel in nearest interpolation mode.\n                let nearest_mode =\n                    get_attr_opt::<str>(node, \"nearest_mode\")?.unwrap_or(\"round_prefer_floor\");\n\n                if mode != \"nearest\" {\n                    bail!(\"Unsupported resize mode: {}\", mode);\n                }\n\n                if nearest_mode != \"floor\" {\n                    bail!(\"Unsupported nearest_mode for resize: {}\", nearest_mode);\n                }\n\n                if coordinate_transformation_mode != \"asymmetric\" {\n                    bail!(\n                        \"Unsupported coordinate_transformation_mode for resize: {}\",\n                        coordinate_transformation_mode\n                    );\n                }\n\n                let h = output_dims[2];\n                let w = output_dims[3];\n                let output = input.upsample_nearest2d(h, w)?;\n\n                values.insert(node.output[0].clone(), output);","sourceCodeStart":2332,"sourceCodeEnd":2368,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L2332-L2368","documentation":"candle-onnx only implements the `nearest` interpolation mode for the ONNX Resize operator. Any other `mode` attribute value (`linear`, `cubic`) is rejected at evaluation time with this message. The op is unsupported, not invalid — the model itself is spec-compliant.","triggerScenarios":"Running a model containing `Resize` nodes with attribute mode=\"linear\" (common for bilinear upsampling) or mode=\"cubic\" through simple_eval/simple_eval_.","commonSituations":"Vision models using bilinear resize (segmentation, super-resolution, U-Net variants) exported from PyTorch F.interpolate(mode='bilinear'); centripetal/bicubic resampling in preprocessing graphs.","solutions":["Change the model to use nearest-neighbor resize (mode=\"nearest\") if acceptable","Pre-resize outside the graph and remove the Resize node from the model","Implement linear/cubic resize support in candle-onnx and rebuild","Use a different ONNX runtime (onnxruntime) for models needing linear/cubic resize"],"exampleFix":"# before\n# node attribute: mode = \"linear\"\n# after (PyTorch export)\nF.interpolate(x, scale_factor=2, mode='nearest')","handlingStrategy":"validation","validationCode":"for node in &graph.node {\n    if node.op_type == \"Resize\" {\n        let mode = get_attr_opt::<String>(node, \"mode\")?.unwrap_or_else(|| \"nearest\".into());\n        if mode != \"nearest\" { return Err(format!(\"mode {} unsupported\", mode)); }\n    }\n}","typeGuard":"fn is_nearest_resize(node: &Node) -> bool {\n    node.op_type == \"Resize\"\n        && get_attr_opt::<String>(node, \"mode\").ok().flatten().map_or(true, |m| m == \"nearest\")\n}","tryCatchPattern":"match eval(...) {\n    Err(e) if e.contains(\"Unsupported resize mode\") => fallback_to_onnxruntime(model),\n    other => other,\n}","preventionTips":["Export with mode='nearest' or pre-resize outside the graph","Scan models for mode attribute values at load time","Document supported resize modes for your pipeline"],"tags":["onnx","resize","unsupported-feature"],"backgroundTag":"unsupported-operator-feature","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}