Skip to content

Commit 8536538

Browse files
Change tuple() to () for slightly improved performance in trt_compiler.py (#8749)
### Description See also #8747 and #8748 ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Benedikt Johannes <benedikt.johannes.hofer@gmail.com> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
1 parent 7d3674e commit 8536538

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

monai/networks/trt_compiler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,10 @@ def parse_groups(
261261
Tuple of Union[torch.Tensor, List[torch.Tensor]], according to the grouping in output_lists
262262
263263
"""
264-
groups: tuple[torch.Tensor | list[torch.Tensor], ...] = tuple()
264+
groups: tuple[torch.Tensor | list[torch.Tensor], ...] = ()
265265
cur = 0
266-
for l in range(len(output_lists)):
267-
gl = output_lists[l]
266+
for idx in range(len(output_lists)):
267+
gl = output_lists[idx]
268268
assert len(gl) == 0 or len(gl) == 1
269269
if len(gl) == 0 or gl[0] == 0:
270270
groups = (*groups, ret[cur])
@@ -273,9 +273,9 @@ def parse_groups(
273273
groups = (*groups, ret[cur : cur + gl[0]])
274274
cur = cur + gl[0]
275275
elif gl[0] == -1:
276-
rev_groups: tuple[torch.Tensor | list[torch.Tensor], ...] = tuple()
276+
rev_groups: tuple[torch.Tensor | list[torch.Tensor], ...] = ()
277277
rcur = len(ret)
278-
for rl in range(len(output_lists) - 1, l, -1):
278+
for rl in range(len(output_lists) - 1, idx, -1):
279279
rgl = output_lists[rl]
280280
assert len(rgl) == 0 or len(rgl) == 1
281281
if len(rgl) == 0 or rgl[0] == 0:

0 commit comments

Comments
 (0)