Skip to content

Commit

Permalink
[Relay] Adding _contrib_BilinearResize2D op from mxnet (#2777)
Browse files Browse the repository at this point in the history
* adding _contrib_BilinearResize2D op from mxnet

* error fixed

* use resize instead of upsample
  • Loading branch information
Laurawly authored and yzhliu committed Mar 17, 2019
1 parent 053f864 commit 011f0b6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python/tvm/relay/frontend/mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,17 @@ def _mx_roi_align(inputs, attrs):
new_attrs["layout"] = "NCHW"
return _op.vision.roi_align(inputs[0], inputs[1], **new_attrs)

def _mx_upsampling(inputs, attrs):
scale_height = attrs.get_float("scale_height", None)
scale_width = attrs.get_float("scale_width", None)
height = attrs.get_int("height", 1)
width = attrs.get_int("width", 1)
if scale_height is not None:
height = scale_height * inputs[0].shape[2]
if scale_width is not None:
width = scale_width * inputs[0].shape[3]
size = (inputs[0].shape[0], inputs[0].shape[1], height, width)
return _op.image.resize(inputs[0], size)

def _mx_roi_pooling(inputs, attrs):
new_attrs = {}
Expand Down Expand Up @@ -646,6 +657,7 @@ def _mx_shape_array(inputs, attrs):
"SoftmaxOutput" : _mx_softmax_output,
"SoftmaxActivation" : _mx_softmax_activation,
# vision
"_contrib_BilinearResize2D" : _mx_upsampling,
"_contrib_MultiBoxPrior" : _mx_multibox_prior,
"_contrib_MultiBoxDetection" : _mx_multibox_detection,
"_contrib_ROIAlign" : _mx_roi_align,
Expand Down

0 comments on commit 011f0b6

Please sign in to comment.