Repository navigation
Decompose aten.var_mean.correction in to_edge - #23681
usmanmateen wants to merge 1 commit into
Conversation
torch.var_mean and torch.std_mean export to aten.var_mean.correction, which is not a core ATen op and is not in the core decomposition table, so to_edge rejected it. Its only registered decomposition is the torch._refs one, which produces prims ops. Decompose it to aten.var.correction and aten.mean.dim instead. Fixes pytorch#23680
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23681
Note: Links to docs will display an error until the docs builds have been completed.
|
|
Hi @usmanmateen! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
|
|
@pytorchbot label "release notes: exir" |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary
Fixes #23680.
torch.var_meanandtorch.std_meanexport toaten.var_mean.correction. It isn't a core ATen op and isn't incore_aten_decompositions(), soto_edgerejected it withSpecViolationErroron the portable and XNNPACK paths. Its only registered decomposition is thetorch._refsone, which produces prims ops. That's why this adds a small decomposition to_default_decomposition_tableinstead of listing the op inadditional_decomp_ops(that givesMissing out variants: {'prims::var', 'prims::sum', 'prims::div'}). The decomposition goes toaten.var.correctionandaten.mean.dim, both core ATen ops with portable kernels.Test plan
test_to_edge_decomposes_var_mean_and_std_meaninexir/program/test/test_program.pyexports a module that calls both ops, runs it through the portable pybindings, and compares with eager. It fails with theSpecViolationErrorbefore this change and passes after.I also lowered and ran these cases with
to_edgeand withto_edge_transform_and_lower(..., partitioner=[XnnpackPartitioner()]), comparing outputs with eager (atol=1e-5):torch.var_mean(x, dim=1, correction=0)SpecViolationErrortorch.var_mean(x)(dim=None)SpecViolationErrortorch.var_mean(x, dim=(0, 2), keepdim=True)SpecViolationErrortorch.var_mean(x, dim=-1, correction=2)SpecViolationErrortorch.std_mean(x, dim=1, unbiased=False)SpecViolationErrorTested against executorch 1.5.1 and torch 2.14.1+cpu on Linux x86_64 (WSL2);
_default_decomposition_tableis the same on main. A set of 55 other small modules (activations, reductions, norms, convolutions, pooling, RNNs, attention, and six torchvision models) lowers and matches eager on both paths before and after.ufmt(black 24.4.2, usort 1.0.8.post1) andflake8pass on the changed files.This PR was authored with AI assistance (Claude Code).
cc @nil-is-all