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

Function gradient

src/backend/cuda/kernel/gradient.hpp:25–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24template<typename T>
25void gradient(Param<T> grad0, Param<T> grad1, CParam<T> in) {
26 constexpr unsigned TX = 32;
27 constexpr unsigned TY = 8;
28
29 auto gradient =
30 common::getKernel("arrayfire::cuda::gradient", {{gradient_cuh_src}},
31 TemplateArgs(TemplateTypename<T>()),
32 {{DefineValue(TX), DefineValue(TY)}});
33
34 dim3 threads(TX, TY, 1);
35
36 int blocksPerMatX = divup(in.dims[0], TX);
37 int blocksPerMatY = divup(in.dims[1], TY);
38 dim3 blocks(blocksPerMatX * in.dims[2], blocksPerMatY * in.dims[3], 1);
39
40 const int maxBlocksY = getDeviceProp(getActiveDeviceId()).maxGridSize[1];
41 blocks.z = divup(blocks.y, maxBlocksY);
42 blocks.y = divup(blocks.y, blocks.z);
43
44 EnqueueArgs qArgs(blocks, threads, getActiveStream());
45
46 gradient(qArgs, grad0, grad1, in, blocksPerMatX, blocksPerMatY);
47 POST_LAUNCH_CHECK();
48}
49
50} // namespace kernel
51} // namespace cuda

Callers

nothing calls this directly

Calls 4

TemplateArgsFunction · 0.85
getActiveStreamFunction · 0.85
getKernelFunction · 0.50
getActiveDeviceIdFunction · 0.50

Tested by

no test coverage detected