Skip to content

Instantly share code, notes, and snippets.

View robertleeplummerjr's full-sized avatar

Robert Plummer robertleeplummerjr

View GitHub Profile
const { GPU } = require('gpu.js');
const gpu = new GPU({ mode: 'gpu' });
const a = [1, 2, 3, 4, 5];
const b = [1, 2, 3, 4, 5];
const kernels = gpu.createKernel(function(a, b) {
let sum = 0;
for (let i = 0; i < 5; i++) {
sum += a[i] + b[i];
}
//
// Copyright(c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// entry_points_gles_2_0_ext.cpp : Implements the GLES 2.0 extension entry points.
#include "libGLESv2/entry_points_gles_2_0_ext.h"
#include "libGLESv2/global_state.h"
@robertleeplummerjr
robertleeplummerjr / draw-buffers-google-angle.cc
Last active February 24, 2019 18:27
DrawBuffers WebGL, WebGL2, HeadlessGL, GoogleAngle
// works good
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <node.h>
#include "nan.h"
#include <v8.h>
// at end of list of items that call "JS_GL_METHOD"
JS_GL_METHOD("drawBuffers", DrawBuffers);
JS_GL_METHOD("extWEBGL_draw_buffers", EXTWEBGL_draw_buffers);
@robertleeplummerjr
robertleeplummerjr / original-fragment.glsl
Last active December 29, 2018 20:38
headless-gl bug
precision highp float;
precision highp int;
precision highp sampler2D;
uniform ivec3 uOutputDim;
uniform ivec2 uTexSize;
varying vec2 vTexCoord;
const vec4 SCALE_FACTOR_INV = vec4(1.0, 0.00390625, 0.0000152587890625, 0.0); // 1, 1/256, 1/65536
vec2 integerMod(vec2 x, float y) {
"scripts": {
"format": "clang-format -i -style=Google binding/*.cc binding/*.h",
"install": "node scripts/install.js && npm run build",
"build": "tsc -p ."
},
const createContext = require('gl');
function main () {
// Create context
var width = 6;
var height = 1;
var gl = createContext(width, height);
var vertexSrc = `precision highp float;
precision highp int;
module.exports = () => {
function kernelRunShortcut(kernel) {
const shortcut = function() {
return kernel.run.apply(kernel, arguments);
};
utils.allPropertiesOf(kernel).forEach((key) => {
if (key[0] === '_' && key[1] === '_') return;
if (typeof kernel[key] === 'function') {
if (key.substring(0, 3) === 'add' || key.substring(0, 3) === 'set') {
class Item {
public static async get<Options extends { id: string }>(o: Options, api: Api): Promise<Item> {
return new Promise<Item>((accept, reject) => {
console.log(api);
accept(new Item());
});
}
public static async search<Options extends { query: string }>(o: Options, api: Api): Promise<Item[]> {
return new Promise<Item[]>((accept, reject) => {
console.log(api);
@robertleeplummerjr
robertleeplummerjr / RNN Time Series Training Data Shapes.md
Last active August 28, 2019 23:46
Fixing brain.js's RNNTimeStep for practicality

Example 1, numeric linear

input/output size = 1. Read by brain.js as:

  • 1, then 2, then 3, then 4, then 5
  • 5, then 4, then 3, then 2, then 1

training:

net.train([
 [1,2,3,4,5],