{"record":{"id":"eab96c6266423745","repo":"huggingface/candle","slug":"unsupported-input-type-type","errorCode":null,"errorMessage":"unsupported input type {type_:?}","messagePattern":"unsupported input type (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":283,"sourceCode":"            None => continue,\n        };\n        let tensor_type = match input_type {\n            onnx::type_proto::Value::TensorType(tt) => tt,\n            _ => continue,\n        };\n\n        let tensor = match values.get(&input.name) {\n            None => bail!(\"missing input {}\", input.name),\n            Some(tensor) => tensor,\n        };\n        let dt = match DataType::try_from(tensor_type.elem_type) {\n            Ok(dt) => match dtype(dt) {\n                Some(dt) => dt,\n                None => {\n                    bail!(\"unsupported 'value' data-type {dt:?} for {}\", input.name)\n                }\n            },\n            type_ => bail!(\"unsupported input type {type_:?}\"),\n        };\n        match &tensor_type.shape {\n            None => continue,\n            Some(shape) => {\n                if shape.dim.len() != tensor.rank() {\n                    bail!(\n                        \"unexpected rank for {}, got {:?}, expected {:?}\",\n                        input.name,\n                        shape.dim,\n                        tensor.shape()\n                    )\n                }\n                for (idx, (d, &dim)) in shape.dim.iter().zip(tensor.dims().iter()).enumerate() {\n                    match &d.value {\n                        Some(onnx::tensor_shape_proto::dimension::Value::DimValue(v)) => {\n                            if *v as usize != dim {\n                                bail!(\n                                    \"unexpected dim {idx} for {}, got {:?}, expected {:?}\",","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L265-L301","documentation":"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).","triggerScenarios":"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.","commonSituations":"Manually patched .onnx files; models from in-house exporters writing raw ints for elem_type; partially written/truncated model files.","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."],"exampleFix":"// before\n# elem_type: 999 in graph.input (hand-edited)\n// after\n# elem_type: 1 (FLOAT) — validate with: python -c \"import onnx; onnx.checker.check_model(onnx.load('m.onnx'))\"","handlingStrategy":"validation","validationCode":"fn elem_types_valid(model: &onnx::ModelProto) -> bool {\n    use candle_onnx::DataType;\n    model.graph.as_ref().map_or(true, |g| g.input.iter().all(|i| {\n        match &i.r#type.value {\n            Some(onnx::type_proto::Value::TensorType(tt)) =>\n                DataType::try_from(tt.elem_type).is_ok(),\n            _ => true,\n        }\n    }))\n}","typeGuard":"fn is_known_elem_type(elem_type: i32) -> bool {\n    candle_onnx::DataType::try_from(elem_type).is_ok()\n}","tryCatchPattern":"if let Err(e) = simple_eval(&model, inputs) {\n    if e.to_string().contains(\"unsupported input type\") {\n        anyhow::bail!(\"model declares an invalid elem_type; run onnx.checker on the file\");\n    }\n    return Err(e.into());\n}","preventionTips":["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"],"tags":["onnx","invalid-model","protobuf","eval"],"backgroundTag":"invalid-onnx-model","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}