Skip to content

[ez][release blocker fix] Insert linalg_vector_norm into decomp table used for Edge export #9938

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 1 commit into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions exir/program/test/test_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,17 +725,17 @@ def count_nodes(graph_module, target):
)

def test_edge_dialect_non_core_aten_ops(self):
class LinalgNorm(torch.nn.Module):
class LinalgRank(torch.nn.Module):
def __init__(self):
super().__init__()

def forward(self, x: torch.Tensor) -> torch.Tensor:
return torch.linalg.norm(x)
return torch.linalg.matrix_rank(x)

from torch._export.verifier import SpecViolationError

input = torch.arange(9, dtype=torch.float) - 4
ep = torch.export.export(LinalgNorm(), (input,), strict=True)
input = torch.ones((9, 9, 9), dtype=torch.float)
ep = torch.export.export(LinalgRank(), (input,), strict=True)

# aten::linalg_norm is not a core op, so it should error out
with self.assertRaises(SpecViolationError):
Expand All @@ -748,9 +748,7 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
ep,
compile_config=EdgeCompileConfig(
_check_ir_validity=True,
_core_aten_ops_exception_list=[
torch.ops.aten.linalg_vector_norm.default
],
_core_aten_ops_exception_list=[torch.ops.aten._linalg_svd.default],
),
)
except SpecViolationError:
Expand Down
12 changes: 11 additions & 1 deletion exir/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,18 @@ def _default_decomposition_table(
]
# pyre-fixme[7]: Expected `Dict[OpOverload, typing.Callable[..., executorch.e...
return get_decompositions(decomp_opset)

decomps = default_decompositions()
# Add edge specific decompositions
additional_decomp_ops = [
# TODO: Eventually this op should be added to the core decompo table, and will not
# need to be added here.
torch.ops.aten.linalg_vector_norm.default,
]
additional_decomps = get_decompositions(additional_decomp_ops)
decomps.update(additional_decomps)
# pyre-fixme[7]: Expected `Dict[OpOverload, typing.Callable[..., executorch.exir....
return default_decompositions()
return decomps


def dynamo_trace(
Expand Down
Loading