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

Function register_node_visitor

backends/arm/operators/node_visitor.py:206–221  ·  view source on GitHub ↗

Register a concrete ``NodeVisitor`` class for its TOSA specs.

(visitor)

Source from the content-addressed store, hash-verified

204
205
206def register_node_visitor(visitor):
207 """Register a concrete ``NodeVisitor`` class for its TOSA specs."""
208 for tosa_spec in visitor.tosa_specs:
209 # Try to get the tuple to make sure it doesn't exist
210 visitor_tuple = (visitor.target, visitor)
211 try:
212 tuples = _node_visitor_tuples.get(tosa_spec)
213 except KeyError:
214 tuples = []
215
216 if visitor_tuple in tuples:
217 raise RuntimeError(
218 f"Visitor for target {visitor.target} already registered for TOSA spec {tosa_spec}"
219 )
220 _node_visitor_tuples.add(tosa_spec, visitor_tuple)
221 return visitor
222
223
224def get_node_visitors(*args) -> Dict[str, NodeVisitor]:

Callers 1

binary_operator_factoryFunction · 0.90

Calls 2

getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected