Repository navigation
Do not delegate CoreML instance_norm with a rank 5 input - #23688
hemanth1999k wants to merge 1 commit into
Conversation
Core ML's instance_norm only accepts rank 3 and 4 inputs. InstanceNorm3d lowered fine, then failed to load: parameter x[0] has invalid rank 5 The partitioner now overrides support for instance_norm over a rank 5 input, so ops_to_not_decompose no longer keeps it whole. It decomposes into ops Core ML runs, and the model stays delegated and matches eager, including affine with batch size > 1. InstanceNorm1d/2d are unchanged. Fixes pytorch#11702
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23688
Note: Links to docs will display an error until the docs builds have been completed.
|
|
|
|
Hi @hemanth1999k! 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: apple" |
|
/easycla |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary
Core ML's
instance_normonly accepts rank 3 and rank 4 inputs.InstanceNorm3dcurrently lowers to Core ML without complaint, then fails when the program loads:CoreMLPartitionernow overrides support forinstance_normwhen its input is rank 5.ops_to_not_decomposetherefore stops keeping it whole, it decomposes into ops Core ML runs, and the model stays delegated and matches eager.InstanceNorm1dandInstanceNorm2dare unchanged.Fixes #11702
Test plan
Added
test_instance_norm_3d_is_decomposedtobackends/apple/coreml/test/test_coreml_partitioner.py. It coversInstanceNorm3don (1, 3, 4, 4, 4) and an affineInstanceNorm3dwith batch size 2 on (2, 3, 4, 5, 6). For each it checks thatinstance_normis not inops_to_not_decompose, lowers withto_edge_transform_and_lower, runs the program throughexecutorch.runtime.Runtime, and compares with eager (atol/rtol 1e-2 because Core ML computes in fp16). It also checks thatInstanceNorm2dis still kept whole.13/13 pass with the change; on main only the new test fails. Run on macOS 26.2, executorch 1.5.1 / main, torch 2.14.0, coremltools 9.0.
ufmtandflake8are clean.cc @nil-is-all