\(\newcommand{\W}[1]{ \; #1 \; }\) \(\newcommand{\R}[1]{ {\rm #1} }\) \(\newcommand{\B}[1]{ {\bf #1} }\) \(\newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} }\) \(\newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} }\) \(\newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} }\) \(\newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }\)
atomic_four_mat_mul¶
View page sourceAtomic Matrix Multiply Class: Example Implementation¶
Syntax¶
atomic_mat_mul
mat_mul ( name )set
( n_left , n_middle , n_right )get
( call_id , n_left , n_middle , n_right )Purpose¶
Construct an atomic operation that computes the matrix product C = A * B .
n_left¶
This is the row dimension of the matrices A and C .
This is an argument (return value) for the set
(get
) routine.
n_middle¶
This is the column dimension of the matrix A
and row dimension of the matrix B
This is an argument (return value) for the set
(get
) routine.
n_right¶
This is the column dimension of the matrices B and C .
This is an argument (return value) for the set
(get
) routine.
call_id¶
This is a return value (argument) for the set
(get
) routine.
x¶
We use x to denote the argument to the atomic function. The size of this vector must be
n = n_left * n_middle + n_middle * n_right
The matrix A is stored in row major order at the beginning of x ; i.e. its ( i , k ) element is
A ( i , k ) = x [ i * n_middle + k ]
The matrix B is stored in row major order at the end of x ; i.e. its ( k , j ) element is
B ( k , j ) = x [ n_left * n_middle + k * n_right + j ]
y¶
We use y to denote the result of the atomic function. The size of this vector must be m = n_middle * n_right . The matrix C is stored in row major order in y ; i.e. its ( i , k ) element is
C ( i , j ) = y [ i * n_right + j ]
Theory¶
Forward¶
For \(k = 0 , \ldots\), the k-th order Taylor coefficient \(C^{(k)}\) is given by
Matrix Argument Scalar Valued Function¶
Suppose \(\bar{F}\) is the derivative of the scalar value function \(s(F)\) with respect to the matrix \(F\); i.e.,
Also suppose that \(t\) is a scalar valued argument and
It follows that
Letting \(E(t) = 0\) and \(D(t) = \Delta^{i,j} (t)\) (where \(\Delta^{i,j} (t)\) is the matrix that is zero, except for \(i = j\) where it is \(t\)) we have
Letting \(D(t) = 0\) and \(E(t) = \Delta^{i,j} (t)\) we have
Reverse¶
Reverse mode eliminates \(C^{(k)}\) as follows: for \(\ell = 0, \ldots , k\),
Contents¶
Name |
Title |
---|---|
atomic_four_mat_mul_implement |
|
atomic_four_mat_mul_forward.cpp |
|
atomic_four_mat_mul_reverse.cpp |
|
atomic_four_mat_mul_sparsity.cpp |
|
atomic_four_mat_mul_rev_depend.cpp |
|
atomic_four_mat_mul_identical_zero.cpp |