kice commented on a change in pull request #4566: [Relay/Topi][Op] Added native
DepthToSpace and SpaceToDepth Operators
URL: https://github.com/apache/incubator-tvm/pull/4566#discussion_r360737840
##########
File path: python/tvm/relay/frontend/onnx.py
##########
@@ -539,35 +539,7 @@ class DepthToSpace(OnnxOpConverter):
def _impl_v11(cls, inputs, attr, params):
block_size = int(attr['blocksize'])
- mode = attr.get("mode", "DCR")
-
- # handle NCHW layout
- indata = infer_value_simulated(inputs[0], params)
- in_n, in_c, in_h, in_w = indata.shape
-
- # reshape to proper output
- new_c = int(in_c / (block_size * block_size))
- new_h = in_h * block_size
- new_w = in_w * block_size
- newshape = (in_n, new_c, new_h, new_w)
-
- if mode == "DCR":
- # expand input to larger dimension.
- expanded = _op.reshape(inputs[0],
- newshape=(in_n, block_size, block_size,
new_c, in_h, in_w))
- # reorder to expand spatial blocks.
- transposed = _op.transpose(expanded, axes=(0, 3, 4, 1, 5, 2))
-
- else: # CRD mode
- # expand input to larger dimension.
- expanded = _op.reshape(inputs[0],
- newshape=(in_n, new_c, block_size,
block_size, in_h, in_w))
- # reorder to expand spatial blocks.
- transposed = _op.transpose(expanded, axes=(0, 1, 4, 2, 5, 3))
-
- return AttrCvt(op_name="reshape",
- extras={'newshape': newshape},
- ignores=['mode', 'blocksize'])([transposed], attr)
+ return _op.nn.depth_to_space(inputs[0], block_size)
Review comment:
We need to handle eacho DepthToSpace mode differently.
For the record, PixelShuffle in Pytorch (onnx CRD mode) and depth_to_space
in tensorflow (onnx DCR mode) is different.
----------------------------------------------------------------
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]
With regards,
Apache Git Services