Skip to content

Commit

Permalink
Avoid calling te.if_then_else with internal Fraction utility
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunderberg committed Jan 12, 2023
1 parent 3b6e6e5 commit e5ddc73
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions python/tvm/topi/image/resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def _resize_1d(
if exclude_outside:
for i in range(4):
wx[i] = te.if_then_else(
te.any(xint - 1 + i < 0, xint + i > image_width), 0.0, wx[i]
te.any(xint - 1 + i < 0, xint + i > image_width), 0.0, wx[i].as_type(out_dtype)
)
sum_wx = sum(wx)
wx = [w / sum_wx for w in wx]
Expand Down Expand Up @@ -738,10 +738,10 @@ def _resize_2d(
if exclude_outside:
for i in range(4):
wx[i] = te.if_then_else(
te.any(xint - 1 + i < 0, xint + i > image_width), 0.0, wx[i]
te.any(xint - 1 + i < 0, xint + i > image_width), 0.0, wx[i].astype(out_dtype)
)
wy[i] = te.if_then_else(
te.any(yint - 1 + i < 0, yint + i > image_height), 0.0, wy[i]
te.any(yint - 1 + i < 0, yint + i > image_height), 0.0, wy[i].astype(out_dtype)
)
sum_wx = sum(wx)
sum_wy = sum(wy)
Expand Down Expand Up @@ -1189,13 +1189,13 @@ def _resize_3d(
if exclude_outside:
for i in range(4):
wz[i] = te.if_then_else(
te.any(xint - 1 + i < 0, xint + i > image_height), 0.0, wx[i]
te.any(xint - 1 + i < 0, xint + i > image_height), 0.0, wx[i].as_type(out_dtype)
)
wy[i] = te.if_then_else(
te.any(yint - 1 + i < 0, yint + i > image_height), 0.0, wy[i]
te.any(yint - 1 + i < 0, yint + i > image_height), 0.0, wy[i].as_type(out_dtype)
)
wx[i] = te.if_then_else(
te.any(xint - 1 + i < 0, xint + i > image_width), 0.0, wx[i]
te.any(xint - 1 + i < 0, xint + i > image_width), 0.0, wx[i].as_type(out_dtype)
)
sum_wz = sum(wz)
sum_wy = sum(wy)
Expand Down

0 comments on commit e5ddc73

Please sign in to comment.