Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// This file is auto-generated by wgsl-gen. Do not edit manually.
 
#pragma once
 
// Template implementation
// Source: tensor/pad.wgsl.template
 
template <>
Status ApplyTemplate<"tensor/pad.wgsl.template">(ShaderHelper& shader_helper, TemplateParameter<"tensor/pad.wgsl.template">::type params) {
  [[maybe_unused]] auto& ss = shader_helper.AdditionalImplementation();
 
  // Extract parameters
  auto& __param_dim_value_zero = params.param_dim_value_zero;
  auto& __param_is_float16 = params.param_is_float16;
  auto& __param_pad_mode = params.param_pad_mode;
 
  // Extract variables
  auto* __var_output = params.var_output;
 
//  1 | #define PAD_MODE_CONSTANT 0
//  2 | #define PAD_MODE_REFLECT 1
//  3 | #define PAD_MODE_EDGE 2
//  4 | #define PAD_MODE_WRAP 3
//  5 |
//  6 | #use guardAgainstOutOfBoundsWorkgroupSizes
//  7 | #use getElementAt
//  8 | #use .offsetToIndices .setByOffset .rank
//  9 |
// 10 | #param dim_value_zero
// 11 | #param is_float16
// 12 | #param pad_mode
// 13 |
// 14 | $MAIN {
MainFunctionStart();
ss << __str_5;
// 15 |   guardAgainstOutOfBoundsWorkgroupSizes(uniforms.output_size);
ss << __str_237;
ss << shader_helper.GuardAgainstOutOfBoundsWorkgroupSizes(__str_233);
ss << __str_25;
// 16 |
ss << __str_5;
// 17 |   let constant_value =
ss << __str_363;
// 18 | #if is_float16
if (__param_is_float16) {
// 19 |       bitcast<vec2<f16>>(uniforms.constant_value)[0];
ss << __str_364;
// 20 | #else
} else {
// 21 |       bitcast<output_value_t>(uniforms.constant_value);
ss << __str_365;
// 22 | #endif
}
// 23 |
// 24 | #if dim_value_zero
if (__param_dim_value_zero) {
// 25 |   output[global_idx] = constant_value;
ss << __str_366;
// 26 | #else
} else {
// 27 |   let output_indices = output.offsetToIndices(global_idx);
ss << __str_367;
ss << __var_output->OffsetToIndices(__str_235);
ss << __str_25;
// 28 |   var input_index = u32(0);
ss << __str_368;
// 29 |   var use_pad_value = false;
ss << __str_369;
// 30 |   var in_coord = i32(0);
ss << __str_370;
// 31 |
ss << __str_5;
// 32 |   for (var dim = 0; dim < output.rank && !use_pad_value; dim++) {
ss << __str_371;
ss << __var_output->Rank();
ss << __str_372;
// 33 |     let output_index = i32(getElementAt(output_indices, dim, output.rank));
ss << __str_373;
ss << GetElementAt(__str_357, __str_358, __var_output->Rank());
ss << __str_12;
// 34 |     let lower_pads = getElementAt(uniforms.lower_pads, dim, output.rank);
ss << __str_374;
ss << GetElementAt(__str_359, __str_358, __var_output->Rank());
ss << __str_25;
// 35 |     let data_shape = i32(getElementAt(uniforms.data_shape, dim, output.rank));
ss << __str_375;
ss << GetElementAt(__str_360, __str_358, __var_output->Rank());
ss << __str_12;
// 36 | #if pad_mode == PAD_MODE_CONSTANT
if (__param_pad_mode == 0) {
// 37 |     if (output_index < lower_pads || output_index >= data_shape + lower_pads) {
ss << __str_376;
// 38 |         use_pad_value = true;
ss << __str_377;
// 39 | #elif pad_mode == PAD_MODE_EDGE
} else if (__param_pad_mode == 2) {
// 40 |     if (output_index < lower_pads) {
ss << __str_378;
// 41 |       in_coord = 0;
ss << __str_379;
// 42 |     } else if (output_index >= data_shape + lower_pads) {
ss << __str_380;
// 43 |       in_coord = data_shape - 1;
ss << __str_381;
// 44 | #elif pad_mode == PAD_MODE_REFLECT
} else if (__param_pad_mode == 1) {
// 45 |     if (output_index < lower_pads || output_index >= data_shape + lower_pads) {
ss << __str_376;
// 46 |       in_coord = output_index - lower_pads;
ss << __str_382;
// 47 |       if (in_coord < 0) {
ss << __str_383;
// 48 |         in_coord = -in_coord;
ss << __str_384;
// 49 |       }
ss << __str_314;
// 50 |       let _2n_1 = 2 * (data_shape - 1);
ss << __str_385;
// 51 |       in_coord = in_coord % _2n_1;
ss << __str_386;
// 52 |       if (in_coord >= data_shape) {
ss << __str_387;
// 53 |         in_coord = _2n_1 - in_coord;
ss << __str_388;
// 54 |       }
ss << __str_314;
// 55 | #else // PAD_MODE_WRAP
} else {
// 56 |     if (output_index < lower_pads) {
ss << __str_378;
// 57 |       in_coord = data_shape + output_index - lower_pads;
ss << __str_389;
// 58 |     } else if (output_index >= data_shape + lower_pads) {
ss << __str_380;
// 59 |       in_coord = output_index - data_shape - lower_pads;
ss << __str_390;
// 60 | #endif // pad_mode
}
// 61 |     } else {
ss << __str_391;
// 62 |         in_coord = output_index - lower_pads;
ss << __str_392;
// 63 |     }
ss << __str_15;
// 64 |
ss << __str_5;
// 65 | #if pad_mode == PAD_MODE_WRAP
if (__param_pad_mode == 3) {
// 66 |     in_coord = ((in_coord % data_shape) + data_shape) % data_shape;
ss << __str_393;
// 67 | #endif
}
// 68 |
// 69 |     input_index += select(u32(in_coord)
ss << __str_394;
// 70 | #if output.rank > 1
if (__var_output->Rank() > 1) {
// 71 |         * getElementAt(uniforms.data_stride, dim, output.rank - 1)
ss << __str_395;
ss << GetElementAt(__str_361, __str_358, __var_output->Rank() - 1);
ss << __str_5;
// 72 | #endif
}
// 73 |         , u32(in_coord), dim == output.rank - 1);
ss << __str_396;
ss << __var_output->Rank();
ss << __str_397;
// 74 |   }
ss << __str_16;
// 75 |
ss << __str_5;
// 76 |   output.setByOffset(global_idx, select(data[input_index], constant_value, use_pad_value));
ss << __str_237;
ss << __var_output->SetByOffset(__str_235, __str_362);
ss << __str_25;
// 77 | #endif
}
// 78 | } // MAIN
MainFunctionEnd();
ss << __str_5;
// 79 |
 
 
  return Status::OK();
}