{"record":{"id":"1ad1821623ec1710","repo":"huggingface/candle","slug":"unsupported-value-type-rtype-for","errorCode":null,"errorMessage":"unsupported 'value' type {rtype:?} for {}","messagePattern":"unsupported 'value' type (.+?) for (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":1107,"sourceCode":"                let input = get(&node.input[0])?;\n                let output = input.floor()?;\n                values.insert(node.output[0].clone(), output);\n            }\n            // https://github.com/onnx/onnx/blob/main/docs/Operators.md#Constant\n            \"Constant\" => {\n                let value = match node.attribute.iter().find(|attr| attr.name == \"value\") {\n                    None => {\n                        // TODO: support sparse_value etc.\n                        bail!(\"cannot find 'value' attr in 'Constant' for {}\", node.name)\n                    }\n                    Some(value) => value,\n                };\n                let output = match value.r#type() {\n                    AttributeType::Tensor => {\n                        let t = value.t.as_ref().unwrap();\n                        get_tensor(t, &node.name)?\n                    }\n                    rtype => bail!(\"unsupported 'value' type {rtype:?} for {}\", node.name),\n                };\n\n                values.insert(node.output[0].clone(), output);\n            }\n            // https://github.com/onnx/onnx/blob/main/docs/Operators.md#Cast\n            \"Cast\" => {\n                let input = get(&node.input[0])?;\n                let dt: i64 = *get_attr(node, \"to\")?;\n                let dtype = match DataType::try_from(dt as i32) {\n                    Ok(DataType::Int32) => DType::I64,\n                    Ok(dt) => match dtype(dt) {\n                        Some(dt) => dt,\n                        None => {\n                            bail!(\"unsupported 'to' value {dt:?} for cast {}\", node.name)\n                        }\n                    },\n                    Err(_) => {\n                        bail!(\"unsupported 'to' value {dt:?} for cast {}\", node.name)","sourceCodeStart":1089,"sourceCodeEnd":1125,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L1089-L1125","documentation":"Once a Constant node's `value` attribute is found, candle-onnx only materializes it when its type is AttributeType::Tensor. Any other attribute type (e.g. GRAPH, SPARSE_TENSOR, STRING, INTS, FLOATS) is rejected with this bail naming the node.","triggerScenarios":"A Constant node's `value` attribute exists but is typed as sparse tensor, graph, or a primitive list rather than a dense Tensor, so the match falls to the rtype catch-all.","commonSituations":"Models exported with sparse tensor constants; graphs embedding subgraph constants; converters that set value as a repeated float/int field while still naming the attribute 'value'.","solutions":["Densify sparse constants into regular tensors (onnx sparse_to_dense tooling) and re-export","Rewrite the attribute to a Tensor via numpy_helper.from_array in the source graph","Use onnxsim/onnx-optimizer to fold constants into initializers","Patch candle-onnx to handle SPARSE_TENSOR and primitive attribute types"],"exampleFix":"// before: value attribute stored as sparse_tensor\n// after\nsparse = node.attribute[0].sparse_tensor\ndense = onnx.helper.make_attribute('value', onnx.sparse_to_dense(sparse))\nnode.attribute.remove(node.attribute[0]); node.attribute.append(dense)","handlingStrategy":"validation","validationCode":"for node in &model.graph.node {\n    if node.op_type == \"Constant\" {\n        if let Some(v) = node.attribute.iter().find(|a| a.name == \"value\") {\n            if v.r#type() != AttributeType::Tensor {\n                panic!(\"Constant node '{}': value type {:?} unsupported\", node.name, v.r#type());\n            }\n        }\n    }\n}","typeGuard":"fn constant_is_tensor(node: &NodeProto) -> bool {\n    node.attribute.iter()\n        .find(|a| a.name == \"value\")\n        .map(|v| v.r#type() == AttributeType::Tensor)\n        .unwrap_or(false)\n}","tryCatchPattern":"match candle_onnx::simple_eval(&model, &inputs) {\n    Err(e) if e.to_string().contains(\"unsupported 'value' type\") => {\n        eprintln!(\"densify or retyped the Constant's value attribute: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Avoid sparse tensor constants in models targeted at candle-onnx","Densify sparse values during export preprocessing","Audit Constant attribute types (must be Tensor) in the model lint pipeline"],"tags":["onnx","constant","attribute-type"],"backgroundTag":"unsupported-onnx-attribute","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}