huggingface/candle · error
unsupported type {:?} for '{name}' attribute in '{}' for {}
Error message
unsupported type {:?} for '{name}' attribute in '{}' for {} What it means
get_attr fetches a required attribute and then checks its attribute_type against the expected Rust type T::TYPE. When the attribute exists but has a different ONNX type (e.g. INT vs INTS, or FLOAT vs TENSOR), the library bails with the actual type, attribute name, op_type and node name.
Source
Thrown at candle-onnx/src/eval.rs:143
}
fn get_attr_<'a>(node: &'a onnx::NodeProto, name: &str) -> Result<&'a onnx::AttributeProto> {
match node.attribute.iter().find(|attr| attr.name == name) {
None => {
bail!(
"cannot find the '{name}' attribute in '{}' for {}",
node.op_type,
node.name
)
}
Some(dt) => Ok(dt),
}
}
fn get_attr<'a, T: Attr + ?Sized>(node: &'a onnx::NodeProto, name: &str) -> Result<&'a T> {
let attr = get_attr_(node, name)?;
if attr.r#type() != T::TYPE {
bail!(
"unsupported type {:?} for '{name}' attribute in '{}' for {}",
attr.r#type,
node.op_type,
node.name
)
}
T::get(attr)
}
fn get_attr_opt<'a, T: Attr + ?Sized>(
node: &'a onnx::NodeProto,
name: &str,
) -> Result<Option<&'a T>> {
match node.attribute.iter().find(|attr| attr.name == name) {
None => Ok(None),
Some(attr) => {
if attr.r#type() != T::TYPE {
bail!(View on GitHub (pinned to d5fee525bf)
Solutions
- Inspect the attribute's r#type in the error and fix the model so it matches the expected ONNX attribute type from the operator spec.
- Re-export the model with the standard exporter for the target opset.
- Convert the attribute in-place with Python onnx (e.g. wrap an int into an ints list).
- Ensure the candle-onnx op implementation matches your model's opset.
Defensive patterns
Strategy: type-guard
Validate before calling
let attr = node.attribute.iter().find(|a| a.name == name).ok_or("missing")?;
assert_eq!(attr.r#type(), expected_type, "attr '{name}' has type {:?}, expected {:?}", attr.r#type, expected_type); Type guard
fn attr_is(attr: &onnx::AttributeProto, t: onnx::AttributeType) -> bool {
attr.r#type() == t
} Try / catch
match get_attr::<i64>(node, "axis") {
Ok(v) => v,
Err(e) if e.to_string().contains("unsupported type") => return Err(e.into()),
Err(e) => return Err(e.into()),
} Prevention
- Check attribute types against the ONNX operator spec when debugging exporter output
- Validate the whole model with onnx.checker before Rust inference
- Pin exporter versions and opsets known to work with candle-onnx
When it happens
Trigger: Evaluating a model where an op's attribute is stored with a different type than candle-onnx's implementation expects, e.g. reading an INT attribute but the model stores it as FLOAT, or a scalar where a list was expected.
Common situations: Exporter quirks writing attributes as the wrong type; opset migrations changing attribute types; hand-edited ONNX files; converter bugs.
Related errors
- attribute {} was of type TENSOR, but no tensor was found
- attribute {} of type TENSOR was an invalid data_type number
- attribute {} of type TENSOR has an unsupported data_type {}
- attribute {} of type TENSOR has a negative dimension, which
- cannot find the '{name}' attribute in '{}' for {}
AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02).
Data as JSON: /api/errors/0769944994cf295f.
Report an issue: GitHub.