def _resize_bilinear():
def _impl(inputs, attr, params):
attr['size'] = attr['_output_shapes'][0][1:3]
inputs.pop(1)
# NHWC
attr['layout'] = 'NHWC'
return AttrCvt(op_name="resize",
ignores=['Tdim'],
extras={'method': "NEAREST_NEIGHBOR"})(inputs, attr)
return _impl
_convert_map = {
.........
'ResizeNearestNeighbor' : _resize_bilinear()
Above is what I have modified in source code to support tensorflow ResizeNearestNeighbor op, and I print related op info below.
node name: input_1 node op: Placeholder attr: {'shape': dim {
size: -1
}
dim {
size: -1
}
dim {
size: -1
}
dim {
size: 3
}
, 'dtype': tf.float32, '_output_shapes': [dim {
size: -1
}
dim {
size: -1
}
dim {
size: -1
}
dim {
size: 3
}
]}
node name: up_sampling2d_1/ResizeNearestNeighbor node op: ResizeNearestNeighbor attr: {'_output_shapes': [dim {
size: -1
}
dim {
size: -1
}
dim {
size: -1
}
dim {
size: 256
}
], 'T': tf.float32, 'align_corners': False}
node name: up_sampling2d_2/ResizeNearestNeighbor node op: ResizeNearestNeighbor attr: {'_output_shapes': [dim {
size: -1
}
dim {
size: -1
}
dim {
size: -1
}
dim {
size: 128
}
], 'T': tf.float32, 'align_corners': False
Here NHW = -1 because input size has not been set, when code goes to nnvm.compiler.build, I set the input shape and dtype.
By the way, I check my tensorflow model using tensorboard, and found that even if I set input placeholder shape and resize op get a determined input shape, it will give output size (?,?,?,C), so does this matter?