Skip to content

remove exir.capture from dynamic_shape_propogation test #3070

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

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 6 additions & 1 deletion exir/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# pyre-strict

import itertools
from typing import List, Optional, Tuple, Union
from typing import Any, List, Optional, Tuple, Union

import executorch.exir as exir

Expand All @@ -34,6 +34,11 @@ def forward(
def get_random_inputs(self) -> Tuple[torch.Tensor, torch.Tensor]:
return (torch.rand(4), torch.rand(5))

def get_dynamic_shape(self) -> Any: # pyre-ignore[3]
dim = torch.export.Dim("dim", max=10)
dim2 = torch.export.Dim("dim2", max=10)
return ({0: dim}, {0: dim2})


class ModelWithUnusedArg(nn.Module):
def __init__(self) -> None:
Expand Down
15 changes: 8 additions & 7 deletions exir/tests/test_dynamic_shape_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
from unittest import TestCase

from executorch import exir
from executorch.exir import to_edge
from executorch.exir.passes import DebugPass, HintBasedSymShapeEvalPass, SpecPropPass
from executorch.exir.tests.models import Repeat
from torch.export import export


class TestDynamicShapeProp(TestCase):
Expand All @@ -17,15 +19,14 @@ def test_repeat(self):
inputs = eager_model.get_random_inputs()
inputs = inputs[0], inputs[1]

prog = exir.capture(
eager_model,
inputs,
exir.CaptureConfig(enable_dynamic_shape=True),
).to_edge(exir.EdgeCompileConfig(_check_ir_validity=False))
prog = to_edge(
export(eager_model, inputs, dynamic_shapes=eager_model.get_dynamic_shape()),
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
)

new_prog = prog.transform(SpecPropPass(), HintBasedSymShapeEvalPass())
new_prog = prog.transform([SpecPropPass(), HintBasedSymShapeEvalPass()])

gm = new_prog.exported_program.graph_module
gm = new_prog.exported_program().graph_module

DebugPass(show_spec=True)(gm)
*_, return_node = gm.graph.nodes
Expand Down