Skip to content

Arm backend: Update fuse_batchnorm_pass to create new placeholders #8411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Mar 4, 2025

Conversation

AdrianLundell
Copy link
Collaborator

@AdrianLundell AdrianLundell commented Feb 12, 2025

  • This allows to fuse bn+convs with multiple users of the same weights
  • Adds new util functions create/delete_const_placeholders to take care of updating the GraphSignature and state_dict/constants dict when handling constant placholders.
  • Adds and updates related tests

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218

- This allows to fuse bn+convs with multiple users of the same weights
- Adds new util functions create/delete_const_placeholders to take care of updating the GraphSignature and state_dict/constants dict when handling constant placholders.
- Adds and updates related tests

Change-Id: I8e550614d9741de840786d9dca9f30af9eb95a64
@AdrianLundell AdrianLundell added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk topic: not user facing labels Feb 12, 2025
Copy link

pytorch-bot bot commented Feb 12, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/8411

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 2 Pending

As of commit 9113109 with merge base efd1a06 (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 12, 2025
@AdrianLundell
Copy link
Collaborator Author

Non related lint error:

>>> Lint for backends/cadence/aot/export_example.py:

  Warning (UFMT) format
    Run `lintrunner -a` to apply this patch.

    You can run `lintrunner -a` to apply this patch.

     6   6 | 
     7   7 | # Example script for exporting simple models to flatbuffer
     8   8 | 
     8     |-#pyre-unsafe
         9 |+# pyre-unsafe
    10  10 | 
    11  11 | import logging
    12  12 | import tempfile

Non related build error (s):

RuntimeError: Command docker exec -t 521694becf2b4fff260051b64d1de66315df287c49d890f89dbc9441d1ea8e7e /exec failed with exit code 2
advanced_index_util.cpp:(.text._ZN5torch8executor16check_index_argsERKN10executorch7runtime7etensor6TensorENS2_8ArrayRefINS3_8optionalIS4_EEEERS4_+0x13d): undefined reference to `executorch::runtime::tensor_shape_to_c_string(executorch::runtime::Span<int const>)'
/usr/bin/ld: advanced_index_util.cpp:(.text._ZN5torch8executor16check_index_argsERKN10executorch7runtime7etensor6TensorENS2_8ArrayRefINS3_8optionalIS4_EEEERS4_+0x158): undefined reference to `executorch::runtime::tensor_shape_to_c_string(executorch::runtime::Span<int const>)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@AdrianLundell
Copy link
Collaborator Author

Non related unittest error:

Collecting tosa-tools@ git+https://review.mlplatform.org/tosa/reference_model@v0.80.1
  Cloning https://review.mlplatform.org/tosa/reference_model (to revision v0.80.1) to /tmp/pip-install-rh38ycq9/tosa-tools_d3857486a2c74e47b4036070304eed7f
  Running command git clone --filter=blob:none --quiet https://review.mlplatform.org/tosa/reference_model /tmp/pip-install-rh38ycq9/tosa-tools_d3857486a2c74e47b4036070304eed7f
  fatal: unable to access 'https://review.mlplatform.org/tosa/reference_model/': Failed to connect to review.mlplatform.org port 443 after 132947 ms: Connection timed out
  error: subprocess-exited-with-error

@digantdesai
Copy link
Contributor

Non related unittest error:

Collecting tosa-tools@ git+https://review.mlplatform.org/tosa/reference_model@v0.80.1
  Cloning https://review.mlplatform.org/tosa/reference_model (to revision v0.80.1) to /tmp/pip-install-rh38ycq9/tosa-tools_d3857486a2c74e47b4036070304eed7f
  Running command git clone --filter=blob:none --quiet https://review.mlplatform.org/tosa/reference_model /tmp/pip-install-rh38ycq9/tosa-tools_d3857486a2c74e47b4036070304eed7f
  fatal: unable to access 'https://review.mlplatform.org/tosa/reference_model/': Failed to connect to review.mlplatform.org port 443 after 132947 ms: Connection timed out
  error: subprocess-exited-with-error

cc @freddan80 do we have a github mirror plans for this?

Copy link
Contributor

@digantdesai digantdesai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and clean. Thanks! We should add these utils in the shared delegate dir, I can see wanting to use this for XNNPACK for example.

@freddan80
Copy link
Collaborator

freddan80 commented Feb 13, 2025

eview.mlplatform.org

This should be changed to point to gitlab servers. Let me check

@AdrianLundell
Copy link
Collaborator Author

Nice and clean. Thanks! We should add these utils in the shared delegate dir, I can see wanting to use this for XNNPACK for example.

Great I can move them! Which folder should I use for this?

@AdrianLundell
Copy link
Collaborator Author

@digantdesai Are you ok with the new changes?

@AdrianLundell
Copy link
Collaborator Author

Lint fail unrelated:

> Lint for backends/cadence/aot/fuse_ops.py:

  Warning (UFMT) format
    Run `lintrunner -a` to apply this patch.

    You can run `lintrunner -a` to apply this patch.

    17  17 | from typing import cast, Sequence
    18  18 | 
    19  19 | # Import these for the cadence function signatures.
    19     |-import executorch.backends.cadence.aot.ops_registrations # noqa: F401
        20 |+import executorch.backends.cadence.aot.ops_registrations  # noqa: F401
    21  21 | 
    22  22 | import torch
    23  23 | import torch.fx

macos unrelated

@digantdesai
Copy link
Contributor

Once you add the buck line, I can pull internally and run. Thanks for the updates.

@facebook-github-bot
Copy link
Contributor

@digantdesai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@digantdesai
Copy link
Contributor

digantdesai commented Feb 21, 2025

still failing.. let me try a fix, I will let you know if it works.

@digantdesai
Copy link
Contributor

digantdesai commented Feb 21, 2025

I can commandeer, or you can apply this patch,

diff --git a/executorch/backends/transforms/targets.bzl b/executorch/backends/transforms/targets.bzl
--- a/executorch/backends/transforms/targets.bzl
+++ b/executorch/backends/transforms/targets.bzl
@@ -149,6 +149,9 @@
     runtime.python_library(
         name = "utils",
         srcs = ["utils.py"],
+        visibility = [
+            "//executorch/backends/...",
+        ],
         deps = [
             "//caffe2:torch",
             "//executorch/exir:lib",

@AdrianLundell
Copy link
Collaborator Author

Thanks, patch applied

@facebook-github-bot
Copy link
Contributor

@digantdesai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@AdrianLundell
Copy link
Collaborator Author

@digantdesai It looks like there are still some meta-internal errors, is that correct?

@digantdesai
Copy link
Contributor

No this looks good. Merge it.

@AdrianLundell
Copy link
Collaborator Author

We cannot merge this, I assume it's due to the required Meta Internal-Only Changes Check - can you override this from your side?

@zingo zingo changed the title [ARM backend] Update fuse_batchnorm_pass to create new placeholders Arm backend: Update fuse_batchnorm_pass to create new placeholders Feb 26, 2025
@AdrianLundell
Copy link
Collaborator Author

@digantdesai We are still not able to merge this and it would be nice to get it in soon as we have two more patches based on this, can you take a look?

@facebook-github-bot
Copy link
Contributor

@digantdesai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@digantdesai digantdesai merged commit 2051a15 into pytorch:main Mar 4, 2025
121 of 124 checks passed
zonglinpeng pushed a commit that referenced this pull request Mar 6, 2025
…8411)

* [ARM backend] Update fuse_batchnorm_pass to create new placeholders

- This allows to fuse bn+convs with multiple users of the same weights
- Adds new util functions create/delete_const_placeholders to take care of updating the GraphSignature and state_dict/constants dict when handling constant placholders.
- Adds and updates related tests

Change-Id: I8e550614d9741de840786d9dca9f30af9eb95a64

* Move create/delete_constant_node utils to shared folder

Change-Id: I3a82f58f9796e421bd205f030f7d79d72a2f7ed9

* Add buck dependency

* Fix bazel build

---------

Co-authored-by: Digant Desai <digantdesai@meta.com>
@AdrianLundell AdrianLundell deleted the change-987432 branch March 19, 2025 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm topic: not user facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants