huggingface/candle · error
unsupported input type {type_:?}
Error message
unsupported input type {type_:?} What it means
The match on DataType::try_from(tensor_type.elem_type) has a catch-all arm: if the elem_type is not even a recognized ONNX DataType value (TryFrom failed), the raw type enum is printed and this error is thrown. It indicates the model declares an input element type outside the known ONNX type set (or a reserved/invalid integer).
Source
Thrown at candle-onnx/src/eval.rs:283
None => continue,
};
let tensor_type = match input_type {
onnx::type_proto::Value::TensorType(tt) => tt,
_ => continue,
};
let tensor = match values.get(&input.name) {
None => bail!("missing input {}", input.name),
Some(tensor) => tensor,
};
let dt = match DataType::try_from(tensor_type.elem_type) {
Ok(dt) => match dtype(dt) {
Some(dt) => dt,
None => {
bail!("unsupported 'value' data-type {dt:?} for {}", input.name)
}
},
type_ => bail!("unsupported input type {type_:?}"),
};
match &tensor_type.shape {
None => continue,
Some(shape) => {
if shape.dim.len() != tensor.rank() {
bail!(
"unexpected rank for {}, got {:?}, expected {:?}",
input.name,
shape.dim,
tensor.shape()
)
}
for (idx, (d, &dim)) in shape.dim.iter().zip(tensor.dims().iter()).enumerate() {
match &d.value {
Some(onnx::tensor_shape_proto::dimension::Value::DimValue(v)) => {
if *v as usize != dim {
bail!(
"unexpected dim {idx} for {}, got {:?}, expected {:?}",View on GitHub (pinned to d5fee525bf)
Solutions
- Validate the model with the official onnx python checker (onnx.checker.check_model) to find invalid elem_types.
- Fix or re-generate the model so all inputs use standard elem_type values.
- If the model comes from a third party, ask for a re-export from the original framework.
- Add a pre-check in your loader that rejects models failing protobuf enum conversion with a clear message.
Example fix
// before
# elem_type: 999 in graph.input (hand-edited)
// after
# elem_type: 1 (FLOAT) — validate with: python -c "import onnx; onnx.checker.check_model(onnx.load('m.onnx'))" Defensive patterns
Strategy: validation
Validate before calling
fn elem_types_valid(model: &onnx::ModelProto) -> bool {
use candle_onnx::DataType;
model.graph.as_ref().map_or(true, |g| g.input.iter().all(|i| {
match &i.r#type.value {
Some(onnx::type_proto::Value::TensorType(tt)) =>
DataType::try_from(tt.elem_type).is_ok(),
_ => true,
}
}))
} Type guard
fn is_known_elem_type(elem_type: i32) -> bool {
candle_onnx::DataType::try_from(elem_type).is_ok()
} Try / catch
if let Err(e) = simple_eval(&model, inputs) {
if e.to_string().contains("unsupported input type") {
anyhow::bail!("model declares an invalid elem_type; run onnx.checker on the file");
}
return Err(e.into());
} Prevention
- Run onnx.checker.check_model before loading
- Avoid hand-editing .onnx protobufs
- Re-generate models from the source framework instead of patching
- Validate downloads with checksums
When it happens
Trigger: simple_eval with a model whose graph.input elem_type is an invalid or reserved protobuf enum value — usually from a hand-edited model, an older/nonstandard exporter, or bit-corruption.
Common situations: Manually patched .onnx files; models from in-house exporters writing raw ints for elem_type; partially written/truncated model files.
Related errors
- no graph defined in proto
- missing input {}
- unsupported 'value' data-type {dt:?} for {}
- unexpected rank for {}, got {:?}, expected {:?}
- unexpected dim {idx} for {}, got {:?}, expected {:?}
AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02).
Data as JSON: /api/errors/eab96c6266423745.
Report an issue: GitHub.