Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.

Commit

Permalink
ResizeBilinear to use upsampling
Browse files Browse the repository at this point in the history
  • Loading branch information
srkreddy1238 committed May 22, 2018
1 parent 1042538 commit 55dc1e6
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions python/nnvm/frontend/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,26 @@ def _impl(inputs, attr, params):

def _resize_bilinear():
def _impl(inputs, attr, params):
# Making a copy node assuming the preprocessing already done.
# Change this when we have corresponding resize bilinear operation.
print ("ResizeBilinear: It's a pass through, please handle preprocessing before input")
pop_node = inputs.pop(1)
params.pop(pop_node.list_output_names()[0])
return AttrCvt(op_name="copy", ignores=['align_corners'])(inputs, attr)
print ("ResizeBilinear:Only NN (nearest neighbor) supported in symetric mode of dimensions")
print ("Change this when we have corresponding resize bilinear operation")

# NHWC
input_shape = attr['_input_shapes'][inputs[0]][0]
in_hw = (input_shape[1], input_shape[2])
out_hw = params[inputs[1].list_output_names()[0]]
inputs.pop(1)
attr['layout'] = 'NHWC'

if in_hw[0] < 0 or in_hw[1] < 0:
scale = 1
else:
# Considering height alone for scale
scale = out_hw[0] / in_hw[0]

return AttrCvt(op_name="upsampling",
ignores=['Tdim', 'align_corners'],
extras={'scale': scale})(inputs, attr)
return _impl

def _check_numerics():
Expand Down Expand Up @@ -439,6 +453,9 @@ def from_tensorflow(self, graph):
self._output_shapes[node.name] = \
[tensor_util.TensorShapeProtoToList(shape) for shape in attr['_output_shapes']]

# Pass the parsed shapes instead
attr["_output_shapes"] = self._output_shapes[node.name]

try:
inputs = [self._nodes[i] for i in node.input]
input_shapes = {}
Expand Down

0 comments on commit 55dc1e6

Please sign in to comment.