diff --git a/mace/kernels/resize_bicubic.h b/mace/kernels/resize_bicubic.h index 046c6bb1206bd3122eb1c8cbacae4c9950cc8ab0..bf61f175fe66a23e754418f580684a3921bfcb23 100644 --- a/mace/kernels/resize_bicubic.h +++ b/mace/kernels/resize_bicubic.h @@ -58,21 +58,21 @@ inline int64_t Bound(int64_t val, int64_t limit) { } inline void GetWeightsAndIndices(float scale, int64_t out_loc, int64_t limit, - std::array* weights, - std::array* indices) { + std::vector* weights, + std::vector* indices) { const int64_t in_loc = scale * out_loc; const float delta = scale * out_loc - in_loc; const int64_t offset = lrintf(delta * kTableSize); const float* coeffs_tab = GetCoeffsTable(); - *weights = {{coeffs_tab[offset * 2 + 1], coeffs_tab[offset * 2], + *weights = {coeffs_tab[offset * 2 + 1], coeffs_tab[offset * 2], coeffs_tab[(kTableSize - offset) * 2], - coeffs_tab[(kTableSize - offset) * 2 + 1]}}; - *indices = {{Bound(in_loc - 1, limit), Bound(in_loc, limit), - Bound(in_loc + 1, limit), Bound(in_loc + 2, limit)}}; + coeffs_tab[(kTableSize - offset) * 2 + 1]}; + *indices = {Bound(in_loc - 1, limit), Bound(in_loc, limit), + Bound(in_loc + 1, limit), Bound(in_loc + 2, limit)}; } -inline float Interpolate1D(const std::array& weights, - const std::array& values) { +inline float Interpolate1D(const std::vector& weights, + const std::vector& values) { return values[0] * weights[0] + values[1] * weights[1] + values[2] * weights[2] + values[3] * weights[3]; } @@ -95,17 +95,17 @@ inline void ResizeImage(const float *images, const float height_scale, const float width_scale, float *output) { - std::array coeff = {{0.0, 0.0, 0.0, 0.0}}; + std::vector coeff = {0.0, 0.0, 0.0, 0.0}; #pragma omp parallel for collapse(2) for (index_t b = 0; b < batch_size; ++b) { for (index_t y = 0; y < out_height; ++y) { - std::array y_weights; - std::array y_indices; + std::vector y_weights; + std::vector y_indices; GetWeightsAndIndices(height_scale, y, in_height, &y_weights, &y_indices); for (index_t x = 0; x < out_width; ++x) { - std::array x_weights; - std::array x_indices; + std::vector x_weights; + std::vector x_indices; GetWeightsAndIndices(width_scale, x, in_width, &x_weights, &x_indices); @@ -117,15 +117,15 @@ inline void ResizeImage(const float *images, float *channel_output_ptr = output + (b * channels + c) * out_height * out_width; for (index_t i = 0; i < 4; ++i) { - const std::array values = { - {static_cast(channel_input_ptr + const std::vector values = { + static_cast(channel_input_ptr [y_indices[i] * in_width + x_indices[0]]), - static_cast(channel_input_ptr + static_cast(channel_input_ptr [y_indices[i] * in_width + x_indices[1]]), - static_cast(channel_input_ptr + static_cast(channel_input_ptr [y_indices[i] * in_width + x_indices[2]]), - static_cast(channel_input_ptr - [y_indices[i] * in_width + x_indices[3]])}}; + static_cast(channel_input_ptr + [y_indices[i] * in_width + x_indices[3]])}; coeff[i] = Interpolate1D(x_weights, values); } channel_output_ptr[y * out_width + x] =