Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ batch_identity()

__kernel void stan::math::opencl_kernels::batch_identity ( __global double *  A,
unsigned int  batch_rows,
unsigned int  size 
)

Makes a batch of smaller identity matrices inside the input matrix.

This kernel operates inplace on the matrix A, filling it with smaller identity matrices with a size of batch_rows x batch_rows. This kernel expects a 3D organization of threads: 1st dim: the number of matrices in the batch. 2nd dim: the number of cols/rows in batch matrices. 3rd dim: the number of cols/rows in batch matrices. Each thread in the organization assigns a single value in the batch. In order to create a batch of 3 matrices the size of NxN you need to run the kernel batch_identity(A, N, 3*N*N) with (3, N, N) threads. The special case of batch_identity(A, N, N*N) executed on (1, N, N) threads creates a single identity matrix the size of NxN and is therefore equal to the basic identity kernel.

Parameters
[in,out]AThe batched identity matrix output.
batch_rowsThe number of rows/cols for the smaller matrices in the batch
sizeThe size of A.
Note
Code is a const char* held in identity_kernel_code. This kernel uses the helper macros available in helpers.cl.

Definition at line 40 of file batch_identity.hpp.