|
17 | 17 | from executorch.exir.lowered_backend_module import get_lowered_submodules
|
18 | 18 | from executorch.exir.pass_base import ExportPass
|
19 | 19 | from executorch.exir.program._program import (
|
| 20 | + EdgeCompileConfig, |
20 | 21 | EdgeProgramManager,
|
21 | 22 | ExecutorchProgramManager,
|
22 | 23 | to_edge,
|
|
26 | 27 | from executorch.extension.pybindings.portable_lib import (
|
27 | 28 | _load_for_executorch_from_buffer,
|
28 | 29 | )
|
29 |
| -from torch.export import export, ExportedProgram |
| 30 | +from torch.export import Dim, export, ExportedProgram |
30 | 31 |
|
31 | 32 | from torch.library import impl, Library
|
32 | 33 |
|
@@ -225,6 +226,38 @@ def test_edge_manager_transform(self):
|
225 | 226 | original_res, # x * y + x
|
226 | 227 | )
|
227 | 228 |
|
| 229 | + def test_issue_3659(self): |
| 230 | + |
| 231 | + class Mul(torch.nn.Module): |
| 232 | + def __init__(self): |
| 233 | + super(Mul, self).__init__() |
| 234 | + |
| 235 | + def forward(self, x: torch.Tensor, y: torch.Tensor): |
| 236 | + return torch.matmul(x, y) |
| 237 | + |
| 238 | + def get_eager_model(self) -> torch.nn.Module: |
| 239 | + return self |
| 240 | + |
| 241 | + def get_example_inputs(self): |
| 242 | + return (torch.randn(1, 3, 10), torch.randn(1, 10, 3)) |
| 243 | + |
| 244 | + def get_dynamic_shapes(self): |
| 245 | + dim1_x = Dim("Dot_dim1_x", min=2, max=100) |
| 246 | + dim2_x = Dim("Dot_dim2_x", min=2, max=100) |
| 247 | + return {"x": {1: dim1_x, 2: dim2_x}, "y": {1: dim2_x, 2: dim1_x}} |
| 248 | + |
| 249 | + model = Mul() |
| 250 | + ep = torch.export.export( |
| 251 | + model, model.get_example_inputs(), dynamic_shapes=model.get_dynamic_shapes() |
| 252 | + ) |
| 253 | + |
| 254 | + to_edge( |
| 255 | + ep, |
| 256 | + compile_config=EdgeCompileConfig( |
| 257 | + _check_ir_validity=True, |
| 258 | + ), |
| 259 | + ) |
| 260 | + |
228 | 261 | def test_transform_dict_api(self):
|
229 | 262 | edge_manager = to_edge(get_exported_programs(), get_config_methods())
|
230 | 263 |
|
|
0 commit comments