huggingface/candle · error
unsupported 'value' data-type {} for {name}
Error message
unsupported 'value' data-type {} for {name} What it means
get_tensor parses an ONNX TensorProto initializer/attribute value into a candle Tensor. It bails when the tensor's data_type is either not representable as a candle DType (dtype(dt) returned None) or when the raw data cannot be interpreted via tensor_proto::try_from at all. The library only supports a fixed set of ONNX element types, and this model carries an initializer whose type is outside that set.
Source
Thrown at candle-onnx/src/eval.rs:229
} else if dt == DType::F64 && !t.double_data.is_empty() {
Tensor::from_slice(&t.double_data, dims.as_slice(), &Device::Cpu)
} else if dt == DType::I64 && !t.int64_data.is_empty() {
Tensor::from_slice(&t.int64_data, dims.as_slice(), &Device::Cpu)
} else {
Tensor::from_raw_buffer(
t.raw_data.as_slice(),
dt,
dims.as_slice(),
&Device::Cpu,
)
}
}
None => {
bail!("unsupported 'value' data-type {dt:?} for {name}")
}
},
Err(_) => {
bail!("unsupported 'value' data-type {} for {name}", t.data_type,)
}
}
}
// This function provides a direct evaluation of the proto.
// Longer-term, we should first convert the proto to an intermediate representation of the compute
// graph so as to make multiple evaluations more efficient.
// An example upside of this would be to remove intermediary values when they are not needed
// anymore.
pub fn simple_eval(
model: &onnx::ModelProto,
mut inputs: HashMap<String, Value>,
) -> Result<HashMap<String, Value>> {
let graph = match &model.graph {
None => bail!("no graph defined in proto"),
Some(graph) => graph,
};
simple_eval_(graph, &mut inputs)View on GitHub (pinned to d5fee525bf)
Solutions
- Inspect the failing tensor's data_type (name is printed in the message) and re-export the model with only supported dtypes (float16/float32/float64, int8/16/32/64, uint8/16/32/64, bool).
- If the tensor is an optional constant, remove or replace it with a supported dtype using onnxruntime/onnx tooling.
- Upgrade candle-onnx to a version that supports the required data type.
- As a workaround, pre-convert the initializer externally and feed it as a named input instead of an initializer.
Example fix
// before // model contains an initializer of type FLOAT8 // after // re-export: python -c "import onnx; ... # convert unsupported init to float32 or drop it, then save model"
Defensive patterns
Strategy: validation
Validate before calling
fn init_types_supported(model: &onnx::ModelProto) -> bool {
model.graph.as_ref().map_or(true, |g| g.initializer.iter().all(|t| {
matches!(t.data_type,
1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13) // FLOAT..DOUBLE, BOOL, etc.
}))
} Try / catch
match simple_eval(&model, inputs) {
Err(e) if e.to_string().contains("unsupported 'value' data-type") => {
eprintln!("model uses an initializer dtype candle-onnx cannot load; re-export as f32/i64");
}
other => other?,
} Prevention
- Re-export models restricted to f32/i64/u8/bool dtypes
- Run onnx.checker and inspect initializer dtypes before shipping a model
- Keep candle-onnx updated for new dtype support
- Beware quantized (int4/float8) and string-tensor models
When it happens
Trigger: Loading an ONNX model whose initializers include a TensorProto with an unsupported elem_type (e.g. complex64/complex128, float8 variants, string/uint4/int4), or whose raw_data field fails protobuf conversion. Raised during simple_eval_ initializer loading, during node attribute evaluation, and directly by callers of get_tensor.
Common situations: Models exported with newer opset types than this crate supports; quantized models with 4-bit types; models using string-tensor constants (e.g. lookup tables); mixed-precision float8 models from recent exporters.
Related errors
- unsupported 'value' data-type {dt:?} for {}
- attribute {} of type TENSOR was an invalid data_type number
- attribute {} of type TENSOR has an unsupported data_type {}
- unsupported 'value' data-type {dt:?} for {name}
- no graph defined in proto
AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02).
Data as JSON: /api/errors/64d73dea600e9667.
Report an issue: GitHub.