MCPcopy Create free account
hub / github.com/pytorch/executorch / _validate_graph_signature

Function _validate_graph_signature

backends/transforms/utils.py:224–249  ·  view source on GitHub ↗

Validates that the graph signature is up to date with the graph.

(exp_program: ExportedProgram)

Source from the content-addressed store, hash-verified

222
223
224def _validate_graph_signature(exp_program: ExportedProgram):
225 """
226 Validates that the graph signature is up to date with the graph.
227 """
228 placeholders = [n for n in exp_program.graph.nodes if n.op == "placeholder"]
229 if len(placeholders) != len(exp_program.graph_signature.input_specs):
230 raise RuntimeError(
231 f"Graph has {len(placeholders)} placeholder nodes but signature has "
232 f"{len(exp_program.graph_signature.input_specs)} input specs"
233 )
234 for node, input_spec in zip(placeholders, exp_program.graph_signature.input_specs):
235 if node.name != input_spec.arg.name:
236 raise RuntimeError(
237 f"Input node {node.name} does not match input spec {input_spec.arg.name}"
238 )
239 outputs = exp_program.graph.output_node().args[0]
240 if len(outputs) != len(exp_program.graph_signature.output_specs):
241 raise RuntimeError(
242 f"Graph has {len(outputs)} output nodes but signature has "
243 f"{len(exp_program.graph_signature.output_specs)} output specs"
244 )
245 for node, output_spec in zip(outputs, exp_program.graph_signature.output_specs):
246 if node.name != output_spec.arg.name:
247 raise RuntimeError(
248 f"Output node {node.name} does not match output spec {output_spec.arg.name}"
249 )
250
251
252def _spec_to_node(

Callers 1

create_mutable_bufferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected