Skip to content

Cortex-M Backend: Add tiny model tests for nn.Modules, nn.functional,…#18297

Merged
psiddh merged 1 commit intomainfrom
cortexm_ops
Mar 19, 2026
Merged

Cortex-M Backend: Add tiny model tests for nn.Modules, nn.functional,…#18297
psiddh merged 1 commit intomainfrom
cortexm_ops

Conversation

@psiddh
Copy link
Contributor

@psiddh psiddh commented Mar 18, 2026

… and torch patterns

Add 21 new test cases across 3 files that exercise the Cortex-M quantizer and pass manager on small composite models. These mirror the Arm backend's test_nn_modules/test_nn_functional/test_torch_functions pattern but target the Cortex-M pipeline.

Tests cover: ConvBnReLU, LinearReLU, ConvTranspose2d, AdaptiveAvgPool2d, MaxPool2d, AvgPool2d, Softmax, Hardswish, Hardsigmoid, depthwise separable conv, inverted residual blocks (MobileNet-style), and multi-op functional compositions.

All tests use test_dialect() which runs quantize→export→to_edge→ run_passes→compare_outputs entirely on the host (no FVP needed).

@psiddh psiddh requested a review from rascani as a code owner March 18, 2026 17:14
Copilot AI review requested due to automatic review settings March 18, 2026 17:14
@pytorch-bot
Copy link

pytorch-bot bot commented Mar 18, 2026

🔗 Helpful Links

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

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

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

@meta-cla meta-cla 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 Mar 18, 2026
@github-actions
Copy link

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds new Cortex-M backend model-level test suites to exercise common composite patterns (torch op compositions, nn.Module building blocks, and torch.nn.functional usage) through the Cortex-M quantizer + pass pipeline.

Changes:

  • Add composite “torch function pattern” models (mul/add, transpose+linear, conv chains, depthwise/inverted residual, linear+softmax).
  • Add nn.Module-focused coverage (conv/bn/relu, pooling, conv-transpose, hardswish/sigmoid, softmax) with an explicit xfail.
  • Add nn.functional-pattern coverage (conv+activation+pooling, pad, linear+bn, hardtanh).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
backends/cortex_m/test/models/test_torch_functions.py New composite torch-op pattern tests for Cortex-M dialect pipeline
backends/cortex_m/test/models/test_nn_modules.py New nn.Module composite tests + one documented xfail
backends/cortex_m/test/models/test_nn_functional.py New functional-pattern composite tests for Cortex-M dialect pipeline

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 18, 2026 17:56
@psiddh psiddh requested review from digantdesai March 18, 2026 17:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Cortex‑M backend model-level test coverage for common torch composite patterns, nn.Module compositions, and torch.nn.functional usage by introducing three new pytest suites that run through the Cortex‑M quantizer and pass pipeline.

Changes:

  • Add composite “torch function” pattern tests (arithmetic fusion, transpose+linear, conv blocks, MobileNet-style blocks, softmax).
  • Add nn.Module composition tests (conv/bn/relu, pooling, activations, softmax, conv transpose, and an xfailed fusion case).
  • Add torch.nn.functional-oriented tests (pad, activations, pooling, linear+BN composition).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
backends/cortex_m/test/models/test_torch_functions.py New composite-pattern tests driven by CortexMTester.test_dialect
backends/cortex_m/test/models/test_nn_modules.py New nn.Module composition tests with an explicit xfail for unsupported fusion
backends/cortex_m/test/models/test_nn_functional.py New functional-style op composition tests (pad/activations/pooling/linear+BN)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

… and torch patterns

Add 21 new test cases across 3 files that exercise the Cortex-M
quantizer and pass manager on small composite models. These mirror
the Arm backend's test_nn_modules/test_nn_functional/test_torch_functions
pattern (PR #18225) but target the Cortex-M pipeline.

Tests cover: ConvBnReLU, LinearReLU, ConvTranspose2d, AdaptiveAvgPool2d,
MaxPool2d, AvgPool2d, Softmax, Hardswish, Hardsigmoid, depthwise
separable conv, inverted residual blocks (MobileNet-style), and
multi-op functional compositions.

All tests use test_dialect() which runs quantize→export→to_edge→
run_passes→compare_outputs entirely on the host (no FVP needed).

Co-authored-by: Claude <noreply@anthropic.com>
@psiddh psiddh requested a review from AdrianLundell March 18, 2026 23:08
@psiddh psiddh merged commit 7a2e230 into main Mar 19, 2026
139 of 142 checks passed
@psiddh psiddh deleted the cortexm_ops branch March 19, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants