ae2f_docs
Slp.core.h
1#ifndef ae2fVK_Ann_Slp_core_h
2#define ae2fVK_Ann_Slp_core_h
3
4#include <ae2f/Cast.h>
5#include <ae2f/errGlob.h>
6#include <vulkan/vulkan.h>
7#include <ae2f/Ann/Slp.h>
8#include <vulkan/vulkan_core.h>
9#include <ae2f/Cmp.h>
10#include <limits.h>
11#include <ae2f/Float.h>
12
13#define clspv_restrict ae2f_restrict
14#include <clspv/Compiler.h>
15
16#if VK_MAX_MEMORY_TYPES > UCHAR_MAX
17#error "Sanity check: memory types will not be stored under unsigned char."
18#endif
19
20
21#include <ae2f/Pack/Beg.h>
22
23/** Each of them matches for the pipeline */
24typedef enum ae2fVK_eAnnSlpPipes {
25 ae2fVK_eAnnSlpPipes_kPredict,
26 ae2fVK_eAnnSlpPipes_kFollow,
27 ae2fVK_eAnnSlpPipes_kTrain,
28 ae2fVK_eAnnSlpPipes_kFit,
29
30 /** @brief This is the end of the value, which typically means the count of actual kernel used. */
31 ae2fVK_eAnnSlpPipes_LEN
32} ae2fVK_eAnnSlpPipes;
33
34typedef enum ae2fVK_eAnnSlpDescPools {
35 ae2fVK_eAnnSlpDescPools_kPredict,
36 ae2fVK_eAnnSlpDescPools_kTrain,
37 ae2fVK_eAnnSlpDescPools_LEN
38} ae2fVK_eAnnSlpDescPools;
39
40typedef enum ae2fVK_eAnnSlpPipeLayouts {
41 ae2fVK_eAnnSlpPipeLayouts_kPredict,
42 ae2fVK_eAnnSlpPipeLayouts_kTrain,
43 ae2fVK_eAnnSlpPipeLayouts_kFit,
44 ae2fVK_eAnnSlpPipeLayouts_LEN
45} ae2fVK_eAnnSlpPipeLayouts;
46
47typedef enum ae2fVK_eAnnSlpDescLayouts {
48 ae2fVK_eAnnSlpDescLayouts_kPredict,
49 ae2fVK_eAnnSlpDescLayouts_kTrain,
50 ae2fVK_eAnnSlpDescLayouts_LEN
51} ae2fVK_eAnnSlpDescLayouts;
52
53
54ae2f_structdef(struct, ae2fVK_AnnSlp);
55ae2f_structdef(struct, ae2fVK_AnnSlpMkAlter_t) {
56
57 /**
58 * @brief
59 * Stack size and allocation count.
60 */
61 size_t m_stack, m_alloccount;
62
63 /**
64 * @brief
65 * Pointer to the created SLP.
66 */
67 ae2fVK_AnnSlp* ae2f_restrict m_ptr;
68
69 unsigned char m_i;
70
71 /** ENDOFDEFINITION */
72};
73
74ae2f_structdef(union, ae2fVK_AnnSlpMkU0_t) {
75 ae2fVK_AnnSlpMkAlter_t m_alter;
76 ae2f_AnnSlpMk_t m_base;
77
78 /***/
79 size_t m_spirv_len;
80};
81
82ae2f_structdef(union, ae2fVK_AnnSlpMkU1_t) {
83 VkMemoryAllocateInfo m_vkmemallocinfo;
84 VkBufferCreateInfo m_vkbufcreatinfo;
85 VkDescriptorSetLayoutCreateInfo m_vkdescsetlayoutcreatinfo;
86 VkPushConstantRange m_vkpushconstrange;
87
88 /***/
89 void* m_spirv;
90 char* m_spirv_c;
91 uint32_t* m_spirv_u32;
92};
93
94ae2f_structdef(struct, ae2fVK_AnnSlpMkU2S0_t) {
95 VkDescriptorSetLayoutBinding m_glob, m_loc;
96};
97
98ae2f_structdef(union, ae2fVK_AnnSlpMkU2_t) {
99 VkMemoryRequirements m_vkmemreqs;
100
101 /** List dummy for ae2fVK_AnnSlpMkU2_t::m_S0. */
102 VkDescriptorSetLayoutBinding m_vkdescsetlayoutbind[2];
103
104 ae2fVK_AnnSlpMkU2S0_t m_S0;
105
106 VkPipelineLayoutCreateInfo m_vkpipelayoutcreatinfo;
107
108 /***/
109 char* m_log;
110 VkShaderModuleCreateInfo m_vkshadermodcreatinfo;
111 VkComputePipelineCreateInfo m_vkcomputepipecreatinfo[ae2fVK_eAnnSlpPipes_LEN];
112};
113
114typedef char STATIC_ASSERT_ae2fVK_AnnSlpMkU2_vkdescsetlayoutbind_sz[
115 sizeof(ae2fVK_AnnSlpMkU2S0_t) == sizeof(VkDescriptorSetLayoutBinding) * 2
116 ? 1 : -1
117];
118
119ae2f_structdef(union, ae2fVK_AnnSlpMkU3_t) {
120 char* m_openclsrc;
121 void* m_openclsrc_v;
122};
123
124ae2f_structdef(struct, ae2fVK_AnnSlpMk_t) {
125 ae2fVK_AnnSlpMkU0_t m_U0;
126 ae2fVK_AnnSlpMkU1_t m_U1;
127 ae2fVK_AnnSlpMkU2_t m_U2;
128 ae2fVK_AnnSlpMkU3_t m_U3;
129
130
131 /** @brief error */
132 ae2f_err_t m_reterr;
133};
134
135ae2f_structdef(struct, ae2fVK_AnnSlpPredictUnion0WrDescInfo_t) {
136 VkDescriptorBufferInfo m_buf[ae2fVK_eAnnSlpDescPools_LEN];
137 VkWriteDescriptorSet m_wrset;
138};
139
140ae2f_structdef(union, ae2fVK_AnnSlpPredictUnion0_t) {
141 VkDescriptorSetAllocateInfo m_vkdescsetallocinfo;
142 VkDescriptorBufferInfo m_vkdescbuffinfo;
143 ae2fVK_AnnSlpPredictUnion0WrDescInfo_t m_vkdescwrdescinfo;
144 VkCommandBufferBeginInfo m_vkcmdbufbeginfo;
145};
146
147ae2f_structdef(struct, ae2fVK_AnnSlpDescPoolCmdMk_t) {
148 /** Temporary buffer 1 */
149 ae2fVK_AnnSlpPredictUnion0_t m_u0;
150};
151
152typedef VkMappedMemoryRange ae2fVK_AnnSlpUnMap_t, ae2fVK_AnnSlpMapRangedGeneric_t;
153
154ae2f_structdef(struct, ae2fVK_AnnSlpCreatDescPoolU0_t)
155{
156 VkDescriptorPoolCreateInfo m_vkdescpoolcreatinfo;
157 VkDescriptorPoolSize m_vkdescpoolsz;
158};
159
160ae2f_structdef(struct, ae2fVK_AnnSlpCreatDescPool_t)
161{
162 ae2fVK_AnnSlpCreatDescPoolU0_t m_U0;
163};
164
165#include <ae2f/Pack/End.h>
166
167#define __ae2fVK_AnnSlpWeightSz_V(CLFLOAT, i_inp, i_out) (sizeof(CLFLOAT) * (i_inp) * (i_out))
168#define __ae2fVK_AnnSlpBiasSz_V(CLFLOAT, i_inp, i_out) (sizeof(CLFLOAT) * (i_out))
169#define __ae2fVK_AnnSlpInpSz_V(CLFLOAT, i_inp, i_out) (sizeof(CLFLOAT) * (i_inp))
170#define __ae2fVK_AnnSlpOutSz_V(CLFLOAT, i_inp, i_out) (sizeof(CLFLOAT) * (i_out))
171#define __ae2fVK_AnnSlpDeltaSz_V(CLFLOAT, i_inp, i_out) (sizeof(CLFLOAT) * (i_out))
172#define __ae2fVK_AnnSlpGoalSz_V(CLFLOAT, i_inp, i_out) (sizeof(CLFLOAT) * (i_out))
173
174#define __ae2fVK_AnnSlpWeightOff_V(CLFLOAT, i_inp, i_out) 0
175
176#define __ae2fVK_AnnSlpBiasOff_V(CLFLOAT, i_inp, i_out)
177 (__ae2fVK_AnnSlpWeightSz_V(CLFLOAT, i_inp, i_out) + __ae2fVK_AnnSlpWeightOff_V(CLFLOAT, i_inp, i_out))
178
179#define __ae2fVK_AnnSlpInpOff_V(CLFLOAT, i_inp, i_out)
180 (__ae2fVK_AnnSlpBiasSz_V(CLFLOAT, i_inp, i_out) + __ae2fVK_AnnSlpBiasOff_V(CLFLOAT, i_inp, i_out))
181
182#define __ae2fVK_AnnSlpOutOff_V(CLFLOAT, i_inp, i_out)
183 (__ae2fVK_AnnSlpInpSz_V(CLFLOAT, i_inp, i_out) + __ae2fVK_AnnSlpInpOff_V(CLFLOAT, i_inp, i_out))
184
185#define __ae2fVK_AnnSlpDeltaOff_V(CLFLOAT, i_inp, i_out)
186 (__ae2fVK_AnnSlpOutSz_V(CLFLOAT, i_inp, i_out) + __ae2fVK_AnnSlpOutOff_V(CLFLOAT, i_inp, i_out))
187#define __ae2fVK_AnnSlpGoalOff_V(CLFLOAT, i_inp, i_out)
188 (__ae2fVK_AnnSlpDeltaSz_V(CLFLOAT, i_inp, i_out) + __ae2fVK_AnnSlpDeltaOff_V(CLFLOAT, i_inp, i_out))
189
190#define __ae2fVK_AnnSlpGlobSz_V(CLFLOAT, i_inp, i_out)
191 (__ae2fVK_AnnSlpGoalSz_V(CLFLOAT, i_inp, i_out) + __ae2fVK_AnnSlpGoalOff_V(CLFLOAT, i_inp, i_out))
192
193#define __ae2fVK_AnnSlpWeightSz(i_inp, i_out) __ae2fVK_AnnSlpWeightSz_V(ae2f_float_t, i_inp, i_out)
194#define __ae2fVK_AnnSlpBiasSz(i_inp, i_out) __ae2fVK_AnnSlpBiasSz_V(ae2f_float_t, i_inp, i_out)
195#define __ae2fVK_AnnSlpInpSz(i_inp, ...) __ae2fVK_AnnSlpInpSz_V(ae2f_float_t, i_inp, i_out)
196#define __ae2fVK_AnnSlpOutSz(i_inp, i_out) __ae2fVK_AnnSlpOutSz_V(ae2f_float_t, i_inp, i_out)
197#define __ae2fVK_AnnSlpDeltaSz(i_inp, i_out) __ae2fVK_AnnSlpDeltaSz_V(ae2f_float_t, i_inp, i_out)
198#define __ae2fVK_AnnSlpGoalSz(i_inp, i_out) __ae2fVK_AnnSlpGoalSz_V(ae2f_float_t, i_inp, i_out)
199
200#define __ae2fVK_AnnSlpWeightOff(i_inp, i_out) 0
201#define __ae2fVK_AnnSlpBiasOff(i_inp, i_out) __ae2fVK_AnnSlpBiasOff_V(ae2f_float_t, i_inp, i_out)
202#define __ae2fVK_AnnSlpInpOff(i_inp, i_out) __ae2fVK_AnnSlpInpOff_V(ae2f_float_t, i_inp, i_out)
203#define __ae2fVK_AnnSlpOutOff(i_inp, i_out) __ae2fVK_AnnSlpOutOff_V(ae2f_float_t, i_inp, i_out)
204#define __ae2fVK_AnnSlpDeltaOff(i_inp, i_out) __ae2fVK_AnnSlpDeltaOff_V(ae2f_float_t, i_inp, i_out)
205#define __ae2fVK_AnnSlpGoalOff(i_inp, i_out) __ae2fVK_AnnSlpGoalOff_V(ae2f_float_t, i_inp, i_out)
206
207#define __ae2fVK_AnnSlpGlobSz(i_inp, i_out) __ae2fVK_AnnSlpGlobSz_V(ae2f_float_t, i_inp, i_out)
208
209#endif
#define ae2f_enumdef(name,...)
Definition Cast.h:111
#define ae2f_structdef(key, name)
Definition Cast.h:110
#define ae2f_const_cast(t, v)
Definition Cast.h:57
#define ae2f_static_cast(t, v)
Definition Cast.h:42
#define ae2f_reinterpret_cast(t, v)
Definition Cast.h:52
#define unless(...)
Invokes when condition is false.
Definition Cast.h:103
#define ae2f_opt
Definition Guide.h:26
#define ae2f_errGlob_OK
The Operation you've wanted went successful.
Definition errGlob.h:23
#define ae2f_errGlob_ALLOC_FAILED
stdlib allocating functions (malloc, calloc, realloc) has been failed.
Definition errGlob.h:40
#define ae2f_errGlob_NFOUND
Found some errors, but not by parameters. The operation has failed.
Definition errGlob.h:50
#define ae2f_errGlob_WRONG_OPERATION
Found that parameter sent by programmer is invalid. The operation may have been ceased while the midd...
Definition errGlob.h:45
uint8_t ae2f_err_t
Informs that this number represents the error.
Definition errGlob.h:19
#define ae2f_errGlob_PTR_IS_NULL
Failed to refer the pointer either l-value inside the function.
Definition errGlob.h:32
#define ae2f_errGlob_IMP_NOT_FOUND
Failed to find the function on preprocessor which is callable for some reason No operation has beed d...
Definition errGlob.h:28
#define __ae2f_MACRO_GENERATED
Definition Conv.auto.h:2
#define __ae2fVK_AnnMlpOutStreamSz(i_depth, i_outc, i_weightc)
Definition Mlp.core.h:130
#define __ae2fVK_AnnMlpWeightOff(i_depth, i_outc, i_weightc)
Definition Mlp.core.h:139
#define __ae2fVK_AnnMlpUnMapRanged_imp
Definition Mlp.core.h:171
#define __ae2fVK_AnnMlpGoalOff(i_depth, i_outc, i_weightc)
Definition Mlp.core.h:157
#define __ae2fVK_AnnMlpMapRangedGeneric_imp
Definition Mlp.core.h:170
#define __ae2fVK_AnnMlpOutStreamOff(i_depth, i_outc, i_weightc)
Definition Mlp.core.h:133
#define __ae2fVK_AnnMlpMdlOff(...)
Definition Mlp.core.h:128
#define __ae2fVK_AnnMlpBiasSz(i_depth, i_outc, i_weightc)
Definition Mlp.core.h:142
#define __ae2fVK_AnnMlpMdlSz(i_depth,...)
Definition Mlp.core.h:125
#define __ae2fVK_AnnMlpGoalSz(i_depth, i_outc, i_weightc)
Definition Mlp.core.h:154
#define __ae2fVK_AnnMlpDeltaStreamOff(i_depth, i_outc, i_weightc)
Definition Mlp.core.h:151
#define __ae2fVK_AnnMlpGlobMemSz(i_depth, i_outc, i_weightc)
Definition Mlp.core.h:160
#define __ae2fVK_AnnMlpBiasOff(i_depth, i_outc, i_weightc)
Definition Mlp.core.h:145
#define __ae2fVK_AnnMlpDeltaStreamSz(i_depth, i_outc, i_weightc)
Definition Mlp.core.h:148
#define __ae2fVK_AnnMlpWeightSz(i_depth, i_outc, i_weightc)
Definition Mlp.core.h:136
#define __ae2fVK_AnnSlpDeltaOff_V(CLFLOAT, i_inp, i_out)
Definition Slp.core.h:185
#define __ae2fVK_AnnSlpGlobSz_V(CLFLOAT, i_inp, i_out)
Definition Slp.core.h:190
#define __ae2fVK_AnnSlpOutSz_V(CLFLOAT, i_inp, i_out)
Definition Slp.core.h:170
#define __ae2fVK_AnnSlpInpSz_V(CLFLOAT, i_inp, i_out)
Definition Slp.core.h:169
#define __ae2fVK_AnnSlpGoalSz_V(CLFLOAT, i_inp, i_out)
Definition Slp.core.h:172
#define __ae2fVK_AnnSlpDeltaSz_V(CLFLOAT, i_inp, i_out)
Definition Slp.core.h:171
#define __ae2fVK_AnnSlpBiasSz_V(CLFLOAT, i_inp, i_out)
Definition Slp.core.h:168
#define __ae2fVK_AnnSlpInpOff_V(CLFLOAT, i_inp, i_out)
Definition Slp.core.h:179
#define __ae2fVK_AnnSlpWeightSz_V(CLFLOAT, i_inp, i_out)
Definition Slp.core.h:167
#define __ae2fVK_AnnSlpWeightOff_V(CLFLOAT, i_inp, i_out)
Definition Slp.core.h:174
#define __ae2fVK_AnnSlpOutOff_V(CLFLOAT, i_inp, i_out)
Definition Slp.core.h:182
#define __ae2fVK_AnnSlpBiasOff_V(CLFLOAT, i_inp, i_out)
Definition Slp.core.h:176
#define __ae2fVK_AnnSlpGoalOff_V(CLFLOAT, i_inp, i_out)
Definition Slp.core.h:187
#define ae2f_MAC_BUILD
Definition Util.h:5
#define ae2fVK_AnnMlpSHADER
#define __ae2fVK_AnnSlpDescPoolMk_imp(v_descpool, r_pool, r_reterr, iv_slp, i_vkdescpoolcreatflags, i_vkmaxdescsets)
#define __ae2fVK_AnnSlpDescPoolCmdClean_imp(iv_slp, i_pool, i_cmd)
#define __ae2fVK_AnnSlpDescPoolCmdMk_imp(COMMANDONRECORDING, v_cmdmk, r_cmd, iv_slp, i_pool, iv_err, i_desccount, i_offglob, i_szglob, i_offloc, i_szloc, i_desclayout, i_pipe, i_pipelayout, i_vkcmdbuf)
#define __ae2fVK_AnnSlpDescPoolClean_imp(i_slp, i_pool)
#define __ae2fVK_AnnMlpMk_imp_V(cllocfloat_t, v_mk, iv_weight_opt, iv_bias_opt, iv_outstream_opt, iv_deltastream_opt, i_len_count, i_len, i_len_swap, i_prm_offset, i_extra, i_act, i_actderiv, i_lossderiv, i_learningrate, i_learningrate_bias, i_vkdev, i_vkmemprops, iv_vkalloccalls, i_vkcldeclaration, i_vkcldefinition)
Definition Mlp.auto.h:107
#define __ae2fVK_AnnSlpMkCLSPVVerbose_imp(r_handle, ir_err, i_first, i_second, i_third)
Definition Slp.auto.h:794
#define __ae2fVK_AnnSlpMapRangedGeneric_imp(T, v_vkmapmemrange, iv_slp, r_err, r_ptr, i_off, i_sz)
Definition Slp.auto.h:868
#define __ae2fVK_AnnSlpMkLoadPipeCreat_imp(CMDONERR, r_reterr, pipecreat, pipelayout, shadermod, entrypoint, idx_pipe, idx_pipelayout)
Definition Slp.auto.h:208
#define __ae2fVK_AnnSlpMkOnePipeLayoutVerbose_imp(CMDONERR, v_vkpushconstrange, v_vkpipelayoutcreatinfo, r_reterr, iv_slpptr, idx, szrequired, vkalloccalls, vkdev)
Definition Slp.auto.h:247
#define __ae2fVK_AnnSlpUnMapRanged_imp(v_out, vi_slp, i_off, i_sz)
Definition Slp.auto.h:941
#define __ae2fVK_AnnSlpMkAllocVKMem_imp(CMDONERR, sz, r_vkres, r_vkbuf, r_vkdevmem, v_errbit, v_vkbufcreatinfo, v_memallocinfo, vkbufuseflags, vksharemode, vkdev, v_vkmemreq, vkalloccalls, v_memtypeidx, memtypeidx_invalid_minus_one, vkpropflag_req, vkphydevmemprops)
Definition Slp.auto.h:109
#define __ae2f_AnnMlpMk_imp(reg_mk, prm_depth, pprm_szvector, propptr_szswap_opt, lppfn_act_opt, lppfn_actderiv_opt, pfn_lossderiv, propptr_deltastream_opt, propptr_outcache_opt, propptr_weight_opt, propptr_bias_opt, prm_learningrate, prm_learningrate_bias, prm_offset_opt, prm_extra_opt)
Automatically allocates ae2f_AnnMlp and store its pointer at (reg_mk).m_mkbase.
Definition Mlp.auto.h:163
#define ae2f_MAC(...)
Definition mac.h:28