1515
1616
1717def register_tosa_dialect_op (op_schema , func ) -> Callable :
18+ """Register a TOSA dialect operator with the backend op library.
19+
20+ Args:
21+ op_schema (str): Operator schema without namespace or overload name.
22+ func (Callable): Fake implementation used for registration.
23+
24+ Returns:
25+ Callable: Backend dialect operator handle exposed via ``exir_ops`` and
26+ marked ``not_callable`` for runtime use.
27+
28+ """
1829 if tosa_lib .ns not in _BACKEND_OP_LIB :
1930 _BACKEND_OP_LIB .append (tosa_lib .ns )
2031
@@ -43,6 +54,7 @@ def register_tosa_dialect_op(op_schema, func) -> Callable:
4354 # the op doesn't need to be callable. This can be changed in the future if needed to support
4455 # execution of TOSA ops directly.
4556 def not_callable ():
57+ """Raise when the dialect op handle is invoked at runtime."""
4658 raise RuntimeError ("TOSA dialect op is not callable" )
4759
4860 op .__equvalent_callable__ = not_callable
@@ -51,11 +63,22 @@ def not_callable():
5163
5264
5365class TosaValueError (ValueError ):
66+ """Error type that annotates failures with the originating TOSA op."""
67+
5468 def __init__ (self , message = "A TOSA value error occurred" , * args , op = None ):
69+ """Initialise the error with optional operator metadata.
70+
71+ Args:
72+ message (str): Human-readable error message.
73+ *args: Additional arguments forwarded to ``ValueError``.
74+ op: Optional operator identifier included in the string output.
75+
76+ """
5577 super ().__init__ (message , * args )
5678 self .op = op
5779
5880 def __str__ (self ):
81+ """Return the base message, appending the operator when provided."""
5982 base_message = super ().__str__ ()
6083 if self .op is not None :
6184 return f"{ base_message } (TOSA op: { self .op } )"
0 commit comments