blib/lib/Peta/NN/Backend/WebGPU.pm untested

filter: Statementstmt 0.0% 0 / 223 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 17 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 0.0% 0 / 37 Podpod 0.0% 0 / 33 totaltotal 0.0% 0 / 336 CC 9 SCAR 14.0
CC
9
Cov
0%
new
12.0
_run
12.0
_pipeline
6.0
CRAP 4.0
1 package Peta::NN::Backend::WebGPU;
2 # ABSTRACT: Peta::NN on the graphics card
3  
4 # The GPU backend: a tensor is [ $buffer, $rows, $cols ], a storage buffer of
5 # 32-bit floats on the card, and every operation is one compute shader
6 # dispatched over it. Tensors stay on the card between operations; only
7 # flat() and the per-batch loss cross the bus.
8 #
9 # 32-bit floats are all WGSL has, so results agree with the plain backend to
10 # about six digits, not to rounding.
11  
12 use v5.36;
13  
14 use Peta::WebGPU;
15  
16 use parent -norequire, 'Peta::NN::Backend';
17 use Peta::NN::Backend;
18  
19 our $VERSION = '0.2610090';
20  
21 my $FLOAT_BYTES = 4;
22 my $GROUP_1D = 64; # must match @workgroup_size in the 1D shaders
23 my $GROUP_2D = 8; # and in the 2D ones
24  
25 # Every shader sees the same parameter block: eight integers, eight floats.
26 my $PARAMS = <<'WGSL';
27 struct Params { n0: u32, n1: u32, n2: u32, n3: u32, n4: u32, n5: u32, n6: u32, n7: u32,
28 f0: f32, f1: f32, f2: f32, f3: f32, f4: f32, f5: f32, f6: f32, f7: f32 }
29 WGSL
30  
31 my %KIND_CODE = (relu => 0, tanh => 1, sigmoid => 2);
32  
33 # name => [ bindings ("r" read-only floats, "w" read-write floats, "u" read-only
34 # unsigned), body ]. The parameter block is always the last binding, as `p`.
35 my %SHADER = (
36  
37 # y[s][j] = b[j] + sum_i w[j][i] x[s][i] n0 n_in, n1 n_out, n2 batch
38 # An invocation computes four outputs of one sample, so the sample's row
39 # is read once for the four.
40 affine => [ [qw(r:x r:w r:b w:y)], 2, <<'WGSL' ],
41 let j = id.x * 4u; let s = id.y;
42 if (j >= p.n1 || s >= p.n2) { return; }
43 let xa = s * p.n0;
44 var acc = vec4<f32>(0.0);
45 for (var i = 0u; i < p.n0; i++) {
46 acc += vec4<f32>(w[j * p.n0 + i], w[(j + 1u) * p.n0 + i], w[(j + 2u) * p.n0 + i], w[(j + 3u) * p.n0 + i]) * x[xa + i];
47 }
48 y[s * p.n1 + j] = b[j] + acc.x;
49 if (j + 1u < p.n1) { y[s * p.n1 + j + 1u] = b[j + 1u] + acc.y; }
50 if (j + 2u < p.n1) { y[s * p.n1 + j + 2u] = b[j + 2u] + acc.z; }
51 if (j + 3u < p.n1) { y[s * p.n1 + j + 3u] = b[j + 3u] + acc.w; }
52 WGSL
53  
54 # gw[j][i] = sum_s dy[s][j] x[s][i], four samples at a time
55 affine_gw => [ [qw(r:x r:dy w:gw)], 2, <<'WGSL' ],
56 let i = id.x; let j = id.y;
57 if (i >= p.n0 || j >= p.n1) { return; }
58 var acc = vec4<f32>(0.0);
59 let whole = (p.n2 / 4u) * 4u;
60 for (var s = 0u; s < whole; s += 4u) {
61 acc += vec4<f32>(dy[s * p.n1 + j], dy[(s + 1u) * p.n1 + j], dy[(s + 2u) * p.n1 + j], dy[(s + 3u) * p.n1 + j])
62 * vec4<f32>(x[s * p.n0 + i], x[(s + 1u) * p.n0 + i], x[(s + 2u) * p.n0 + i], x[(s + 3u) * p.n0 + i]);
63 }
64 var sum = acc.x + acc.y + acc.z + acc.w;
65 for (var s = whole; s < p.n2; s++) { sum += dy[s * p.n1 + j] * x[s * p.n0 + i]; }
66 gw[j * p.n0 + i] = sum;
67 WGSL
68  
69 # gb[j] = sum_s dy[s][j]
70 affine_gb => [ [qw(r:dy w:gb)], 1, <<'WGSL' ],
71 let j = id.x;
72 if (j >= p.n1) { return; }
73 var sum = 0.0;
74 for (var s = 0u; s < p.n2; s++) { sum += dy[s * p.n1 + j]; }
75 gb[j] = sum;
76 WGSL
77  
78 # dx[s][i] = sum_j w[j][i] dy[s][j]
79 affine_dx => [ [qw(r:dy r:w w:dx)], 2, <<'WGSL' ],
80 let i = id.x; let s = id.y;
81 if (i >= p.n0 || s >= p.n2) { return; }
82 var sum = 0.0;
83 for (var j = 0u; j < p.n1; j++) { sum += w[j * p.n0 + i] * dy[s * p.n1 + j]; }
84 dx[s * p.n0 + i] = sum;
85 WGSL
86  
87 # n0 elements, n1 the activation: 0 relu, 1 tanh, 2 sigmoid
88 activate => [ [qw(r:x w:y)], 1, <<'WGSL' ],
89 let i = id.x;
90 if (i >= p.n0) { return; }
91 let v = x[i];
92 if (p.n1 == 0u) { y[i] = max(v, 0.0); }
93 else if (p.n1 == 1u) { y[i] = tanh(v); }
94 else { y[i] = 1.0 / (1.0 + exp(-v)); }
95 WGSL
96  
97 activate_grad => [ [qw(r:y r:dy w:dx)], 1, <<'WGSL' ],
98 let i = id.x;
99 if (i >= p.n0) { return; }
100 let v = y[i];
101 if (p.n1 == 0u) { dx[i] = select(0.0, dy[i], v > 0.0); }
102 else if (p.n1 == 1u) { dx[i] = dy[i] * (1.0 - v * v); }
103 else { dx[i] = dy[i] * v * (1.0 - v); }
104 WGSL
105  
106 # y[n][k] = e[tok[n]][k] n0 dim, n1 tokens in the batch
107 embed => [ [qw(r:e u:tok w:y)], 1, <<'WGSL' ],
108 let i = id.x;
109 if (i >= p.n0 * p.n1) { return; }
110 y[i] = e[tok[i / p.n0] * p.n0 + i % p.n0];
111 WGSL
112  
113 # The token rows of a batch out of rows that are already on the card (see
114 # epoch_data): row s of the batch is row ord[start + s] of them all.
115 # n0 tokens per row, n1 start, n2 rows in the batch
116 rows_at => [ [qw(u:tok u:ord x:out)], 1, <<'WGSL' ],
117 let i = id.x;
118 if (i >= p.n0 * p.n2) { return; }
119 out[i] = tok[ord[p.n1 + i / p.n0] * p.n0 + i % p.n0];
120 WGSL
121  
122 # ge[v][k] = sum over the tokens equal to v of dx[n][k]. Written per table
123 # cell, not per token, so no two invocations ever write the same cell.
124 # (One invocation per table row, gathering the row in one pass over the
125 # tokens, is less work and five times slower: a hundred long loops do not
126 # fill a card, sixteen hundred short ones do.)
127 # The tokens are looked at four at a time; most fours hold no v at all.
128 embed_grad => [ [qw(u:tok r:dx w:ge)], 1, <<'WGSL' ],
129 let i = id.x;
130 if (i >= p.n0 * p.n2) { return; }
131 let v = i / p.n0; let k = i % p.n0;
132 var sum = 0.0;
133 let whole = (p.n1 / 4u) * 4u;
134 for (var n = 0u; n < whole; n += 4u) {
135 let hit = vec4<u32>(tok[n], tok[n + 1u], tok[n + 2u], tok[n + 3u]) == vec4<u32>(v);
136 if (any(hit)) {
137 if (hit.x) { sum += dx[n * p.n0 + k]; }
138 if (hit.y) { sum += dx[(n + 1u) * p.n0 + k]; }
139 if (hit.z) { sum += dx[(n + 2u) * p.n0 + k]; }
140 if (hit.w) { sum += dx[(n + 3u) * p.n0 + k]; }
141 }
142 }
143 for (var n = whole; n < p.n1; n++) { if (tok[n] == v) { sum += dx[n * p.n0 + k]; } }
144 ge[i] = sum;
145 WGSL
146  
147 # The same for rows on the card: class and weight of row s are those of
148 # row ord[start + s], and its loss is left at loss[start + s], on the card.
149 # n0 cols, n1 rows, n2 start
150 softmax_ce_at => [ [qw(r:z u:cls r:wt u:ord w:d w:loss)], 1, <<'WGSL' ],
151 let s = id.x;
152 if (s >= p.n1) { return; }
153 let at = s * p.n0;
154 let row = ord[p.n2 + s];
155 var top = z[at];
156 for (var i = 1u; i < p.n0; i++) { top = max(top, z[at + i]); }
157 var sum = 0.0;
158 for (var i = 0u; i < p.n0; i++) { sum += exp(z[at + i] - top); }
159 for (var i = 0u; i < p.n0; i++) { d[at + i] = exp(z[at + i] - top) / sum; }
160 let hit = at + cls[row];
161 loss[p.n2 + s] = -wt[row] * log(max(d[hit], 1e-37));
162 d[hit] -= 1.0;
163 for (var i = 0u; i < p.n0; i++) { d[at + i] *= wt[row]; }
164 WGSL
165  
166 # per row: d = softmax(z) - onehot(cls), loss = -log p[cls] n0 cols, n1 rows
167 softmax_ce => [ [qw(r:z u:cls r:wt w:d w:loss)], 1, <<'WGSL' ],
168 let s = id.x;
169 if (s >= p.n1) { return; }
170 let at = s * p.n0;
171 var top = z[at];
172 for (var i = 1u; i < p.n0; i++) { top = max(top, z[at + i]); }
173 var sum = 0.0;
174 for (var i = 0u; i < p.n0; i++) { sum += exp(z[at + i] - top); }
175 for (var i = 0u; i < p.n0; i++) { d[at + i] = exp(z[at + i] - top) / sum; }
176 let hit = at + cls[s];
177 loss[s] = -wt[s] * log(max(d[hit], 1e-37));
178 d[hit] -= 1.0;
179 for (var i = 0u; i < p.n0; i++) { d[at + i] *= wt[s]; }
180 WGSL
181  
182 mse => [ [qw(r:o r:t r:wt w:d w:loss)], 1, <<'WGSL' ],
183 let s = id.x;
184 if (s >= p.n1) { return; }
185 let at = s * p.n0;
186 var sum = 0.0;
187 for (var i = 0u; i < p.n0; i++) {
188 let diff = o[at + i] - t[at + i];
189 sum += diff * diff;
190 d[at + i] = wt[s] * 2.0 * diff / f32(p.n0);
191 }
192 loss[s] = wt[s] * sum / f32(p.n0);
193 WGSL
194  
195 # every value times f0: weight decay
196 decay => [ [qw(w:q)], 1, <<'WGSL' ],
197 let i = id.x;
198 if (i >= p.n0) { return; }
199 q[i] *= p.f0;
200 WGSL
201  
202 # f0 lr, f1 momentum, f2 scale
203 sgd => [ [qw(w:q r:g w:v)], 1, <<'WGSL' ],
204 let i = id.x;
205 if (i >= p.n0) { return; }
206 v[i] = p.f1 * v[i] - p.f0 * p.f2 * g[i];
207 q[i] += v[i];
208 WGSL
209  
210 # f0 rate, f1 beta1, f2 beta2, f3 epsilon, f4 scale
211 adam => [ [qw(w:q r:g w:m w:v)], 1, <<'WGSL' ],
212 let i = id.x;
213 if (i >= p.n0) { return; }
214 let grad = p.f4 * g[i];
215 m[i] = p.f1 * m[i] + (1.0 - p.f1) * grad;
216 v[i] = p.f2 * v[i] + (1.0 - p.f2) * grad * grad;
217 q[i] -= p.f0 * m[i] / (sqrt(v[i]) + p.f3);
218 WGSL
219 );
220  
221 my %ACCESS = (
222 r => 'var<storage, read> %s: array<f32>',
223 w => 'var<storage, read_write> %s: array<f32>',
224 u => 'var<storage, read> %s: array<u32>',
225 x => 'var<storage, read_write> %s: array<u32>',
226 );
227  
228 # One device and one set of compiled pipelines per process, however many
229 # networks use the backend. A forked child does not share its parent's: a
230 # device does not cross a fork, so the first backend made in a child opens
231 # the child's own. Tensors made before the fork stay the parent's.
232 my ($DEVICE, $OWNER, %PIPELINE, %PARAM_BUFFER);
233  
234 sub new ($class) {
235 die "no usable GPU adapter\n" if !Peta::WebGPU::have_gpu();
236 if (!$DEVICE || $OWNER != $$) {
237 (%PIPELINE, %PARAM_BUFFER) = ();
238 $DEVICE = Peta::WebGPU::Device->new(power => 'high-performance');
239 $OWNER = $$;
240 }
241 return bless {}, $class;
242 }
243  
244 sub name ($self) { return 'gpu' }
245  
246 sub adapter ($self) { return $DEVICE->info }
247  
248 # For other modules that compute on the card with shaders of their own, on
249 # this device and beside these operations: define() adds a shader under a
250 # name (bindings and body as in the table above, "x" being unsigned integers
251 # that are written), dispatch() runs one over a grid of invocations with up
252 # to eight integers in its parameter block, and buffer() puts bytes on the
253 # card, or reserves that many when given a number.
254 sub define ($self, $name, $bindings, $dims, $body, $functions = '') {
255 $SHADER{$name} //= [ $bindings, $dims, $body, $functions ];
256 return;
257 }
258  
259 sub dispatch ($self, $name, $buffers, $ints, $nx, $ny = 1) {
260 _run($name, $buffers, _params($ints), $nx, $ny);
261 return;
262 }
263  
264 sub buffer ($self, $content) { return $DEVICE->storage_buffer($content) }
265  
266 sub _pipeline ($name) {
267 return $PIPELINE{$name} //= do {
268 my ($bindings, $dims, $body, $functions) = @{ $SHADER{$name} };
269 my $slot = 0;
270 my $source = $PARAMS;
271 for my $binding (@$bindings) {
272 my ($access, $var) = split /:/, $binding;
273 $source .= sprintf "\@group(0) \@binding(%d) $ACCESS{$access};\n", $slot++, $var;
274 }
275 $source .= sprintf "\@group(0) \@binding(%d) var<uniform> p: Params;\n", $slot;
276 $source .= $functions // '';
277 $source .= sprintf "\@compute \@workgroup_size(%s)\n", $dims == 2 ? "$GROUP_2D, $GROUP_2D" : $GROUP_1D;
278 $source .= "fn main(\@builtin(global_invocation_id) id: vec3<u32>) {\n$body}\n";
279 [ $DEVICE->pipeline($DEVICE->shader($source), 'main'), $dims ];
280 };
281 }
282  
283 # The parameter block for a dispatch. Blocks of integers only (sizes) recur
284 # all the time and are kept; one with floats (an optimizer step) is new at
285 # every step and is not.
286 sub _params ($ints, $floats = undef) {
287 my $bytes = pack 'L8 f8', (@$ints, (0) x 8)[ 0 .. 7 ], (@{ $floats // [] }, (0) x 8)[ 0 .. 7 ];
288 return $DEVICE->uniform_buffer($bytes) if $floats;
289 return $PARAM_BUFFER{$bytes} //= $DEVICE->uniform_buffer($bytes);
290 }
291  
292 # Run a shader over a grid of $nx by $ny invocations.
293 sub _run ($name, $buffers, $params, $nx, $ny = 1) {
294 my ($pipeline, $dims) = @{ _pipeline($name) };
295 my $group = $dims == 2 ? $GROUP_2D : $GROUP_1D;
296 $DEVICE->run($pipeline, [ @$buffers, $params ],
297 int(($nx + $group - 1) / $group), $dims == 2 ? int(($ny + $group - 1) / $group) : 1);
298 return;
299 }
300  
301 sub _empty ($rows, $cols) {
302 return [ $DEVICE->storage_buffer($FLOAT_BYTES * $rows * $cols), $rows, $cols ];
303 }
304  
305 sub tensor ($self, $flat, $cols) {
306 return [ $DEVICE->storage_buffer(pack 'f*', @$flat), @$flat / $cols, $cols ];
307 }
308  
309 # [ buffer of unsigned indices, how many, how many per row ]
310 sub tokens ($self, $flat, $per_row) {
311 return [ $DEVICE->storage_buffer(pack 'L*', @$flat), scalar @$flat, $per_row ];
312 }
313  
314 sub flat ($self, $tensor) {
315 my ($buffer, $rows, $cols) = @$tensor;
316 return [ unpack 'f' . ($rows * $cols), $buffer->read ];
317 }
318  
319 sub zeros_like ($self, $tensor) { return _empty(@$tensor[ 1, 2 ]) }
320  
321 sub affine ($self, $X, $W, $b) {
322 my ($batch, $n_in) = @$X[ 1, 2 ];
323 my $n_out = $W->[1];
324 my $Y = _empty($batch, $n_out);
325 _run('affine', [ $X->[0], $W->[0], $b->[0], $Y->[0] ], _params([ $n_in, $n_out, $batch ]), int(($n_out + 3) / 4), $batch);
326 return $Y;
327 }
328  
329 sub affine_grad ($self, $X, $W, $dY, $need_dx) {
330 my ($batch, $n_in) = @$X[ 1, 2 ];
331 my $n_out = $W->[1];
332 my $params = _params([ $n_in, $n_out, $batch ]);
333 my $gW = _empty($n_out, $n_in);
334 my $gb = _empty(1, $n_out);
335 _run('affine_gw', [ $X->[0], $dY->[0], $gW->[0] ], $params, $n_in, $n_out);
336 _run('affine_gb', [ $dY->[0], $gb->[0] ], $params, $n_out);
337 return ($gW, $gb) if !$need_dx;
338 my $dX = _empty($batch, $n_in);
339 _run('affine_dx', [ $dY->[0], $W->[0], $dX->[0] ], $params, $n_in, $batch);
340 return ($gW, $gb, $dX);
341 }
342  
343 sub _kind ($kind) { return $KIND_CODE{$kind} // die "unknown activation '$kind'\n" }
344  
345 sub activate ($self, $kind, $X) {
346 my ($rows, $cols) = @$X[ 1, 2 ];
347 my $Y = _empty($rows, $cols);
348 _run('activate', [ $X->[0], $Y->[0] ], _params([ $rows * $cols, _kind($kind) ]), $rows * $cols);
349 return $Y;
350 }
351  
352 sub activate_grad ($self, $kind, $Y, $dY) {
353 my ($rows, $cols) = @$Y[ 1, 2 ];
354 my $dX = _empty($rows, $cols);
355 _run('activate_grad', [ $Y->[0], $dY->[0], $dX->[0] ], _params([ $rows * $cols, _kind($kind) ]), $rows * $cols);
356 return $dX;
357 }
358  
359 sub embed ($self, $E, $tokens) {
360 my $dim = $E->[2];
361 my ($buffer, $count, $per_row) = @$tokens;
362 my $Y = _empty($count / $per_row, $per_row * $dim);
363 _run('embed', [ $E->[0], $buffer, $Y->[0] ], _params([ $dim, $count ]), $count * $dim);
364 return $Y;
365 }
366  
367 sub embed_grad ($self, $E, $tokens, $dX) {
368 my ($vocab, $dim) = @$E[ 1, 2 ];
369 my $gE = _empty($vocab, $dim);
370 _run('embed_grad', [ $tokens->[0], $dX->[0], $gE->[0] ], _params([ $dim, $tokens->[1], $vocab ]), $vocab * $dim);
371 return $gE;
372 }
373  
374 # Both losses leave one loss per row on the card; reading those back is the
375 # one place a training step waits for the GPU.
376 sub _row_losses ($buffer, $rows) {
377 my $sum = 0;
378 $sum += $_ for unpack "f$rows", $buffer->read;
379 return $sum;
380 }
381  
382 # One weight per row for the losses; all ones when the caller gives none.
383 sub _row_weights ($weights, $rows) {
384 return $DEVICE->storage_buffer(pack 'f*', $weights ? @$weights : (1) x $rows);
385 }
386  
387 sub softmax_ce ($self, $logits, $classes, $weights = undef) {
388 my ($rows, $cols) = @$logits[ 1, 2 ];
389 my $d = _empty($rows, $cols);
390 my $loss = $DEVICE->storage_buffer($FLOAT_BYTES * $rows);
391 my $cls = $DEVICE->storage_buffer(pack 'L*', @$classes);
392 _run('softmax_ce', [ $logits->[0], $cls, _row_weights($weights, $rows), $d->[0], $loss ], _params([ $cols, $rows ]), $rows);
393 return (_row_losses($loss, $rows), $d);
394 }
395  
396 # --- an epoch that stays on the card --------------------------------------------
397 # What crosses the bus per training step is what limits a card: here the
398 # token rows, classes and weights of ALL the samples go up once
399 # (epoch_data), the order they are taken in once per epoch (epoch_order), a
400 # step picks its rows on the card (batch_at, softmax_ce_at), and the losses
401 # stay there until the epoch is over (epoch_loss).
402  
403 # All the samples of a training run: their token rows, classes and weights.
404 sub epoch_data ($self, $rows, $per_row, $classes, $weights = undef) {
405 my $count = @$classes;
406 return {
407 count => $count,
408 per_row => $per_row,
409 tokens => $DEVICE->storage_buffer(pack 'L*', @$rows),
410 classes => $DEVICE->storage_buffer(pack 'L*', @$classes),
411 weights => _row_weights($weights, $count),
412 };
413 }
414  
415 # The order the samples are taken in this epoch, and a clean slate of losses.
416 sub epoch_order ($self, $data, $order) {
417 $data->{order} = $DEVICE->storage_buffer(pack 'L*', @$order);
418 $data->{loss} = $DEVICE->storage_buffer($FLOAT_BYTES * $data->{count});
419 return;
420 }
421  
422 # The token rows of $count samples from position $start of the order, as
423 # embed() takes them.
424 sub batch_at ($self, $data, $start, $count) {
425 my $per_row = $data->{per_row};
426 my $rows = $DEVICE->storage_buffer(4 * $count * $per_row);
427 _run('rows_at', [ @$data{qw(tokens order)}, $rows ], _params([ $per_row, $start, $count ]), $count * $per_row);
428 return [ $rows, $count * $per_row, $per_row ];
429 }
430  
431 # The gradient of the loss of those samples; their losses stay on the card.
432 sub softmax_ce_at ($self, $logits, $data, $start) {
433 my ($rows, $cols) = @$logits[ 1, 2 ];
434 my $d = _empty($rows, $cols);
435 _run('softmax_ce_at', [ $logits->[0], @$data{qw(classes weights order)}, $d->[0], $data->{loss} ], _params([ $cols, $rows, $start ]), $rows);
436 return $d;
437 }
438  
439 # The summed loss of the epoch: the one read of the epoch.
440 sub epoch_loss ($self, $data) { return _row_losses($data->{loss}, $data->{count}) }
441  
442 sub mse ($self, $out, $targets, $weights = undef) {
443 my ($rows, $cols) = @$out[ 1, 2 ];
444 my $d = _empty($rows, $cols);
445 my $loss = $DEVICE->storage_buffer($FLOAT_BYTES * $rows);
446 my $want = $DEVICE->storage_buffer(pack 'f*', @$targets);
447 _run('mse', [ $out->[0], $want, _row_weights($weights, $rows), $d->[0], $loss ], _params([ $cols, $rows ]), $rows);
448 return (_row_losses($loss, $rows), $d);
449 }
450  
451 sub decay ($self, $P, $factor) {
452 my $count = $P->[1] * $P->[2];
453 _run('decay', [ $P->[0] ], _params([$count], [$factor]), $count);
454 return;
455 }
456  
457 sub sgd_update ($self, $P, $G, $V, $lr, $momentum, $scale) {
458 my $count = $P->[1] * $P->[2];
459 _run('sgd', [ $P->[0], $G->[0], $V->[0] ], _params([$count], [ $lr, $momentum, $scale ]), $count);
460 return;
461 }
462  
463 sub adam_update ($self, $P, $G, $M, $V, $rate, $b1, $b2, $eps, $scale) {
464 my $count = $P->[1] * $P->[2];
465 _run('adam', [ $P->[0], $G->[0], $M->[0], $V->[0] ], _params([$count], [ $rate, $b1, $b2, $eps, $scale ]), $count);
466 return;
467 }
468  
469 1;
470  
471 __END__