| 114 | } |
| 115 | |
| 116 | void ClPool3dKernel::configure(const ClCompileContext &compile_context, |
| 117 | const ITensorInfo *src, |
| 118 | ITensorInfo *dst, |
| 119 | const Pooling3dLayerInfo &pool_info) |
| 120 | { |
| 121 | ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst); |
| 122 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst, pool_info)); |
| 123 | auto padding_info = get_padding_info({src, dst}); |
| 124 | |
| 125 | // Auto init if empty |
| 126 | TensorShape out_shape = compute_pool3d_shape(src->tensor_shape(), pool_info); |
| 127 | auto_init_if_empty(*dst, src->clone()->set_tensor_shape(out_shape)); |
| 128 | |
| 129 | // Set instance variables |
| 130 | _pool_info = pool_info; |
| 131 | _data_layout = src->data_layout(); |
| 132 | |
| 133 | _num_elems_processed_per_iteration = (dst->data_type() == DataType::F32) ? 2 : 4; |
| 134 | _num_elems_processed_per_iteration = adjust_vec_size(_num_elems_processed_per_iteration, dst->dimension(0)); |
| 135 | |
| 136 | const PoolingType pool_type = pool_info.pool_type; |
| 137 | const int idx_width = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH); |
| 138 | const int idx_height = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT); |
| 139 | const int idx_depth = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::DEPTH); |
| 140 | const int idx_channel = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::CHANNEL); |
| 141 | const int idx_batch_size = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::BATCHES); |
| 142 | const int pool_size_x = pool_info.is_global_pooling ? src->dimension(idx_width) : pool_info.pool_size.width; |
| 143 | const int pool_size_y = pool_info.is_global_pooling ? src->dimension(idx_height) : pool_info.pool_size.height; |
| 144 | const int pool_size_z = pool_info.is_global_pooling ? src->dimension(idx_depth) : pool_info.pool_size.depth; |
| 145 | const bool exclude_padding = pool_info.exclude_padding; |
| 146 | const int pool_stride_x = pool_info.stride.x(); |
| 147 | const int pool_stride_y = pool_info.stride.y(); |
| 148 | const int pool_stride_z = pool_info.stride.z(); |
| 149 | const int pool_pad_top = pool_info.padding.top; |
| 150 | const int pool_pad_left = pool_info.padding.left; |
| 151 | const int pool_pad_front = pool_info.padding.front; |
| 152 | const DataType data_type = src->data_type(); |
| 153 | |
| 154 | // Set build options |
| 155 | CLBuildOptions build_opts; |
| 156 | build_opts.add_option("-DVEC_SIZE=" + support::cpp11::to_string(_num_elems_processed_per_iteration)); |
| 157 | build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(data_type)); |
| 158 | build_opts.add_option("-DPOOL_" + string_from_pooling_type(pool_type)); |
| 159 | build_opts.add_option("-DSTRIDE_X=" + support::cpp11::to_string(pool_stride_x)); |
| 160 | build_opts.add_option("-DSTRIDE_Y=" + support::cpp11::to_string(pool_stride_y)); |
| 161 | build_opts.add_option("-DSTRIDE_Z=" + support::cpp11::to_string(pool_stride_z)); |
| 162 | build_opts.add_option("-DPAD_X=" + support::cpp11::to_string(pool_pad_left)); |
| 163 | build_opts.add_option("-DPAD_Y=" + support::cpp11::to_string(pool_pad_top)); |
| 164 | build_opts.add_option("-DPAD_Z=" + support::cpp11::to_string(pool_pad_front)); |
| 165 | build_opts.add_option("-DPOOL_SIZE_X=" + support::cpp11::to_string(pool_size_x)); |
| 166 | build_opts.add_option("-DPOOL_SIZE_Y=" + support::cpp11::to_string(pool_size_y)); |
| 167 | build_opts.add_option("-DPOOL_SIZE_Z=" + support::cpp11::to_string(pool_size_z)); |
| 168 | build_opts.add_option("-DSRC_WIDTH=" + support::cpp11::to_string(src->dimension(idx_width))); |
| 169 | build_opts.add_option("-DSRC_HEIGHT=" + support::cpp11::to_string(src->dimension(idx_height))); |
| 170 | build_opts.add_option("-DSRC_DEPTH=" + support::cpp11::to_string(src->dimension(idx_depth))); |
| 171 | |
| 172 | // If datatype is quantized add relevant parameters |
| 173 | if (is_data_type_quantized_asymmetric(data_type) && src->quantization_info() != dst->quantization_info()) |
nothing calls this directly
no test coverage detected