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

Method run_op

src/gpu/cl/kernels/ClSoftmaxKernel.cpp:186–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186void ClSoftmaxKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
187{
188 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
189 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window);
190
191 const auto src =
192 utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC));
193 auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST));
194 ICLTensor *tmp = (_tmp_info.total_size() > 0)
195 ? utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_INT_0))
196 : nullptr;
197
198 if (!_prepared)
199 {
200 _prepared = true;
201
202 const auto *src_info = src->info();
203 const auto *dst_info = dst->info();
204 auto src_strides = src_info->strides_in_bytes();
205 auto dst_strides = dst_info->strides_in_bytes();
206
207 const auto src_stride_axis = src_strides[_axis];
208 const auto dst_stride_axis = dst_strides[_axis];
209
210 // This axis has been removed from execution window, hence we remove it from the list of strides
211 // provided to the kernel.
212 // In case axis > 0, src/dst_stride_axis will be provided in dedicated argument independent from global ID.
213 src_strides.remove(_axis);
214 dst_strides.remove(_axis);
215
216 // Argument 0: src_ptr.
217 _kernel.setArg<cl_uint>(1, src_strides[0]);
218 _kernel.setArg<cl_uint>(2, src_strides[1]);
219 _kernel.setArg<cl_uint>(3, src_strides[2]);
220 _kernel.setArg<cl_uint>(4, src_info->offset_first_element_in_bytes());
221
222 // Argument 5: dst_ptr.
223 _kernel.setArg<cl_uint>(6, dst_strides[0]);
224 _kernel.setArg<cl_uint>(7, dst_strides[1]);
225 _kernel.setArg<cl_uint>(8, dst_strides[2]);
226 _kernel.setArg<cl_uint>(9, dst_info->offset_first_element_in_bytes());
227
228 if (tmp != nullptr)
229 {
230 const auto *tmp_info = tmp->info();
231 const auto &tmp_strides = tmp_info->strides_in_bytes();
232
233 // Argument 10: tmp_ptr.
234 _kernel.setArg<cl_uint>(11, tmp_strides[1]);
235 _kernel.setArg<cl_uint>(12, tmp_strides[2]);
236 _kernel.setArg<cl_uint>(13, tmp_strides[3]);
237 _kernel.setArg<cl_uint>(14, 0);
238 }
239
240 if (_axis > 0)
241 {
242 _kernel.setArg<cl_uint>(15, src_stride_axis);
243 _kernel.setArg<cl_uint>(16, dst_stride_axis);

Callers

nothing calls this directly

Calls 7

get_const_tensorMethod · 0.80
removeMethod · 0.80
setArgMethod · 0.80
get_tensorMethod · 0.45
total_sizeMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected