huggingface/candle · error
Unsupported coordinate_transformation_mode for resize: {}
Error message
Unsupported coordinate_transformation_mode for resize: {} What it means
candle-onnx's Resize implementation only supports coordinate_transformation_mode="asymmetric". ONNX defines several modes (half_pixel, align_corners, pytorch_half_pixel, tf_half_pixel_for_nn, etc.) and the default is half_pixel, so most exported models trigger this error even when mode/nearest_mode are supported.
Source
Thrown at candle-onnx/src/eval.rs:2358
let coordinate_transformation_mode =
get_attr_opt::<str>(node, "coordinate_transformation_mode")?
.unwrap_or("half_pixel");
// Interpolation mode: nearest, linear, or cubic.
let mode = get_attr_opt::<str>(node, "mode")?.unwrap_or("nearest");
// How to determine the "nearest" pixel in nearest interpolation mode.
let nearest_mode =
get_attr_opt::<str>(node, "nearest_mode")?.unwrap_or("round_prefer_floor");
if mode != "nearest" {
bail!("Unsupported resize mode: {}", mode);
}
if nearest_mode != "floor" {
bail!("Unsupported nearest_mode for resize: {}", nearest_mode);
}
if coordinate_transformation_mode != "asymmetric" {
bail!(
"Unsupported coordinate_transformation_mode for resize: {}",
coordinate_transformation_mode
);
}
let h = output_dims[2];
let w = output_dims[3];
let output = input.upsample_nearest2d(h, w)?;
values.insert(node.output[0].clone(), output);
}
"Trilu" => {
let input = get(&node.input[0])?;
// Get the diagonal offset 'k' from the second input if provided
let k = if node.input.len() > 1 && !node.input[1].is_empty() {
to_vec0_flexible::<i64>(get(&node.input[1])?)?
} else {View on GitHub (pinned to d5fee525bf)
Solutions
- Rewrite the Resize node attributes to coordinate_transformation_mode="asymmetric" via onnx-surgement/graph surgery (verify numerics)
- Add half_pixel support to candle-onnx eval.rs
- Compute the resize outside the ONNX graph in candle code
- Use onnxruntime for this model
Example fix
// before
// coordinate_transformation_mode = "half_pixel" (default)
// after
node.attribute.push(onnx_attr("coordinate_transformation_mode", "asymmetric")); Defensive patterns
Strategy: validation
Validate before calling
if node.op_type == "Resize" {
let ctm = get_attr_opt::<String>(node, "coordinate_transformation_mode")?.unwrap_or_else(|| "half_pixel".into());
if ctm != "asymmetric" { return Err(format!("ctm {} unsupported", ctm)); }
} Type guard
fn uses_asymmetric_ctm(node: &Node) -> bool {
get_attr_opt::<String>(node, "coordinate_transformation_mode").ok().flatten().map_or(false, |m| m == "asymmetric")
} Try / catch
match eval(...) {
Err(e) if e.contains("coordinate_transformation_mode") => fallback_to_onnxruntime(model),
other => other,
} Prevention
- Remember the spec default is half_pixel, which is unsupported
- Set coordinate_transformation_mode='asymmetric' at export if numerics allow
- Check resize attributes with onnx.helper during CI
When it happens
Trigger: Evaluating a Resize node whose coordinate_transformation_mode attribute is anything other than "asymmetric", including the spec default "half_pixel".
Common situations: PyTorch exports using align_corners=False produce half_pixel; align_corners=True exports produce align_corners; TF exports produce tf_half_pixel_for_nn — all rejected.
Related errors
- Unsupported resize mode: {}
- Unsupported nearest_mode for resize: {}
- Either scales or sizes should be present
- attribute {} was of type TENSOR, but no tensor was found
- attribute {} of type TENSOR was an invalid data_type number
AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02).
Data as JSON: /api/errors/006cfd4b13e8519f.
Report an issue: GitHub.