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

Function _arange_start_step_handler

backends/mlx/ops.py:2120–2153  ·  view source on GitHub ↗

Handle arange with start, end, and step arguments. Supports both static (literal int) and dynamic (Slot from item()) start/stop/step.

(P: MLXProgramBuilder, n: Node)

Source from the content-addressed store, hash-verified

2118
2119@REGISTRY.register(target=[torch.ops.aten.arange.start_step])
2120def _arange_start_step_handler(P: MLXProgramBuilder, n: Node) -> Slot:
2121 """Handle arange with start, end, and step arguments.
2122
2123 Supports both static (literal int) and dynamic (Slot from item()) start/stop/step.
2124 """
2125 args = P.args(n)
2126 kwargs = P.kwargs(n)
2127 require_args(args, 2, 3, "aten.arange.start_step")
2128 require_kwargs(
2129 kwargs, {"dtype", "layout", "device", "pin_memory"}, "aten.arange.start_step"
2130 )
2131 require_contiguous_format(
2132 layout=kwargs.get("layout"),
2133 op_name="aten.arange.start_step",
2134 )
2135 start = args[0]
2136 stop = args[1]
2137 step = args[2] if len(args) > 2 else 1
2138
2139 # arange defaults to int64 when dtype is not specified (like torch.arange)
2140 dtype = kwargs.get("dtype", torch.int64)
2141 scalar_type_val = torch_dtype_to_scalar_type(dtype)
2142
2143 out = P.make_or_get_slot(n)
2144 P.emit(
2145 ARangeNode(
2146 out=P.slot_to_tid(out),
2147 start=P.to_int_or_vid(start),
2148 stop=P.to_int_or_vid(stop),
2149 step=P.to_int_or_vid(step),
2150 scalar_type=scalar_type_val,
2151 )
2152 )
2153 return out
2154
2155
2156@REGISTRY.register(target=[torch.ops.aten.rms_norm.default])

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected