-
Notifications
You must be signed in to change notification settings - Fork 365
chore: dynamic shape support for clamp/min/max/floor_div/logical_and #2977
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
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
|
@@ -8,11 +8,8 @@ | |
|
||
from ..testing_utilities import lower_graph_testing | ||
|
||
# This testcase assumes that torch.ops.aten.clamp.default converter doesn't support | ||
# dynamic shapes. One should remove this testcase when the support is added. | ||
# This testcase tests if the graph is partitioned correctly into a TRT segment | ||
# and a Pytorch segment when the torch.ops.aten.clamp.default converter gets disabled | ||
# due to lack of dynamic shape support. | ||
# This testcase assumes that torch.ops.aten.clamp.default supports dynamic shapes. | ||
keehyuna marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# This testcase tests if the graph is partitioned correctly into a TRT segment only. | ||
|
||
|
||
class TestDynamicPartitioning(TestCase): | ||
|
@@ -53,51 +50,6 @@ def forward(self, x): | |
1, | ||
f"Number of TRT segments should be 1 but got {trt_segments}", | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test case with assume_dynamic_shape_support=True flag was removed. TestDynamicPartitioning test checks if there is only trt segment in module. |
||
self.assertEqual( | ||
pyt_segments, | ||
1, | ||
f"Number of PyTorch segments should be 1 but got {pyt_segments}", | ||
) | ||
|
||
def test_assume_dynamic_shape_support_converters(self): | ||
class Clamp(torch.nn.Module): | ||
def __init__(self, *args, **kwargs) -> None: | ||
super().__init__(*args, **kwargs) | ||
self.relu = torch.nn.ReLU() | ||
|
||
def forward(self, x): | ||
x = self.relu(x) | ||
return torch.ops.aten.clamp.default(x, min=2.5, max=6.5) | ||
|
||
model = Clamp().eval().cuda() | ||
trt_model = torch_tensorrt.compile( | ||
model, | ||
inputs=[ | ||
torch_tensorrt.Input( | ||
min_shape=(1, 3, 8, 8), | ||
opt_shape=(4, 3, 8, 8), | ||
max_shape=(8, 3, 8, 8), | ||
dtype=torch.float32, | ||
name="x", | ||
) | ||
], | ||
dryrun=True, | ||
assume_dynamic_shape_support=True, | ||
min_block_size=1, | ||
) | ||
|
||
trt_segments, pyt_segments = 0, 0 | ||
for submod in list(trt_model.named_children()): | ||
if "_run_on_acc" in submod[0]: | ||
trt_segments += 1 | ||
elif "_run_on_gpu" in submod[0]: | ||
pyt_segments += 1 | ||
|
||
self.assertEqual( | ||
trt_segments, | ||
1, | ||
f"Number of TRT segments should be 2 but got {trt_segments}", | ||
) | ||
self.assertEqual( | ||
pyt_segments, | ||
0, | ||
|
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.
Uh oh!
There was an error while loading. Please reload this page.