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 12:23:24 UTC

[GitHub] [tvm] NicolaLancellotti opened a new pull request #7556: Remove pytest dependency in arm_compute_lib.py

NicolaLancellotti opened a new pull request #7556:
URL: https://github.com/apache/tvm/pull/7556


   This pr removes the unexpected dependency on pytest in python/tvm/relay/op/contrib/arm_compute_lib.py
   


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



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

Posted by GitBox <gi...@apache.org>.
lhutton1 commented on a change in pull request #7556:
URL: https://github.com/apache/tvm/pull/7556#discussion_r585757847



##########
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:
       Agreed, I think this would make it more readable as well, otherwise this looks good to me!




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



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

Posted by GitBox <gi...@apache.org>.
NicolaLancellotti commented on pull request #7556:
URL: https://github.com/apache/tvm/pull/7556#issuecomment-787917536


   Please, can you review it? @mbaret @comaniac @d-smirnov


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



[GitHub] [tvm] comaniac merged pull request #7556: Remove pytest dependency in arm_compute_lib.py

Posted by GitBox <gi...@apache.org>.
comaniac merged pull request #7556:
URL: https://github.com/apache/tvm/pull/7556


   


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



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

Posted by GitBox <gi...@apache.org>.
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



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

Posted by GitBox <gi...@apache.org>.
comaniac commented on pull request #7556:
URL: https://github.com/apache/tvm/pull/7556#issuecomment-799706896


   Thanks @NicolaLancellotti @lhutton1 


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



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

Posted by GitBox <gi...@apache.org>.
NicolaLancellotti commented on a change in pull request #7556:
URL: https://github.com/apache/tvm/pull/7556#discussion_r593084365



##########
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:
       I have added `OpAttrContext` (which is a copy of `TempOpAttr`) in `arm_compute_lib.py`.
   And I have replaced `TempOpAttr` with `OpAttrContext`.




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