44 const size_t round_value = ceil_policy_scale ? 1
U : 0
U;
54 const auto width =
static_cast<int>(in.
shape().x());
55 const auto height =
static_cast<int>(in.
shape().y());
67 for(uint32_t element_idx = 0, count = 0; element_idx < num_elements; ++element_idx, ++count)
87 x_src = (idx + 0.5f) * wr;
88 y_src = (idy + 0.5f) * hr;
100 out[element_idx] =
tensor_elem_at(in,
id, border_mode, constant_border_value);
113 x_src = (idx + 0.5f) * wr - 0.5f;
114 y_src = (idy + 0.5f) * hr - 0.5f;
120 id.set(0, std::floor(x_src));
121 id.set(1, std::floor(y_src));
124 out[element_idx] =
bilinear_policy(in,
id, x_src, y_src, border_mode, constant_border_value);
130 out[element_idx] = constant_border_value;
134 id.set(0, utility::clamp<int>(x_src, 0, width - 1));
135 id.set(1, utility::clamp<int>(y_src, 0, height - 1));
143 int x_from = std::floor(idx * wr - 0.5f - x_src);
144 int y_from = std::floor(idy * hr - 0.5f - y_src);
145 int x_to = std::ceil((idx + 1) * wr - 0.5f - x_src);
146 int y_to = std::ceil((idy + 1) * hr - 0.5f - y_src);
147 const int xi = std::floor(x_src);
148 const int yi = std::floor(y_src);
151 x_src = std::max(-
static_cast<float>(border_size), std::min(x_src,
static_cast<float>(width - 1 + border_size)));
152 y_src = std::max(-
static_cast<float>(border_size), std::min(y_src,
static_cast<float>(height - 1 + border_size)));
155 x_from = ((x_src + x_from) < -border_size) ? -border_size : x_from;
156 y_from = ((y_src + y_from) < -border_size) ? -border_size : y_from;
157 x_to = ((x_src + x_to) >= (width + border_size)) ? (width - 1 + border_size) : x_to;
158 y_to = ((y_src + y_to) >= (height + border_size)) ? (height - 1 + border_size) : y_to;
162 for(
int j = yi + y_from, je = yi + y_to; j <= je; ++j)
164 for(
int i = xi + x_from, ie = xi + x_to; i <= ie; ++i)
166 id.set(0,
static_cast<int>(i));
167 id.set(1,
static_cast<int>(j));
168 sum +=
tensor_elem_at(in,
id, border_mode, constant_border_value);
171 out[element_idx] = sum / ((x_to - x_from + 1) * (y_to - y_from + 1));
183 template <
typename T>
196 if(
src.quantization_info().uniform().scale != 0.f)
201 dst = convert_to_asymmetric<uint8_t>(dst_tmp, output_quantization_info);
215 if(
src.quantization_info().uniform().scale != 0.f)
220 dst = convert_to_asymmetric<int8_t>(dst_tmp, output_quantization_info);