masahi commented on a change in pull request #5135: [ONNX]Pool3d & upsample3d
op support
URL: https://github.com/apache/incubator-tvm/pull/5135#discussion_r399144140
##########
File path: python/tvm/relay/frontend/onnx.py
##########
@@ -780,19 +784,32 @@ def _impl_v9(cls, inputs, attr, params):
assert len(inputs) == 2, "Upsample op take 2 inputs, {}
given".format(len(inputs))
scales = params[inputs[1].name_hint].asnumpy()
inputs = inputs[:1]
- assert len(scales) == 4 and scales[0] == 1.0 and scales[1] == 1.0
+ assert scales[0] == 1.0 and scales[1] == 1.0
+ input_shape = infer_shape(inputs[0])
+ dims = len(input_shape)
mode = attr.get('mode')
if mode == b'nearest':
method = "nearest_neighbor"
elif mode == b'linear':
- method = "bilinear"
+ method = "trilinear" if dims == 5 else "bilinear"
else:
raise tvm.error.OpAttributeInvalid(
'Value {} in attribute "mode" of operator Upsample is not
valid.'.format(mode))
- attr = {'scale_h': scales[-2], 'scale_w': scales[-1], 'method': method,
- 'layout': 'NCHW', 'align_corners': True}
- return AttrCvt('upsampling')(inputs, attr)
-
+ attr = {'scale_h': scales[-2],
+ 'scale_w': scales[-1],
+ 'method': method}
+ if dims == 5:
+ assert len(scales) == 5
+ attr['scale_d'] = scales[-3]
+ attr['layout'] = 'NCDHW'
+ attr['coordinate_transformation_mode'] = 'half_pixel'
Review comment:
why is this hard coded for half_pixel?
----------------------------------------------------------------
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