masahi commented on a change in pull request #9795:
URL: https://github.com/apache/tvm/pull/9795#discussion_r774143427



##########
File path: python/tvm/relay/frontend/pytorch.py
##########
@@ -1735,14 +1735,19 @@ def pad(inputs, input_types):
             paddings = [paddings[i : i + 2] for i in range(0, len(paddings), 
2)]
 
             const_paddings = []
+            non_zero_found = False
             for pad in paddings:
                 const_paddings.append([])
                 for p in pad:
                     if not isinstance(p, int):
                         p = int(_infer_value(p, {}).numpy())
                     const_paddings[-1].append(p)
+                    if p != 0:
+                        non_zero_found = True
 
-            if mode == "constant":
+            if not non_zero_found:
+                return data

Review comment:
       This is a minor optimization but it non-trivially helped performance on 
the DETR model. @comaniac 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to