quic-sanirudh commented on code in PR #16173:
URL: https://github.com/apache/tvm/pull/16173#discussion_r1413373649


##########
python/tvm/relax/transform/optimize_layout_transform.py:
##########
@@ -63,27 +63,24 @@ def transform_function(self, func: Expr, mod: IRModule, 
ctx: PassContext) -> IRM
 
         self.mod = mod
         updated_func = func
-        for _, func in mod.functions_items():
-            # Skip non-relax functions
-            if not isinstance(func, Function):
-                continue
-            # Skip primitive functions
-            if "Primitive" in func.attrs.keys() and func.attrs["Primitive"] != 
0:
-                continue
 
-            def rewriter(expr, matches):
-                arg1 = matches[self.pattern]
-                if self.pattern_2 not in matches.keys():
+        # Skip primitive functions
+        if "Primitive" in func.attrs.keys() and func.attrs["Primitive"] != 0:
+            return updated_func
+
+        def rewriter(expr, matches):
+            arg1 = matches[self.pattern]
+            if self.pattern_2 not in matches.keys():
+                arg2 = matches[self.input]
+            else:
+                arg2 = matches[self.gv_]
+                if "remove_pad" == self.mod[arg2].attrs["operator_name"]:
                     arg2 = matches[self.input]
-                else:
-                    arg2 = matches[self.gv_]
-                    if "remove_pad" == self.mod[arg2].attrs["operator_name"]:
-                        arg2 = matches[self.input]
-                if hasattr(arg1.struct_info, "shape") and 
hasattr(arg2.struct_info, "shape"):
-                    if structural_equal(arg1.struct_info.shape, 
arg2.struct_info.shape):
-                        return arg2
-                return expr
+            if hasattr(arg1.struct_info, "shape") and 
hasattr(arg2.struct_info, "shape"):
+                if structural_equal(arg1.struct_info.shape, 
arg2.struct_info.shape):
+                    return arg2
+            return expr
 
-            updated_func = rewrite_call(self.pattern, rewriter, func)

Review Comment:
   Thanks for the review, don't know how I missed that.



-- 
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