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

Function _linear_handler

backends/mlx/ops.py:790–816  ·  view source on GitHub ↗
(P: MLXProgramBuilder, n: Node)

Source from the content-addressed store, hash-verified

788
789@REGISTRY.register(target=[torch.ops.aten.linear.default])
790def _linear_handler(P: MLXProgramBuilder, n: Node) -> Slot:
791 args = P.args(n)
792 require_args(args, 2, 3, "aten.linear")
793 require_kwargs(P.kwargs(n), set(), "aten.linear")
794 x, w = args[0], args[1]
795 b = args[2] if len(args) > 2 else None
796 out = P.make_or_get_slot(n)
797
798 # Transpose weight: linear(x, w) = x @ w.T
799 _, w_t = P.make_tmp_slot()
800 P.emit(
801 TransposeNode(
802 x=P.slot_to_tid(w),
803 out=P.slot_to_tid(w_t),
804 perm=[1, 0],
805 )
806 )
807
808 P.emit(
809 AddmmNode(
810 mat1=P.slot_to_tid(x),
811 mat2=P.slot_to_tid(w_t),
812 out=P.slot_to_tid(out),
813 bias=P.slot_to_tid(b) if b else None,
814 )
815 )
816 return out
817
818
819@REGISTRY.register(target=[torch.ops.aten.addmm.default])

Callers

nothing calls this directly

Calls 8

require_argsFunction · 0.85
require_kwargsFunction · 0.85
argsMethod · 0.80
kwargsMethod · 0.80
emitMethod · 0.80
slot_to_tidMethod · 0.80
make_or_get_slotMethod · 0.45
make_tmp_slotMethod · 0.45

Tested by

no test coverage detected