Neural Network/Brain/node_modules/gpu.js/src/gpu.js
/**
   *
   * Create a super kernel which executes sub kernels
   * and saves their output to be used with the next sub kernel.
   * This can be useful if we want to save the output on one kernel,
   * and then use it as an input to another kernel. *Machine Learning*
   *
   * @param {Object|Array} subKernels - Sub kernels for this kernel
   * @param {Function} rootKernel - Root kernel
   *
   * @returns {Function} callable kernel function
   *
   * @example
   * const megaKernel = gpu.createKernelMap({
   *   addResult: function add(a, b) {
   *     return a[this.thread.x] + b[this.thread.x];
   *   },
   *   multiplyResult: function multiply(a, b) {
   *     return a[this.thread.x] * b[this.thread.x];
   *   },
   *  }, function(a, b, c) {
   *       return multiply(add(a, b), c);
   * });
   *
   * megaKernel(a, b, c);
   *
   * Note: You can also define subKernels as an array of functions.
   * > [add, multiply]
   *
   */
Create a super kernel which executes sub kernels
and saves their output to be used with the next sub kernel.
This can be useful if we want to save the output on one kernel,
and then use it as an input to another kernel. *Machine Learning

@param {Object|Array} subKernels - Sub kernels for this kernel
@param {Function} rootKernel - Root kernel

@returns {Function} callable kernel function





You can also define subKernels as an array of functions.
> [add, multiply]
Create a super kernel which executes sub kernels and saves their output to be used with the next sub kernel . This can be useful if we want to save the output on one kernel and then use it as an input to another kernel . * Machine Learning @param { Object|Array } subKernels - Sub kernels for this kernel @param { Function } rootKernel - Root kernel @returns { Function } callable kernel function You can also define subKernels as an array of functions . > [ add multiply ]
createKernelMap() {
    let fn;
    let settings;
    if (typeof arguments[arguments.length - 2] === 'function') {
      fn = arguments[arguments.length - 2];
      settings = arguments[arguments.length - 1];
    } else {
      fn = arguments[arguments.length - 1];
    }
    if (this.mode !== 'dev') {
      if (!this.Kernel.isSupported || !this.Kernel.features.kernelMap) {
        if (this.mode && kernelTypes.indexOf(this.mode) < 0) {
          throw new Error(`kernelMap not supported on ${this.Kernel.name}`);
        }
      }
    }
    const settingsCopy = upgradeDeprecatedCreateKernelSettings(settings);
    if (settings && typeof settings.argumentTypes === 'object') {
      settingsCopy.argumentTypes = Object.keys(settings.argumentTypes).map(argumentName => settings.argumentTypes[argumentName]);
    }
    if (Array.isArray(arguments[0])) {
      settingsCopy.subKernels = [];
      const functions = arguments[0];
      for (let i = 0; i < functions.length; i++) {
        const source = functions[i].toString();
        const name = utils.getFunctionNameFromString(source);
        settingsCopy.subKernels.push({
          name,
          source,
          property: i,
        });
      }
    } else {
      settingsCopy.subKernels = [];
      const functions = arguments[0];
      for (let p in functions) {
        if (!functions.hasOwnProperty(p)) continue;
        const source = functions[p].toString();
        const name = utils.getFunctionNameFromString(source);
        settingsCopy.subKernels.push({
          name: name || p,
          source,
          property: p,
        });
      }
    }
    const kernel = this.createKernel(fn, settingsCopy);
    return kernel;
  }
createKernelMap ( ) { let fn ; let settings ; if ( typeof arguments [ arguments . length - 2 ] === 'function' ) { fn = arguments [ arguments . length - 2 ] ; settings = arguments [ arguments . length - 1 ] ; } else { fn = arguments [ arguments . length - 1 ] ; } if ( this . mode !== 'dev' ) { if ( ! this . Kernel . isSupported || ! this . Kernel . features . kernelMap ) { if ( this . mode && kernelTypes . indexOf ( this . mode ) < 0 ) { throw new Error ( ` ${ this . Kernel . name } ` ) ; } } } const settingsCopy = upgradeDeprecatedCreateKernelSettings ( settings ) ; if ( settings && typeof settings . argumentTypes === 'object' ) { settingsCopy . argumentTypes = Object . keys ( settings . argumentTypes ) . map ( argumentName => settings . argumentTypes [ argumentName ] ) ; } if ( Array . isArray ( arguments [ 0 ] ) ) { settingsCopy . subKernels = [ ] ; const functions = arguments [ 0 ] ; for ( let i = 0 ; i < functions . length ; i ++ ) { const source = functions [ i ] . toString ( ) ; const name = utils . getFunctionNameFromString ( source ) ; settingsCopy . subKernels . push ( { name , source , property : i , } ) ; } } else { settingsCopy . subKernels = [ ] ; const functions = arguments [ 0 ] ; for ( let p in functions ) { if ( ! functions . hasOwnProperty ( p ) ) continue ; const source = functions [ p ] . toString ( ) ; const name = utils . getFunctionNameFromString ( source ) ; settingsCopy . subKernels . push ( { name : name || p , source , property : p , } ) ; } } const kernel = this . createKernel ( fn , settingsCopy ) ; return kernel ; }
Create a super kernel which executes sub kernels
 and saves their output to be used with the next sub kernel.
Create a super kernel which executes sub kernels and saves their output to be used with the next sub kernel .
// handle conversion of argumentTypes