| 104 | } |
| 105 | |
| 106 | void ClScaleKernel::configure(const CLCompileContext &compile_context, |
| 107 | ITensorInfo *src, |
| 108 | ITensorInfo *dst, |
| 109 | const ScaleKernelInfo &info) |
| 110 | { |
| 111 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst, info)); |
| 112 | auto padding_info = get_padding_info({src, dst}); |
| 113 | |
| 114 | // Info required for the static tuning |
| 115 | _data_layout = info.data_layout == DataLayout::UNKNOWN ? src->data_layout() : info.data_layout; |
| 116 | |
| 117 | const bool is_nhwc = _data_layout == DataLayout::NHWC; |
| 118 | |
| 119 | float scale_x = 0.f; |
| 120 | float scale_y = 0.f; |
| 121 | std::tie(scale_x, scale_y) = calculate_scale_factors(src, dst, _data_layout, info.align_corners); |
| 122 | |
| 123 | // Area interpolation behaves as Nearest Neighbour in case of up-sampling |
| 124 | auto interpolation_policy_to_use = info.interpolation_policy; |
| 125 | if (info.interpolation_policy == InterpolationPolicy::AREA && scale_x <= 1.f && scale_y <= 1.f) |
| 126 | { |
| 127 | interpolation_policy_to_use = InterpolationPolicy::NEAREST_NEIGHBOR; |
| 128 | } |
| 129 | |
| 130 | // Create kernel |
| 131 | const int idx_width = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH); |
| 132 | const int idx_height = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT); |
| 133 | const int idx_channel = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::CHANNEL); |
| 134 | const unsigned int src_width = src->dimension(idx_width); |
| 135 | const unsigned int src_height = src->dimension(idx_height); |
| 136 | const unsigned int dst_width = dst->dimension(idx_width); |
| 137 | const unsigned int dst_channels = dst->dimension(idx_channel); |
| 138 | unsigned int vec_size = 0; |
| 139 | unsigned int vec_size_leftover = 0; |
| 140 | |
| 141 | CLBuildOptions build_opts; |
| 142 | if (_data_layout == DataLayout::NHWC) |
| 143 | { |
| 144 | vec_size = adjust_vec_size(src->data_type() == DataType::F32 ? 4 : 8, dst_channels); |
| 145 | vec_size_leftover = dst_channels % vec_size; |
| 146 | build_opts.add_option("-DSRC_TENSOR_TYPE=BUFFER"); |
| 147 | build_opts.add_option("-DSRC_DATA_TYPE=" + get_cl_type_from_data_type(src->data_type())); |
| 148 | build_opts.add_option("-DDST_TENSOR_TYPE=BUFFER"); |
| 149 | build_opts.add_option("-DDST_DATA_TYPE=" + get_cl_type_from_data_type(dst->data_type())); |
| 150 | build_opts.add_option("-DCONSTANT_VALUE=" + |
| 151 | string_from_pixel_value(info.constant_border_value, src->data_type())); |
| 152 | build_opts.add_option("-DN0=" + support::cpp11::to_string(vec_size)); |
| 153 | build_opts.add_option("-DPARTIAL_N0=" + support::cpp11::to_string(vec_size_leftover)); |
| 154 | build_opts.add_option("-DSCALE_" + string_from_interpolation_policy(interpolation_policy_to_use)); |
| 155 | build_opts.add_option_if(src->num_dimensions() > 3, "-DBATCHED_EXECUTION"); |
| 156 | build_opts.add_option_if(info.border_mode == BorderMode::REPLICATE, "-DBORDER_MODE_REPLICATE"); |
| 157 | build_opts.add_option_if(info.border_mode == BorderMode::CONSTANT, "-DBORDER_MODE_CONSTANT"); |
| 158 | build_opts.add_option_if(info.align_corners, "-DALIGN_CORNERS"); |
| 159 | build_opts.add_option_if(is_data_type_float(src->data_type()), "-DIS_FLOATING_POINT"); |
| 160 | build_opts.add_option_if_else(info.sampling_policy == SamplingPolicy::CENTER, "-DSAMPLING_POLICY_CENTER", |
| 161 | "-DSAMPLING_POLICY_TOP_LEFT"); |
| 162 | } |
| 163 | else if (_data_layout == DataLayout::NCHW) |
nothing calls this directly
no test coverage detected