You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/03/01 17:42:52 UTC

[GitHub] [tvm] comaniac commented on a change in pull request #7556: Remove pytest dependency in arm_compute_lib.py

comaniac commented on a change in pull request #7556:
URL: https://github.com/apache/tvm/pull/7556#discussion_r584919519



##########
File path: python/tvm/relay/op/contrib/arm_compute_lib.py
##########
@@ -111,20 +111,38 @@ def convert_conv(attrs, inputs, tinfos, desired_layouts):
 
         return convert_conv
 
-    with TempOpAttr(
-        "nn.conv2d", "FTVMConvertOpLayout", convert_layout_conv2d(tvm.relay.nn.conv2d)
-    ), TempOpAttr(
-        "qnn.conv2d", "FTVMConvertOpLayout", convert_layout_conv2d(tvm.relay.qnn.op.conv2d)
-    ):
-        seq = tvm.transform.Sequential(
-            [
-                transform.ConvertLayout(
-                    {"nn.conv2d": ["NHWC", "OHWI"], "qnn.conv2d": ["NHWC", "OHWI"]}
-                ),
-                transform.FoldConstant(),
-            ]
-        )
-        preprocessed_mod = seq(mod)
+    # Set tmp attributes
+    attr_key = "FTVMConvertOpLayout"
+
+    op_nn = relay.op.get("nn.conv2d")
+    older_attr_nn = op_nn.get_attr(attr_key)
+    op_nn.reset_attr(attr_key)
+    op_nn.set_attr(attr_key, convert_layout_conv2d(tvm.relay.nn.conv2d))
+
+    op_qnn = relay.op.get("qnn.conv2d")
+    older_attr_qnn = op_qnn.get_attr(attr_key)
+    op_qnn.reset_attr(attr_key)
+    op_qnn.set_attr(attr_key, convert_layout_conv2d(tvm.relay.qnn.op.conv2d))

Review comment:
       Better to use `with` context as `TempOpAttr` does to make sure the changes won't affect other processes. I think it's fine to just copy `TempOpAttr` here to be `ArmComputeLibOpAttrContext` or something like 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org