ae2f_docs
Slp.cl.c
Go to the documentation of this file.
1#define ae2f_NEED_CLASS 0
2
3#if __ae2f_MACRO_GENERATED
4#define ae2fVK_clspv_IS_OPENCL 1
5#endif
6
7#include "./Slp.auto.h"
8
9#ifndef ACT
10#define ACT(r, x)
11#endif
12
13#ifndef ACT_DERIV
14#define ACT_DERIV(r, x)
15#endif
16
17#ifndef LOSS_DERIV
18#define LOSS_DERIV(r, y, y_desired, i, c)
19#endif
20
21/** Magic numbers */
22#define p_weight glob
23#define p_bias (glob + (osz * isz))
24#define p_inp ((p_bias) + (osz))
25#define p_out ((p_inp) + isz)
26#define p_delta ((p_out) + osz)
27#define p_goal ((p_delta) + osz)
28
29const ae2f_structdef(struct, lr_t) {
30 ae2f_float_t m_weight;
31 ae2f_float_t m_bias;
32};
33
34
35/**
36 * @brief
37 *
38 * get_global_id(0) : oidx \n
39 *
40 * Global: \n
41 * , ae2f_float_t[Out][Inp] : Weight \n
42 * , ae2f_float_t[Out] : Bias \n
43 * , ae2f_float_t[Inp] \n
44 * , ae2f_float_t[Out] \n
45 *
46 * */
47__kernel void kPredict(__global ae2f_float_t* glob, const uint32_t unused) {
48 const size_t
49 oidx = get_global_id(0)
50 , osz = get_global_size(0)
51 , iidx = get_global_id(1)
52 , isz = get_global_size(1);
53
54 clSlpPredict_t v_predict;
55
56 clSlpPredict(v_predict, p_out, p_inp, p_weight, p_bias, iidx, isz, oidx, osz, ACT);
57}
58
59/**
60 * @brief
61 *
62 * get_global_id(0) : oidx \n
63 * get_local_id(0) : iidx \n
64 *
65 * Global: \n
66 * ae2f_float_t[Out][Inp] : Weights \n
67 * , ae2f_float_t[Out] : Bias \n
68 * , ae2f_float_t[Inp] \n
69 * , ae2f_float_t[Out] \n
70 * , ae2f_float_t[Out] : Delta \n
71 * , ae2f_float_t[Out] : Goal \n
72 *
73 * Local: \n
74 * ae2f_float_t[Out] \n
75 * */
77 const size_t
78 oidx = get_global_id(0)
79 , osz = get_global_size(0)
80 , iidx = get_global_id(1)
81 , isz = get_global_size(1)
82 ;
83
84 ae2f_float_t delta = 0, v_tmp = 0, v_tmp1 = 0;
85 clSlpPredict_t v_predict;
86
87 clSlpPredict(v_predict, loc, p_inp, p_weight, p_bias, iidx, isz, oidx, osz, ACT);
88
89 if(iidx == 0) {
90 p_out[oidx] = loc[oidx];
91
93 v_tmp, v_tmp1
94 , loc /** out */
95 , p_goal /** out_desired */
96 , ACT_DERIV, LOSS_DERIV
97 , delta
98 , oidx, osz
99 );
100
101 /** delta */
102 p_delta[oidx] = (delta);
103
105 p_bias[oidx] /** r_bias */
106 , delta /** delta */
107 , lr.m_bias
108 );
109 }
110
112 p_inp[iidx] /** inp */
113 , (delta) /** delta */
114 , glob /** weight */
115 , lr.m_weight
116 , isz
117 , iidx
118 , osz
119 , oidx
120 );
121
122}
123
124/**
125 * @brief
126 *
127 * get_global_id(0) : oidx \n
128 * get_local_id(0) : iidx \n
129 *
130 * Global: \n
131 * ae2f_float_t[Out][In] : Weights \n
132 * , ae2f_float_t[Out] : Bias \n
133 * , ae2f_float_t[Inp] \n
134 * , ae2f_float_t[Out] \n
135 * , ae2f_float_t[Out] : Delta \n
136 * , ae2f_float_t[Out] : Goal \n
137 *
138 * */
139__kernel void kFit(lr_t lr, __global ae2f_float_t* glob) {
140 const size_t
141 oidx = get_global_id(0)
142 , osz = get_global_size(0)
143 , iidx = get_global_id(1)
144 , isz = get_global_size(1)
145 ;
146
147 ae2f_float_t delta, v_tmp, v_tmp1;
148
149 if(iidx == 0) {
151 v_tmp, v_tmp1
152 , p_out /** out */
153 , p_goal /** out_desired */
154 , ACT_DERIV
155 , LOSS_DERIV
156 , delta /** retdelta */
157 , oidx
158 , osz
159 );
160
161 /** delta */
162 p_delta[oidx] = delta;
163
165 p_bias[oidx] /** r_bias */
166 , delta /** delta */
167 , lr.m_bias
168 );
169 }
170
172 p_inp[iidx] /** inp */
173 , delta /** delta */
174 , p_weight /** weight */
175 , lr.m_weight
176 , isz
177 , iidx
178 , osz
179 , oidx
180 );
181}
182
183/**
184 * @brief
185 * get_global_id(0): oidx
186 * get_local_id(0): iidx
187 *
188 * Global: \n
189 * ae2f_float_t[Out][In] : Weights \n
190 * , ae2f_float_t[Out] : Bias \n
191 * , ae2f_float_t[Inp] \n
192 * , ae2f_float_t[Out] : Delta \n
193 * */
194__kernel void kFollow(lr_t lr, __global ae2f_float_t* glob) {
195 const size_t
196 oidx = get_global_id(0)
197 , osz = get_global_size(0)
198 , iidx = get_global_id(1)
199 , isz = get_global_size(1)
200 ;
201
203 p_inp[iidx] /** inp */
204 , p_delta[oidx] /** delta */
205 , p_weight /** weight */
206 , lr.m_weight
207 , isz
208 , iidx
209 , osz
210 , oidx
211 );
212
213 if(iidx == 0) {
215 p_bias[oidx] /** r_bias */
216 , p_delta[oidx] /** delta */
217 , lr.m_bias
218 );
219 }
220}
#define ae2f_structdef(key, name)
Definition Cast.h:110
ae2f_float ae2f_float_t
Definition Float.h:38
#define p_weight
sizeof(ae2f_float_t) * pgsz_sqr * llsz
Definition Mlp.cl.c:37
#define p_goal
sizeof(ae2f_float_t) * pgsz
Definition Mlp.cl.c:46
#define p_inp
Definition Mlp.cl.c:34
#define p_bias
sizeof(ae2f_float_t) * pgsz * llsz
Definition Mlp.cl.c:40
__kernel void kPredict(__global void *glob, __local ae2f_float_t *loc, const uint32_t lsz)
loc ae2f_float_t[Page]: inp ae2f_float_t[Page]: out
Definition Mlp.cl.c:93
__kernel void kFollow(__global void *glob, __local ae2f_float_t *loc, lrlsz_t lr)
loc ae2f_float_t[lsz - 1][Page]: OutStream ae2f_float_t[lsz - 1][Page]: DeltaStream
Definition Mlp.cl.c:166
__kernel void kTrain(lr_t lr, __global ae2f_float_t *glob, __local ae2f_float_t *loc)
get_global_id(0) : oidx get_local_id(0) : iidx
Definition Slp.cl.c:76
#define p_delta
Definition Slp.cl.c:26
__kernel void kFit(lr_t lr, __global ae2f_float_t *glob)
get_global_id(0) : oidx get_local_id(0) : iidx
Definition Slp.cl.c:139
#define p_out
Definition Slp.cl.c:25
#define __global
#define uint32_t
#define __local
#define size_t
#define __kernel
size_t get_global_id(uint dimindx)
size_t get_global_size(uint dimindx)
#define __ae2f_AnnSlpFollowOneW_imp(inp, delta, weight, learningrate, inp_sz, inp_idx, out_sz, out_idx)
Weights.
Definition Slp.auto.h:366
#define __ae2f_AnnSlpFollowOneB_imp(r_bias, delta, learningrate_bias)
Definition Slp.auto.h:385
#define __ae2f_AnnSlpFetchDeltaOne_imp(v_fetchdelta_0, v_fetchdelta_1, out, out_desired, actderiv_opt, lossderiv, retdelta, oidx, osz)
Definition Slp.auto.h:513
#define clSlpPredict
Definition Slp.auto.h:88
#define clSlpPredict_t
Definition Slp.auto.h:89