lhutton1 commented on code in PR #13632:
URL: https://github.com/apache/tvm/pull/13632#discussion_r1050617765
##########
python/tvm/relay/op/nn/_nn.py:
##########
@@ -47,6 +47,42 @@
# log_softmax
reg.register_strategy("nn.log_softmax", strategy.log_softmax_strategy)
+# upsampling_tanspose
[email protected]_convert_op_layout("nn.upsampling")
+def convert_upsampling(attrs, inputs, tinfos, desired_layouts):
+ """Convert Layout pass registration for upsampling op.
+
+ Parameters
+ ----------
+ attrs : tvm.ir.Attrs
+ Attributes of current convolution
+ inputs : list of tvm.relay.Expr
+ The args of the Relay expr to be legalized
+ tinfos : list of types
+ List of input and output types
+ desired_layouts : list of layout strings
+ List of layouts defining our desired
+ layout for the data and kernel inputs respectively.
+
+ Returns
+ -------
+ result : tvm.relay.Expr
+ The transformed expr
+ """
+ data = inputs[0]
+ new_attrs = dict(attrs)
+ assert len(desired_layouts) == 1, "A desired layout is expected for
upsampling's inputs"
+ desired_data_layout = desired_layouts[0]
+ assert desired_data_layout != "default", "Data layout cannot be default"
+ new_attrs["layout"] = desired_data_layout
+
+ if desired_data_layout == "NCHW":
+ return relay.nn.upsampling(data, **new_attrs)
+ elif desired_data_layout == "NHWC":
+ return relay.nn.upsampling(data, **new_attrs)
Review Comment:
Seems these checks are redundant, we can simply just `return
relay.nn.upsampling(data, **new_attrs)` and defer handling unsupported layouts
to `relay.nn.upsample`.
--
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]