Repository navigation
Raise inoperative error guards in ExportSession, XNNPACK node_visitor, and Samsung conv1d #22373
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
Open
AxelNoun
wants to merge
6
commits into
pytorch:main
Choose a base branch
from
AxelNoun:fix/unraised-error-checks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+56
−3
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
95b4eff
Raise inoperative error guards in ExportSession, XNNPACK node_visitor…
AxelNoun 2b911ba
Merge branch 'main' into fix/unraised-error-checks
AxelNoun 12c3858
Merge branch 'main' into fix/unraised-error-checks
AxelNoun 89cf698
Merge remote-tracking branch 'origin/main' into fix/unraised-error-ch…
AxelNoun aabf5c3
Merge branch 'main' into fix/unraised-error-checks
AxelNoun 21b2f61
Merge remote-tracking branch 'origin/main' into fix/unraised-error-ch…
AxelNoun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # All rights reserved. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
|
|
||
| import unittest | ||
|
|
||
| import torch | ||
| from executorch.export import ExportRecipe, ExportSession | ||
| from executorch.export.types import StageType | ||
|
|
||
|
|
||
| class Tiny(torch.nn.Module): | ||
| def forward(self, x: torch.Tensor) -> torch.Tensor: | ||
| return x + 1 | ||
|
|
||
|
|
||
| class TestPrintDelegationInfoGuards(unittest.TestCase): | ||
| def test_print_delegation_info_requires_a_lowering_stage(self) -> None: | ||
| session = ExportSession( | ||
| model=Tiny(), | ||
| example_inputs=[(torch.randn(2, 3),)], | ||
| export_recipe=ExportRecipe( | ||
| name="test", | ||
| pipeline_stages=[StageType.TORCH_EXPORT], | ||
| ), | ||
| ) | ||
| with self.assertRaises(RuntimeError) as cm: | ||
| session.print_delegation_info() | ||
| self.assertIn("at least one of the lowering stages", str(cm.exception)) | ||
|
|
||
| def test_print_delegation_info_requires_lowering_artifact(self) -> None: | ||
| session = ExportSession( | ||
| model=Tiny(), | ||
| example_inputs=[(torch.randn(2, 3),)], | ||
| export_recipe=ExportRecipe( | ||
| name="test", | ||
| pipeline_stages=[ | ||
| StageType.TORCH_EXPORT, | ||
| StageType.TO_EDGE_TRANSFORM_AND_LOWER, | ||
| ], | ||
| ), | ||
| ) | ||
| with self.assertRaises(RuntimeError) as cm: | ||
| session.print_delegation_info() | ||
| self.assertIn("run the lowering stage first", str(cm.exception)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shoudln't we use 'why()'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why()here isWhyNoPartition(exir/backend/utils.py), and every call to it in this backend sits inpartition/config/*.py, or in a pass that receives it as an argument: it logs a reason and the caller returnsFalse, so the node is left on CPU.define_tensorruns after partitioning, at serialization time, so there is nowhyin scope and nothing left to decline. The options here are to raise or to serialize a wrong axis silently. I used the helper this file already uses (four othercheck_or_raisecalls), andop_conv2d.pyperforms these same two axis checks one level up (lines 88 and 93), which is why thiselseshould be unreachable on the conv2d path.Your question did surface two things, though.
First,
check_or_raise(False, ...)is the only literal-Falsecall in the repo. Happy to give it a real condition, which also drops theelse:Second,
ConvolutionConfig.check_constraintsuseswhy()for the transpose per-channel axis (gemm_configs.py:406), but there is no equivalent gate for the depthwise one. A per-channel depthwise conv withaxis != 0is therefore partitioned and then raises atop_conv2d.py:93, instead of staying on CPU. The axis is read verbatim from the dequant node's 4th arg (quant_params.py:272), so a quantizer other thanXNNPACKQuantizercan produce it. Would you like thatwhy()gate added here, or kept out of this PR (which only makes dead guards fire) and done as a follow-up?