(P: MLXProgramBuilder, n: Node)
| 404 | """Create a handler for a simple unary op: x → node_cls(x, out).""" |
| 405 | |
| 406 | def handler(P: MLXProgramBuilder, n: Node) -> Slot: |
| 407 | args = P.args(n) |
| 408 | require_args(args, 1, 1, op_name) |
| 409 | require_kwargs(P.kwargs(n), set(), op_name) |
| 410 | x = args[0] |
| 411 | out = P.make_or_get_slot(n) |
| 412 | P.emit(node_cls(x=P.slot_to_tid(x), out=P.slot_to_tid(out))) |
| 413 | return out |
| 414 | |
| 415 | handler.__name__ = f"_{op_name.replace('.', '_')}_handler" |
| 416 | handler.__doc__ = f"Handle {op_name} (table-driven unary op)." |
no test coverage detected