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

Function _embedding_handler

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

Source from the content-addressed store, hash-verified

1074
1075@REGISTRY.register(target=[torch.ops.aten.embedding.default])
1076def _embedding_handler(P: MLXProgramBuilder, n: Node) -> Slot:
1077 args = P.args(n)
1078 require_args(args, 2, 3, "aten.embedding")
1079 # "padding_idx", "scale_grad_by_freq", "sparse" are training only args
1080 # and ignored
1081 require_kwargs(
1082 P.kwargs(n), {"padding_idx", "scale_grad_by_freq", "sparse"}, "aten.embedding"
1083 )
1084 w, x = args[0], args[1]
1085 # padding_idx (args[2] if present) is ignored - only affects gradients
1086 out = P.make_or_get_slot(n)
1087 P.emit(
1088 TakeNode(
1089 x=P.slot_to_tid(w),
1090 index=IntOrVidOrTid.from_tid(P.slot_to_tid(x)),
1091 out=P.slot_to_tid(out),
1092 axis=0,
1093 )
1094 )
1095 return out
1096
1097
1098@REGISTRY.register(target=[torch.ops.aten.add.Tensor, torch.ops.aten.add.Scalar])

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected