LeshengJin commented on code in PR #15184:
URL: https://github.com/apache/tvm/pull/15184#discussion_r1248309101


##########
python/tvm/relax/transform/legalize_ops/manipulate.py:
##########
@@ -163,3 +163,30 @@ def _scatter_elements(bb: BlockBuilder, call: Call) -> 
Expr:
         call.attrs.axis,
         call.attrs.reduction,
     )
+
+
+@register_legalize("relax.layout_transform")
+def _layout_transform(bb: BlockBuilder, call: Call) -> Expr:
+    index_map: tvm.tir.IndexMap = call.attrs.index_map
+    pad_value = call.attrs.pad_value.value
+
+    def te_layout_transform(data):
+        inverse, padding_predicate = 
index_map.non_surjective_inverse(data.shape)
+        output_shape = index_map.map_shape(data.shape)
+        return te.compute(
+            output_shape,
+            lambda *idx: tvm.te.if_then_else(

Review Comment:
   Yes, that's better. Added an if-else statement to check if the predicated is 
needed.



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