Neural Network/Brain/node_modules/gpu.js/src/gpu.js
/**
   *
   * Combine different kernels into one super Kernel,
   * useful to perform multiple operations inside one
   * kernel without the penalty of data transfer between
   * cpu and gpu.
   *
   * The number of kernel functions sent to this method can be variable.
   * You can send in one, two, etc.
   *
   * @param {Function} subKernels - Kernel function(s) to combine.
   * @param {Function} rootKernel - Root kernel to combine kernels into
   *
   * @example
   *   combineKernels(add, multiply, function(a,b,c){
   *     return add(multiply(a,b), c)
   *  })
   *
   * @returns {Function} Callable kernel function
   *
   */
Combine different kernels into one super Kernel,
useful to perform multiple operations inside one
kernel without the penalty of data transfer between
cpu and gpu.

The number of kernel functions sent to this method can be variable.
You can send in one, two, etc.

@param {Function} subKernels - Kernel function(s) to combine.
@param {Function} rootKernel - Root kernel to combine kernels into



@returns {Function} Callable kernel function
Combine different kernels into one super Kernel useful to perform multiple operations inside one kernel without the penalty of data transfer between cpu and gpu . The number of kernel functions sent to this method can be variable . You can send in one two etc . @param { Function } subKernels - Kernel function ( s ) to combine . @param { Function } rootKernel - Root kernel to combine kernels into @returns { Function } Callable kernel function
combineKernels() {
    const firstKernel = arguments[0];
    const combinedKernel = arguments[arguments.length - 1];
    if (firstKernel.kernel.constructor.mode === 'cpu') return combinedKernel;
    const canvas = arguments[0].canvas;
    const context = arguments[0].context;
    const max = arguments.length - 1;
    for (let i = 0; i < max; i++) {
      arguments[i]
        .setCanvas(canvas)
        .setContext(context)
        .setPipeline(true);
    }
    return function() {
      const texture = combinedKernel.apply(this, arguments);
      if (texture.toArray) {
        return texture.toArray();
      }
      return texture;
    };
  }
combineKernels ( ) { const firstKernel = arguments [ 0 ] ; const combinedKernel = arguments [ arguments . length - 1 ] ; if ( firstKernel . kernel . constructor . mode === 'cpu' ) return combinedKernel ; const canvas = arguments [ 0 ] . canvas ; const context = arguments [ 0 ] . context ; const max = arguments . length - 1 ; for ( let i = 0 ; i < max ; i ++ ) { arguments [ i ] . setCanvas ( canvas ) . setContext ( context ) . setPipeline ( true ) ; } return function ( ) { const texture = combinedKernel . apply ( this , arguments ) ; if ( texture . toArray ) { return texture . toArray ( ) ; } return texture ; } ; }
Combine different kernels into one super Kernel,
 useful to perform multiple operations inside one
 kernel without the penalty of data transfer between
 cpu and gpu.
Combine different kernels into one super Kernel useful to perform multiple operations inside one kernel without the penalty of data transfer between cpu and gpu .