huggingface/candle · error

unsupported 'value' data-type {dt:?} for {name}

Error message

unsupported 'value' data-type {dt:?} for {name}

What it means

get_tensor materializes an ONNX TensorProto into a candle Tensor. Both branches — a recognized data_type with no candle Tensor implementation for it, and an unrecognized numeric data_type — bail reporting the unsupported data type for the given tensor name. This happens when converting initializers or Constant-like tensors during simple_eval_.

Source

Thrown at candle-onnx/src/eval.rs:225

        Ok(dt) => match dtype(dt) {
            Some(dt) => {
                if dt == DType::F32 && !t.float_data.is_empty() {
                    Tensor::from_slice(&t.float_data, dims.as_slice(), &Device::Cpu)
                } 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 {

View on GitHub (pinned to d5fee525bf)

Solutions

  1. Cast the offending tensor to a supported dtype (float32/float16/int32/int64) in the source framework or via Python onnx before loading.
  2. Re-export the model with standard dtype settings (weights in f32).
  3. Update candle-onnx to a version supporting the dtype shown in the error.
  4. If the number is invalid, fix the model file's data_type field with onnx.checker + manual repair.
Defensive patterns

Strategy: validation

Validate before calling

for (name, t) in &model.graph.initializer {
    let dt = onnx::tensor_proto::DataType::try_from(t.data_type)
        .map_err(|_| format!("initializer '{name}' invalid data_type {}", t.data_type))?;
    assert!(matches!(dt, DataType::FLOAT | DataType::INT64 | DataType::FLOAT16), "initializer '{name}' dtype {dt:?} unsupported");
}

Type guard

fn is_materializable(t: &onnx::TensorProto) -> bool {
    onnx::tensor_proto::DataType::try_from(t.data_type)
        .map(|dt| 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
        ))
        .unwrap_or(false)
}

Try / catch

match simple_eval_(&model, inputs) {
    Ok(outs) => outs,
    Err(e) if e.to_string().contains("unsupported 'value' data-type") => {
        // reload a pre-cast (f32) copy of the model
        let model = load_f32_model()?;
        simple_eval_(&model, inputs)?
    }
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling simple_eval_ or building the initializers map on a model whose TensorProto has a data_type candle-onnx cannot materialize (unsupported enum, or a valid ONNX type with no candle conversion, e.g. string/complex/some float variants).

Common situations: Models with bfloat16/float8/string/complex tensors; corrupted data_type integers; exporters writing exotic dtypes; older candle versions missing newer dtype support.

Related errors


AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02). Data as JSON: /api/errors/d503ce2f2ff5ee0d. Report an issue: GitHub.