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:
[email protected]