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

Function _slice_handler

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

Source from the content-addressed store, hash-verified

1270 target=[torch.ops.aten.slice.Tensor, torch.ops.aten.slice_copy.Tensor]
1271)
1272def _slice_handler(P: MLXProgramBuilder, n: Node) -> Slot:
1273 args = P.args(n)
1274 require_args(args, 4, 5, "aten.slice")
1275 require_kwargs(P.kwargs(n), set(), "aten.slice")
1276 x, dim, start, stop = args[0], args[1], args[2], args[3]
1277 step = args[4] if len(args) > 4 else 1
1278 if start is None:
1279 start = 0
1280 require_static_int(step, "step", "aten.slice")
1281 assert step >= 1, f"aten.slice: step must be >= 1, got {step}"
1282 out = P.make_or_get_slot(n)
1283 P.emit(
1284 SliceNode(
1285 x=P.slot_to_tid(x),
1286 out=P.slot_to_tid(out),
1287 axis=P.to_int_or_vid(dim),
1288 start=P.to_int_or_vid(start),
1289 stop=P.to_int_or_vid(stop),
1290 step=step,
1291 )
1292 )
1293 return out
1294
1295
1296@REGISTRY.register(target=[torch.ops.aten.narrow.default])

Callers

nothing calls this directly

Calls 9

require_argsFunction · 0.85
require_kwargsFunction · 0.85
require_static_intFunction · 0.85
argsMethod · 0.80
kwargsMethod · 0.80
emitMethod · 0.80
slot_to_tidMethod · 0.80
to_int_or_vidMethod · 0.80
make_or_get_slotMethod · 0.45

Tested by

no test coverage detected