diff options
author | TatWai Chong <tatwai.chong@arm.com> | 2023-08-31 16:58:27 -0700 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2023-09-13 18:44:56 +0000 |
commit | fb879821119c93109198a576e7b93e80b3dc0616 (patch) | |
tree | 330eceb5d54add4c1e2ccdfdbac7f277573d0a57 /reference_model/src/ops/image.cc | |
parent | 76c6a556c7396ee6468780b57676e5821c55b1e4 (diff) | |
download | reference_model-fb879821119c93109198a576e7b93e80b3dc0616.tar.gz |
Add integer divide with floor for coordinate calculation
Align with the change in the spec.
Define idiv_floor to give equivalent behavior to the floating-point
floor function for image coordinate calculation.
Change-Id: Ice06d354d58b1bb0dfedab55c9cc9eac1598b50c
Signed-off-by: TatWai Chong <tatwai.chong@arm.com>
Diffstat (limited to 'reference_model/src/ops/image.cc')
-rw-r--r-- | reference_model/src/ops/image.cc | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/reference_model/src/ops/image.cc b/reference_model/src/ops/image.cc index cf2b60a..b1b762f 100644 --- a/reference_model/src/ops/image.cc +++ b/reference_model/src/ops/image.cc @@ -159,16 +159,15 @@ int OpResize<InDtype, OutDtype, resize_t>::eval() int32_t y = oy * scale_y_d + offset_y; int32_t x = ox * scale_x_d + offset_x; - int32_t iy; - int32_t ix; + int16_t iy = idiv_floor(y, scale_y_n); + int16_t ix = idiv_floor(x, scale_x_n); + resize_t dy; resize_t dx; if (std::is_same<resize_t, double>::value) { const double fy_double = static_cast<double>(y) / static_cast<double>(scale_y_n); const double fx_double = static_cast<double>(x) / static_cast<double>(scale_x_n); - iy = floor(fy_double); - ix = floor(fx_double); dy = (resize_t)(fy_double - iy); dx = (resize_t)(fx_double - ix); @@ -177,8 +176,6 @@ int OpResize<InDtype, OutDtype, resize_t>::eval() { const float fy = static_cast<float>(y) / static_cast<float>(scale_y_n); const float fx = static_cast<float>(x) / static_cast<float>(scale_x_n); - iy = floor(fy); - ix = floor(fx); if (std::is_floating_point<resize_t>::value || (typeid(resize_t) == typeid(Eigen::bfloat16)) || (typeid(resize_t) == typeid(half_float::half))) |