MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / configure

Method configure

src/gpu/cl/kernels/ClPool2dKernel.cpp:121–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121void ClPool2dKernel::configure(const ClCompileContext &compile_context,
122 ITensorInfo *src,
123 ITensorInfo *dst,
124 const PoolingLayerInfo &pool_info,
125 ITensorInfo *indices)
126{
127 ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst);
128 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst, pool_info, indices));
129
130 auto padding_info = get_padding_info({src, dst, indices});
131
132 // Auto init if empty
133 TensorShape out_shape = compute_pool_shape(*src, pool_info);
134 auto_init_if_empty(*dst, src->clone()->set_tensor_shape(out_shape));
135 if (indices)
136 {
137 auto_init_if_empty(*indices, src->clone()->set_tensor_shape(out_shape).set_data_type(DataType::U32));
138 }
139
140 // Set instance variables
141 _pool_info = pool_info;
142 _data_layout = pool_info.data_layout == DataLayout::UNKNOWN ? src->data_layout() : pool_info.data_layout;
143 _num_elems_processed_per_iteration =
144 (_data_layout == DataLayout::NCHW) ? 1 : ((dst->data_type() == DataType::F32) ? 2 : 4);
145 _num_elems_processed_per_iteration = adjust_vec_size(_num_elems_processed_per_iteration, dst->dimension(0));
146
147 int pool_stride_x = 0;
148 int pool_stride_y = 0;
149 const PoolingType pool_type = pool_info.pool_type;
150 const int idx_width = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH);
151 const int idx_height = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT);
152 const int idx_channel = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::CHANNEL);
153 const int idx_batch_size = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::BATCHES);
154 const int pool_size_x = pool_info.is_global_pooling ? src->dimension(idx_width) : pool_info.pool_size.width;
155 const int pool_size_y = pool_info.is_global_pooling ? src->dimension(idx_height) : pool_info.pool_size.height;
156 const PadStrideInfo pad_stride_info = pool_info.pad_stride_info;
157 const bool exclude_padding = pool_info.exclude_padding;
158 std::tie(pool_stride_x, pool_stride_y) = pad_stride_info.stride();
159 const int pool_pad_top = pad_stride_info.pad_top();
160 const int pool_pad_left = pad_stride_info.pad_left();
161 const DataType data_type = src->data_type();
162
163 // Set build options
164 CLBuildOptions build_opts;
165 build_opts.add_option("-DVEC_SIZE=" + support::cpp11::to_string(_num_elems_processed_per_iteration));
166 build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(data_type));
167 build_opts.add_option("-DPOOL_" + string_from_pooling_type(pool_type));
168 build_opts.add_option("-DSTRIDE_X=" + support::cpp11::to_string(pool_stride_x));
169 build_opts.add_option("-DSTRIDE_Y=" + support::cpp11::to_string(pool_stride_y));
170 build_opts.add_option("-DPAD_X=" + support::cpp11::to_string(pool_pad_left));
171 build_opts.add_option("-DPAD_Y=" + support::cpp11::to_string(pool_pad_top));
172 build_opts.add_option("-DPOOL_SIZE_X=" + support::cpp11::to_string(pool_size_x));
173 build_opts.add_option("-DPOOL_SIZE_Y=" + support::cpp11::to_string(pool_size_y));
174 build_opts.add_option("-DSRC_WIDTH=" + support::cpp11::to_string(src->dimension(idx_width)));
175 build_opts.add_option("-DSRC_HEIGHT=" + support::cpp11::to_string(src->dimension(idx_height)));
176 build_opts.add_option("-DMAX_WIDTH=" +
177 support::cpp11::to_string(src->dimension(idx_width) + (exclude_padding ? 0 : pool_pad_left)));
178 build_opts.add_option("-DMAX_HEIGHT=" +

Callers

nothing calls this directly

Calls 15

get_padding_infoFunction · 0.85
compute_pool_shapeFunction · 0.85
auto_init_if_emptyFunction · 0.85
adjust_vec_sizeFunction · 0.85
Size2DClass · 0.85
is_data_type_floatFunction · 0.85
is_data_type_quantizedFunction · 0.85
get_min_maxFunction · 0.85
lowestFunction · 0.85

Tested by

no test coverage detected