This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface ITestCaseSubject { | |
subject: string; | |
} | |
export interface IEachTestCase extends ITestCaseSubject { | |
each: Array<() => any>; | |
} | |
export type ArrayMoreThanOne<T> = [T, T, ...T[]]; | |
export function testPermutations(subjectCases: ArrayMoreThanOne<IEachTestCase>) { | |
function traverseAll( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[_a-zA-Z]+[_a-zA-Z0-9]*(?=[\(]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function kernel(settings) { | |
const { context, constants } = settings; | |
const gl = context; | |
const glVariables0 = gl.getExtension('OES_texture_float'); | |
const glVariables1 = gl.getExtension('OES_texture_float_linear'); | |
const glVariables2 = gl.getExtension('OES_element_index_uint'); | |
const glVariables3 = gl.getExtension('WEBGL_draw_buffers'); | |
const glVariables4 = gl.getExtension('WEBGL_color_buffer_float'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { GPU } = require('./src'); | |
const gpu = new GPU(); | |
// language=GLSL | |
const clz32 = `float clz32(float x) { | |
int _x = int(x); | |
_x -= bitwiseAnd(bitwiseSignedRightShift(_x, 1), ${0x55555555}); | |
_x = bitwiseAnd(bitwiseSignedRightShift(_x, 2), ${0x33333333}) + bitwiseAnd(_x, ${0x33333333}); | |
_x = bitwiseAnd((bitwiseSignedRightShift(_x, 4) + _x), ${0x0f0f0f0f}); | |
_x += bitwiseSignedRightShift(_x, 8); | |
_x += bitwiseSignedRightShift(_x, 16); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gpu = new GPU(); | |
const kernel = gpu.createKernel(function (baseImage, overlayImages, overlayImagesCount, overlayImagesSizes, offsets) { | |
const pixel = baseImage[this.thread.y][this.thread.x]; | |
for (let i = 0; i < overlayImagesCount; i++) { | |
const offset = offsets[i]; | |
const size = overlayImagesSizes[i]; | |
if (this.thread.x >= offset[0] && this.thread.x <= size[0] - offset[0]) { | |
if (this.thread.y >= offset[1] && this.thread.x <= size[1] - offset[1]) { | |
const mixPixel = overlayImagesCount[i][this.thread.y - offset[1]][this.thread.x - offset[0]]; | |
//mix mixPixel with pixel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { GPU } = require('gpu.js'); | |
const gpu = new GPU(); | |
// possible solution to confusing kernel maps | |
const kernel = gpu.createKernel(function(input1, input2) { | |
const value1 = input1[this.thread.z][this.thread.y][this.thread.x]; | |
const value2 = input1[this.thread.z][this.thread.y][this.thread.x]; | |
/* | |
up sides: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function kernel(settings) { | |
const { context, constants } = settings; | |
const gl = context; | |
const glVariables0 = gl.getExtension('OES_texture_float'); | |
const glVariables1 = gl.getExtension('OES_texture_float_linear'); | |
const glVariables2 = gl.getExtension('OES_element_index_uint'); | |
const glVariables3 = gl.getExtension('WEBGL_draw_buffers'); | |
const glVariables4 = gl.getExtension('WEBGL_color_buffer_float'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GPU { | |
createKernel<KF extends KernelFunction>(kernel: KF, settings?: IGPUKernelSettings): | |
((...args: Parameters<KF>) => | |
ReturnType<KF>[] | |
| ReturnType<KF>[][] | |
| ReturnType<KF>[][][] | |
| Texture | |
| void | |
) | |
& Kernel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const NeuralNetwork = require('./src/neural-network-gpu'); | |
const NeuralNetworkGPU = require('./src/neural-network-gpu'); | |
const { FeedForward } = require('./src/feed-forward'); | |
const { input, feedForward, target } = require('./src/layer'); | |
const { GPU } = require('gpu.js'); | |
const { setup } = require('./src/utilities/kernel'); | |
const { setLogInternalWeights, setLogInternalDeltas, setCheckWeights, setCheckDeltas } = require('./src/layer/debug/strict-watch'); | |
const xorTrainingData = [ | |
{ input: [0, 1], output: [1] }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// language=GLSL | |
const source = `// https://www.shadertoy.com/view/4t2SDh | |
//note: uniformly distributed, normalized rand, [0,1] | |
highp float randomSeedShift = 0.0; | |
highp float previousRandomSeedShift = 0.0; | |
bool flip = false; | |
const highp float factor = 9999.0; | |
uniform highp float randomSeed1; | |
uniform highp float randomSeed2; | |
highp float nrand(highp vec2 n) { |
NewerOlder