Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion python/tvm/relay/frontend/tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,15 @@ def _convert_resize(self, method, op):
coord_trans = "align_corners" if align_corners else "asymmetric"
coord_trans = "half_pixel" if half_pixel_centers else coord_trans

rounding_method = ""
if method == "nearest_neighbor":
if not align_corners and half_pixel_centers:
rounding_method = "round_prefer_ceil"

if bilinear_method and input_tensor.qnn_params:
in_expr = self.dequantize(in_expr, input_tensor)
out = _op.image.resize2d(
in_expr, target_size, None, "NHWC", method, coordinate_transformation_mode=coord_trans
in_expr, target_size, None, "NHWC", method, coord_trans, rounding_method
)
if bilinear_method and output_tensor.qnn_params:
out = self.quantize(out, output_tensor)
Expand Down
14 changes: 14 additions & 0 deletions tests/python/frontend/tflite/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,20 @@ def test_all_resize():
align_corners=False,
half_pixel_centers=False,
)
_test_resize(
tf.image.resize_nearest_neighbor,
images_data_float32,
size_data,
align_corners=True,
half_pixel_centers=False,
)
_test_resize(
tf.image.resize_nearest_neighbor,
images_data_float32,
size_data,
align_corners=False,
half_pixel_centers=True,
)


#######################################################################
Expand Down