{"record":{"id":"0b2c6c7809f1badb","repo":"huggingface/candle","slug":"attribute-was-of-type-tensor-but-no-tensor-was","errorCode":null,"errorMessage":"attribute {} was of type TENSOR, but no tensor was found","messagePattern":"attribute (.+?) was of type TENSOR, but no tensor was found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":88,"sourceCode":"\nimpl AttrOwned for Vec<String> {\n    const TYPE: AttributeType = AttributeType::Strings;\n    fn get(attr: &onnx::AttributeProto) -> Result<Self> {\n        let mut ret = vec![];\n        for bytes in attr.strings.iter() {\n            let s = String::from_utf8(bytes.clone()).map_err(candle::Error::wrap)?;\n            ret.push(s);\n        }\n        Ok(ret)\n    }\n}\n\nimpl AttrOwned for Tensor {\n    const TYPE: AttributeType = AttributeType::Tensor;\n    fn get(attr: &onnx::AttributeProto) -> Result<Self> {\n        let tensor_proto = match &attr.t {\n            Some(value) => value,\n            None => bail!(\n                \"attribute {} was of type TENSOR, but no tensor was found\",\n                attr.name\n            ),\n        };\n\n        let data_type = match DataType::try_from(tensor_proto.data_type) {\n            Ok(value) => value,\n            Err(_) => bail!(\n                \"attribute {} of type TENSOR was an invalid data_type number {}\",\n                attr.name,\n                tensor_proto.data_type\n            ),\n        };\n\n        let dtype = match dtype(data_type) {\n            Some(value) => value,\n            None => bail!(\n                \"attribute {} of type TENSOR has an unsupported data_type {}\",","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L70-L106","documentation":"AttrOwned::get for the Tensor attribute type extracts the embedded TensorProto from an ONNX AttributeProto. When the attribute is declared as type TENSOR but its `t` field is None (no actual tensor payload), the library cannot proceed and bails. This indicates a malformed or unusual ONNX model file.","triggerScenarios":"Parsing an ONNX model whose node attribute has attribute_type TENSOR but a missing `t` field; calling simple_eval_ / forward on such a model; any get_attr::<Tensor> / get_attr_opt_owned::<Tensor> call on that attribute.","commonSituations":"Hand-edited or programmatically generated ONNX files where the tensor payload was never set; ONNX produced by a converter bug; model files written by an older/newer opset with different attribute conventions.","solutions":["Re-export or re-generate the ONNX model from the original framework (PyTorch/TF) with a standard exporter.","Inspect the model (e.g. with Python onnx + onnx.checker) to find the attribute with type TENSOR but no `t` payload and fix it.","Use a different attribute accessor if the value is actually stored as a graph (g) or sparse_tensor (sparse_tensor) field.","Update candle-onnx in case newer versions handle the model variant."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let attr = node.attribute.iter().find(|a| a.name == name).ok_or(\"missing attr\")?;\nassert_eq!(attr.r#type(), onnx::AttributeType::Tensor, \"not a TENSOR attr\");\nassert!(attr.t.is_some(), \"TENSOR attr has no tensor payload\");","typeGuard":"fn has_tensor_payload(attr: &onnx::AttributeProto) -> bool {\n    attr.r#type() == onnx::AttributeType::Tensor && attr.t.is_some()\n}","tryCatchPattern":"match get_attr::<Tensor>(node, \"value\") {\n    Ok(t) => t,\n    Err(e) if e.to_string().contains(\"no tensor was found\") => {\n        // fall back to initializer or reject the model\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Run onnx.checker on every model file before loading it in Rust","Reject models at ingest time if any TENSOR attribute lacks a payload","Keep exporters up to date; avoid hand-edited ONNX"],"tags":["rust","candle","onnx","attribute"],"backgroundTag":"onnx-attribute-type-mismatch","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}