MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / sobel

Function sobel

src/backend/opencl/kernel/sobel.hpp:26–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24namespace kernel {
25template<typename Ti, typename To, unsigned ker_size>
26void sobel(Param dx, Param dy, const Param in) {
27 constexpr int THREADS_X = 16;
28 constexpr int THREADS_Y = 16;
29
30 std::vector<TemplateArg> targs = {
31 TemplateTypename<Ti>(),
32 TemplateTypename<To>(),
33 TemplateArg(ker_size),
34 };
35 std::vector<std::string> compileOpts = {
36 DefineKeyValue(Ti, dtype_traits<Ti>::getName()),
37 DefineKeyValue(To, dtype_traits<To>::getName()),
38 DefineKeyValue(KER_SIZE, ker_size),
39 };
40 compileOpts.emplace_back(getTypeBuildDefinition<Ti>());
41
42 auto sobel =
43 common::getKernel("sobel3x3", {{sobel_cl_src}}, targs, compileOpts);
44
45 cl::NDRange local(THREADS_X, THREADS_Y);
46
47 int blk_x = divup(in.info.dims[0], THREADS_X);
48 int blk_y = divup(in.info.dims[1], THREADS_Y);
49
50 cl::NDRange global(blk_x * in.info.dims[2] * THREADS_X,
51 blk_y * in.info.dims[3] * THREADS_Y);
52 size_t loc_size =
53 (THREADS_X + ker_size - 1) * (THREADS_Y + ker_size - 1) * sizeof(Ti);
54
55 sobel(cl::EnqueueArgs(getQueue(), global, local), *dx.data, dx.info,
56 *dy.data, dy.info, *in.data, in.info, cl::Local(loc_size), blk_x,
57 blk_y);
58 CL_DEBUG_FINISH(getQueue());
59}
60} // namespace kernel
61} // namespace opencl
62} // namespace arrayfire

Callers

nothing calls this directly

Calls 5

TemplateArgClass · 0.85
getNameFunction · 0.85
EnqueueArgsClass · 0.85
getKernelFunction · 0.50
getQueueFunction · 0.50

Tested by

no test coverage detected