{"id":44794252,"url":"https://github.com/jongomez/wedge","last_synced_at":"2026-02-16T12:22:32.623Z","repository":{"id":330369541,"uuid":"1122527795","full_name":"jongomez/wedge","owner":"jongomez","description":"Machine Learning Framework","archived":false,"fork":false,"pushed_at":"2025-12-25T23:00:34.000Z","size":19739,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-26T13:43:41.465Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jongomez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-25T00:02:57.000Z","updated_at":"2025-12-25T23:00:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"586eaf12-1af4-43b4-bf56-2e96a7752cf5","html_url":"https://github.com/jongomez/wedge","commit_stats":null,"previous_names":["jongomez/wedge"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/jongomez/wedge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongomez%2Fwedge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongomez%2Fwedge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongomez%2Fwedge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongomez%2Fwedge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jongomez","download_url":"https://codeload.github.com/jongomez/wedge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongomez%2Fwedge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29507902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T09:05:14.864Z","status":"ssl_error","status_checked_at":"2026-02-16T08:55:59.364Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-16T12:22:31.921Z","updated_at":"2026-02-16T12:22:32.617Z","avatar_url":"https://github.com/jongomez.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wedge\n\nWedge is a web based machine learning framework.\n\n## What This Project Currently Does\n\nThe main focus at the moment is compiling and executing TensorFlow.js models\nusing custom GLSL shaders. Currently, this project:\n\n1. **Loads** TensorFlow.js GraphModel or LayersModel formats\n2. **Compiles** them into an internal graph representation\n3. **Executes** operations via custom WebGL2 fragment shaders\n4. **Uses textures** for efficient GPU tensor storage and computation\n\n## Goals\n\nThe main goals are:\n\n1. Be able to load other types of models - onnx, tflite, gguf and possibly more.\n2. Have a custom top level API for building / editing / debugging / machine\n   learning graphs.\n3. Support for different backends. While the current focus is WebGL2, an\n   Electron app that supports other backends (e.g. a C or C++ backend) is also\n   planned.\n\n## Project Structure\n\n```\nwedge/\n├── packages/\n│   ├── core/                 # @wedge/core - Main inference engine\n│   │   └── src/\n│   │       ├── backends/\n│   │       │   └── webgl/\n│   │       │       ├── WedgeWebGL.ts       # Main runtime class\n│   │       │       ├── ops/                # WebGL shader implementations\n│   │       │       │   ├── conv2D/         # 2D convolution\n│   │       │       │   ├── depthwiseConv2D/\n│   │       │       │   ├── relu/           # Activation\n│   │       │       │   ├── arithmetic/     # Add, multiply\n│   │       │       │   ├── ResizeBilinear/\n│   │       │       │   └── singleInputBasic/\n│   │       │       ├── buffersAndTextures.ts\n│   │       │       ├── setupShadersAndWebGL.ts\n│   │       │       └── types.ts\n│   │       ├── graph/\n│   │       │   ├── types.ts      # GraphNode, Graph interfaces\n│   │       │   ├── compile.ts    # Graph compilation\n│   │       │   └── transform.ts  # Graph optimizations\n│   │       ├── tensor/\n│   │       │   ├── TensorBase.ts\n│   │       │   └── TensorWebGL.ts\n│   │       ├── ops/\n│   │       │   └── types.ts      # Op parameter types\n│   │       ├── external/\n│   │       │   └── tensorflow/   # Vendored TF.js code for model loading\n│   │       └── types.ts          # Core type definitions\n│   └── ui-react/             # @wedge/ui-react - React components\n├── apps/\n│   ├── site/                 # Next.js demo/test application\n│   └── electron/             # Desktop app (WIP)\n└── benchmarks/               # Performance comparison app\n```\n\n## Key Concepts\n\n### WedgeWebGL Class (`packages/core/src/backends/webgl/WedgeWebGL.ts`)\n\nThe main runtime. Key properties:\n\n- `gl`: WebGL2RenderingContext\n- `originalGraph` / `compiledGraph`: Graph representations\n- `orderedNodes`: Execution order of operations\n- `opNodeWithProgramMap`: Maps operations to compiled WebGL programs\n\nKey methods:\n\n- `loadGraphModel(path)`: Load a TensorFlow.js model\n- `run(inputRawData)`: Execute inference, returns Float32Array\n- `readOutput()`: Read results from GPU textures\n\n### Graph System (`packages/core/src/graph/`)\n\n```typescript\n// GraphNode represents a single operation in the computation graph\ntype GraphNode = {\n  name: string;\n  op: { name: keyof Ops }; // Operation type (conv2d, relu, etc.)\n  inputs: GraphNode[]; // Input nodes\n  params: { [key: string]: GraphNodeParam };\n  children: GraphNode[];\n};\n\n// Graph is the full computation graph\ninterface Graph {\n  nodes: { [key: string]: GraphNode };\n  placeholders: GraphNode[]; // Model inputs\n  inputs: GraphNode[];\n  outputs: GraphNode[];\n  weights: GraphNode[];\n}\n```\n\n### Operations (`packages/core/src/ops/types.ts`)\n\nSupported operations:\n\n- `conv2d` - 2D convolution with optional ReLU fusion\n- `depthwiseConv2d` - Depthwise separable convolution\n- `relu` - ReLU activation\n- `resizeBilinear` - Image resizing\n- `add`, `multiply` - Element-wise arithmetic\n\nEach operation has:\n\n- `init.ts` - Setup and initialization\n- `output.ts` - Output texture configuration\n- `webGLShader.ts` - GLSL fragment shader code\n\n### Tensor System (`packages/core/src/tensor/`)\n\n- `TensorBase`: Abstract base class\n- `TensorWebGL`: WebGL-backed tensor stored as GPU textures\n\nData formats:\n\n- `NHWC`: Batch, Height, Width, Channels\n- `HWC`: Height, Width, Channels\n- `VEC`: Flat vector\n\n## How to Run\n\nThis is an npm workspaces monorepo.\n\n### Install Dependencies\n\n```bash\nnpm install\n```\n\n### Run Development Servers\n\n```bash\n# Main site app\nnpm run -w apps/site dev\n\n# Core package dev server (includes tests)\nnpm run -w packages/core dev\n\n# Benchmarks\nnpm run -w benchmarks dev\n```\n\n### Build\n\n```bash\nnpm run -w packages/core build\nnpm run -w apps/site build\n```\n\n### Lint\n\n```bash\nnpm run -w packages/core lint\n```\n\n## Architecture Flow\n\n1. **Model Loading**: TensorFlow.js model loaded via `loadGraphModel()`\n2. **Graph Construction**: Model converted to internal `Graph` representation\n3. **Compilation**: Graph nodes ordered for execution, WebGL programs created\n4. **Execution**: For each operation:\n   - Bind input textures\n   - Set shader uniforms\n   - Render to output texture (framebuffer)\n5. **Output**: Final texture read back to CPU as Float32Array\n\n## Key Files for Understanding the Codebase\n\n| File                                                         | Purpose                            |\n| ------------------------------------------------------------ | ---------------------------------- |\n| `packages/core/src/backends/webgl/WedgeWebGL.ts`             | Main runtime, execution loop       |\n| `packages/core/src/graph/types.ts`                           | Graph and node type definitions    |\n| `packages/core/src/ops/types.ts`                             | Operation interfaces and params    |\n| `packages/core/src/backends/webgl/ops/conv2D/webGLShader.ts` | Example shader implementation      |\n| `packages/core/src/backends/webgl/setupShadersAndWebGL.ts`   | WebGL context initialization       |\n| `packages/core/src/backends/webgl/buffersAndTextures.ts`     | Framebuffer and texture management |\n\n## Technology Stack\n\n- **Runtime**: TypeScript, WebGL2\n- **Framework**: React 19, Next.js 15\n- **ML**: TensorFlow.js 4.16 (for model loading/conversion)\n- **Testing**: react-browser-tests, Puppeteer\n\n## Status\n\nActive development. WebGL backend is functional. WebGPU backend is planned but\nnot yet implemented.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongomez%2Fwedge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjongomez%2Fwedge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongomez%2Fwedge/lists"}