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

Function _var_handler

backends/mlx/ops.py:3290–3313  ·  view source on GitHub ↗

Handle aten.var - variance of elements along axes.

(P: MLXProgramBuilder, n: Node)

Source from the content-addressed store, hash-verified

3288
3289@REGISTRY.register(target=[torch.ops.aten.var.correction, torch.ops.aten.var.dim])
3290def _var_handler(P: MLXProgramBuilder, n: Node) -> Slot:
3291 """Handle aten.var - variance of elements along axes."""
3292 args = P.args(n)
3293 require_args(args, 1, 2, "aten.var")
3294 require_kwargs(P.kwargs(n), {"correction", "keepdim"}, "aten.var")
3295 x = args[0]
3296 axes, _ = normalize_reduction_dim(args)
3297
3298 # Get correction/ddof and keepdim from kwargs
3299 correction = n.kwargs.get("correction", None)
3300 keepdim = n.kwargs.get("keepdim", False)
3301 ddof = int(correction) if correction is not None else 1
3302
3303 out = P.make_or_get_slot(n)
3304 P.emit(
3305 VarNode(
3306 x=P.slot_to_tid(x),
3307 out=P.slot_to_tid(out),
3308 axes=axes,
3309 keepdims=keepdim,
3310 ddof=ddof,
3311 )
3312 )
3313 return out
3314
3315
3316@REGISTRY.register(target=[torch.ops.aten.std.correction])

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected