chickadee » array-morphisms-crunch » make-crunch-threaded-activation-backend

make-crunch-activation-backendprocedure
make-crunch-threaded-activation-backendprocedure

Return an activation backend for register-activation-backend!. The threaded backend splits large arrays across threads. Its results are the same as those of the unthreaded one. Both register the binary ops add, sub, mul and div with register-binary-op!.

A backend holds f32 and f64 kernels for:

  • the activations relu, sigmoid and tanh and their derivative ops relu-deriv, sigmoid-deriv and tanh-deriv;
  • exp, log, sqrt, negate and abs;
  • the binary ops add, sub, mul and div, also broadcast by row, column or scalar;
  • sums, means, maxima and minima of row-major 2-D arrays over axis 0 or 1, rounded exactly as the Scheme loops round them;
  • scans (sum, prod, max, min) of row-major arrays along any axis; a scan along the last axis runs 8 lines together;
  • copies of strided views of rank at most 4 into row-major order;
  • fused kernels for the bodies that the fusion pass of array-morphisms forms most often (below).

The kernels are generated from the scalar-op table of array-morphisms, which also supplies the Scheme combiners, so each kernel uses the same formula. log and sqrt of a negative number give NaN, where Scheme gives a complex number.

Each kernel is also exported on its own, as crunch-<op>-f32 and crunch-<op>-f64, a procedure (size in out).