{"record":{"id":"d7069c14f9430db7","repo":"huggingface/candle","slug":"cannot-find-input-name-for-op","errorCode":null,"errorMessage":"cannot find {input_name} for op '{}'","messagePattern":"cannot find (.+?) for op '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":326,"sourceCode":"                        // We do not check equality constraints for the DimParam dimensions for now.\n                        Some(onnx::tensor_shape_proto::dimension::Value::DimParam(_)) | None => (),\n                    }\n                }\n            }\n        };\n        if dt != tensor.dtype() {\n            bail!(\n                \"unexpected dtype for {}, got {:?}, expected {dt:?}\",\n                input.name,\n                tensor.dtype()\n            )\n        }\n    }\n    // The nodes are topologically sorted so we can just process them in order.\n    for node in graph.node.iter() {\n        let get = |input_name: &str| match values.get(input_name) {\n            Some(value) => Ok(value),\n            None => bail!(\"cannot find {input_name} for op '{}'\", node.name),\n        };\n        let get_opt = |i: usize| {\n            node.input\n                .get(i)\n                .filter(|s: &&String| !s.is_empty())\n                .map(|s| get(s))\n        };\n\n        // TODO: Validate node.input for each operator.\n        match node.op_type.as_str() {\n            \"Add\" => {\n                let input0 = get(&node.input[0])?;\n                let input1 = get(&node.input[1])?;\n                let output = input0.broadcast_add(input1)?;\n                values.insert(node.output[0].clone(), output);\n            }\n            \"Sub\" => {\n                let input0 = get(&node.input[0])?;","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L308-L344","documentation":"During node execution, simple_eval_ looks up each node input name in the accumulated values map (initializers + prior outputs + user inputs). If a name is missing when the op needs it, this error is thrown with the missing name and the op's name. It usually means the graph is malformed or an input was not produced earlier.","triggerScenarios":"simple_eval on a model whose node references an unknown name (graph not topologically valid / corrupted), or where a user input name matches what a node consumes but was omitted from the inputs map (the generic input check only iterates graph.input).","commonSituations":"Subgraph/outer-scope references the evaluator doesn't support; models edited to remove a producer node; optional inputs referenced with empty names being consumed via get instead of get_opt; stripped initializers (external data not loaded).","solutions":["Validate the model with onnx.checker / onnx.shape_inference to confirm every node input is produced by an initializer, graph input, or earlier node output.","Ensure all graph inputs listed in model.graph.input are supplied in the inputs HashMap.","Check external-data initializers were loaded (weights file next to the .onnx, correct location field).","If the name comes from an optional input slot, this is an evaluator limitation — pin or upgrade candle-onnx to a version handling that op pattern."],"exampleFix":"// before\nlet mut inputs = HashMap::new();\ninputs.insert(\"input\".to_string(), x); // mask referenced by Add node missing\n// after\ninputs.insert(\"mask\".to_string(), mask); // supply every producer name nodes consume","handlingStrategy":"validation","validationCode":"fn unreferenced_inputs(model: &onnx::ModelProto, inputs: &HashMap<String, Value>) -> Vec<String> {\n    // ensure every name consumed by nodes is either supplied, an initializer, or an earlier output\n    let produced: std::collections::HashSet<String> = model.graph.as_ref().map_or_default(|g| {\n        g.initializer.iter().map(|t| t.name.clone())\n            .chain(g.input.iter().map(|i| i.name.clone()))\n            .chain(g.node.iter().flat_map(|n| n.output.iter().cloned()))\n            .collect()\n    });\n    let mut missing = vec![];\n    if let Some(g) = &model.graph {\n        for n in &g.node {\n            for inp in &n.input {\n                if !inp.is_empty() && !produced.contains(inp) && !inputs.contains_key(inp) {\n                    missing.push(inp.clone());\n                }\n            }\n        }\n    }\n    missing\n}","typeGuard":null,"tryCatchPattern":"match simple_eval(&model, inputs) {\n    Err(e) if e.to_string().starts_with(\"cannot find\") => {\n        anyhow::bail!(\"graph references a value never produced — check model integrity / external weight files / supplied inputs\")\n    }\n    r => r?,\n}","preventionTips":["Run onnx.checker + shape inference to verify graph validity","Ship external-data weight files alongside the .onnx","Supply every name in model.graph.input","Prefer unedited exporter output over manual model surgery","Upgrade candle-onnx if the pattern involves optional/subgraph inputs"],"tags":["onnx","eval","missing-value","graph"],"backgroundTag":"missing-required-input","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}