Handle aten.var - variance of elements along axes.
(P: MLXProgramBuilder, n: Node)
| 3288 | |
| 3289 | @REGISTRY.register(target=[torch.ops.aten.var.correction, torch.ops.aten.var.dim]) |
| 3290 | def _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]) |
nothing calls this directly
no test coverage detected