huggingface/candle · error
attribute {} of type TENSOR has an unsupported data_type {}
Error message
attribute {} of type TENSOR has an unsupported data_type {} What it means
The tensor attribute's data_type is a valid ONNX type, but candle-onnx has no mapping from that ONNX DataType to a candle DType. Types without candle equivalents (e.g. certain float8/complex/uint variants depending on candle version) are rejected rather than silently misinterpreted.
Source
Thrown at candle-onnx/src/eval.rs:105
Some(value) => value,
None => bail!(
"attribute {} was of type TENSOR, but no tensor was found",
attr.name
),
};
let data_type = match DataType::try_from(tensor_proto.data_type) {
Ok(value) => value,
Err(_) => bail!(
"attribute {} of type TENSOR was an invalid data_type number {}",
attr.name,
tensor_proto.data_type
),
};
let dtype = match dtype(data_type) {
Some(value) => value,
None => bail!(
"attribute {} of type TENSOR has an unsupported data_type {}",
attr.name,
data_type.as_str_name()
),
};
let mut dims = Vec::with_capacity(tensor_proto.dims.len());
for dim in &tensor_proto.dims {
if dim < &0 {
bail!(
"attribute {} of type TENSOR has a negative dimension, which is unsupported",
attr.name
)
}
dims.push(*dim as usize)
}
Tensor::from_raw_buffer(&tensor_proto.raw_data, dtype, &dims, &Device::Cpu)View on GitHub (pinned to d5fee525bf)
Solutions
- Convert the model's tensors to a supported dtype (f32/f16/i64) before loading, e.g. cast weights in Python with onnx.
- Regenerate the model exporting float32 parameters.
- Update candle/candle-onnx to a version that supports the needed dtype.
- Replace the unsupported attribute tensor with an equivalent supported representation.
Defensive patterns
Strategy: validation
Validate before calling
let dt = onnx::tensor_proto::DataType::try_from(t.data_type)?;
let supported = [DataType::FLOAT, DataType::INT32, DataType::INT64, DataType::FLOAT16];
assert!(supported.contains(&dt), "unsupported dtype {dt:?} for '{name}'"); Type guard
fn is_candle_supported(dt: onnx::tensor_proto::DataType) -> bool {
matches!(
dt,
onnx::tensor_proto::DataType::FLOAT
| onnx::tensor_proto::DataType::FLOAT16
| onnx::tensor_proto::DataType::INT32
| onnx::tensor_proto::DataType::INT64
| onnx::tensor_proto::DataType::UINT8
| onnx::tensor_proto::DataType::BOOL
)
} Try / catch
match get_attr::<Tensor>(node, name) {
Ok(v) => v,
Err(e) if e.to_string().contains("unsupported data_type") => {
// pre-cast model tensors to f32 and retry
return Err(e);
}
Err(e) => return Err(e),
} Prevention
- Convert models to f32/f16/i64 before loading
- Check candle-onnx release notes for newly supported dtypes
- Avoid bfloat16/complex/string tensors in attributes
When it happens
Trigger: Loading an ONNX tensor attribute (or initializer via get_tensor) whose element type is one candle-onnx's dtype() mapping does not support, e.g. BFLOAT16/FLOAT8/COMPLEX types on candle versions lacking them.
Common situations: Models using bfloat16 weights or newer float8 formats; exporters emitting complex or string tensors for attributes; older candle-onnx not yet supporting recently added ONNX dtypes.
Related errors
- attribute {} of type TENSOR was an invalid data_type number
- unsupported 'value' data-type {dt:?} for {name}
- attribute {} was of type TENSOR, but no tensor was found
- 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/305bbbcaeb1d2ea1.
Report an issue: GitHub.