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

Method configure

src/gpu/cl/kernels/ClScatterKernel.cpp:114–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114void ClScatterKernel::configure(const ClCompileContext &compile_context,
115 const ITensorInfo *updates,
116 const ITensorInfo *indices,
117 ITensorInfo *dst,
118 const ScatterInfo &info)
119{
120 ARM_COMPUTE_ERROR_ON_NULLPTR(updates, dst, indices);
121 ARM_COMPUTE_LOG_PARAMS(updates, indices, dst, info);
122
123 const TensorShape &dst_shape = dst->tensor_shape();
124 const int index_len = indices->dimension(0);
125
126 // Check for single element data block
127 const bool is_scalar_block = (dst->num_dimensions() == static_cast<uint32_t>(index_len));
128
129 const int n0 = adjust_vec_size(16 / updates->element_size(), is_scalar_block ? 1 : updates->dimension(0));
130 const int partial_n0 = updates->dimension(0) % n0;
131
132 // The GWS will be 2D [x, y]
133 // x-dimension refers to the x coordinate of the dst tensor
134 // y-dimension refers to the collapsed y-coordinate of the data part of the dst tensor
135 Window win;
136
137 if (!is_scalar_block)
138 {
139 win = calculate_max_window(dst_shape, Steps(n0));
140
141 // Collapse the dimensions corresponding to indices in the execution window
142 for (int i = 0; i < index_len; ++i)
143 {
144 win.set(dst->num_dimensions() - (i + 1), Window::Dimension(0, 1, 1));
145 }
146
147 win = win.collapse(win, 1);
148 }
149
150 // Set build options
151 CLBuildOptions build_opts;
152 build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(dst->data_type()));
153 build_opts.add_option_if(is_data_type_float(dst->data_type()), "-DIS_FLOAT");
154
155 const int num_dims = dst->num_dimensions();
156 TensorShape ind_collapsed = indices->tensor_shape().collapsed_from(1);
157 build_opts.add_option("-DNUM_INDICES=" + support::cpp11::to_string(ind_collapsed[1]));
158 build_opts.add_option("-DINDEX_LENGTH=" + support::cpp11::to_string(index_len));
159
160 // We provide 5 variables to use in a constant array
161 for (int i = 1; i <= max_index_length; i++)
162 {
163 build_opts.add_option("-DOUT_SHAPE_N_MINUS_" + support::cpp11::to_string(i) + "=" +
164 support::cpp11::to_string(dst_shape[std::max(num_dims - i, 0)]));
165 }
166
167 build_opts.add_option("-DN0=" + support::cpp11::to_string(n0));
168 build_opts.add_option("-DPARTIAL_N0=" + support::cpp11::to_string(partial_n0));
169
170 switch (info.func)
171 {

Callers

nothing calls this directly

Calls 15

adjust_vec_sizeFunction · 0.85
StepsClass · 0.85
is_data_type_floatFunction · 0.85
upper_stringFunction · 0.85
create_kernelFunction · 0.85
lower_stringFunction · 0.85
add_option_ifMethod · 0.80
collapsed_fromMethod · 0.80
calculate_max_windowFunction · 0.50
DimensionClass · 0.50
to_stringFunction · 0.50

Tested by

no test coverage detected