Skip to content

Commit

Permalink
Only allow 4d or 5d inputs to TRT nn.pad (#8073)
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Morris authored May 19, 2021
1 parent 476f0ff commit e8045b1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/tvm/relay/op/contrib/tensorrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,11 +726,15 @@ def pad_annotate_fn(expr): # pylint: disable=unused-variable
if float(attrs.pad_value) != 0.0:
logger.info("nn.pad: pad value is %f but must be 0.0.", float(attrs.pad_value))
return False
if len(attrs.pad_width) not in [4, 5]:
logger.info("nn.pad: can only pad 4D or 5D inputs")
return False
if any([x != 0 for x in attrs.pad_width[0]]) or any([x != 0 for x in attrs.pad_width[1]]):
logger.info("nn.pad: can't pad batch or channel dimensions.")
return False
if len(attrs.pad_width) == 5 and any([x != 0 for x in attrs.pad_width[2]]):
logger.info("nn.pad: can only pad last two dimensions for 5D inputs.")
return False
return True


Expand Down

0 comments on commit e8045b1

Please sign in to comment.