English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

Appendix B of the Book 'Born': Full WGSL Shader Operator List for the WebGPU Backend

Forum topic · QianXun · 2026-06-13

Summary

This appendix from the serialized technical book 'Born' catalogs the WebGPU backend's embedded WGSL compute shaders: 53 shaders covering 9 operator categories. The element-wise binary operations (add, sub, mul, div) run with a workgroup size of 256. Unary operations include negation, exp, log, sqrt, ReLU, sigmoid, and SiLU. Matrix operations comprise a standard matmul shader at workgroup (16,16) and a batched matrix multiplication at (8,8,1). Convolution and pooling include 2D convolution and max pooling, both at (16,16). Reductions cover global sum, cross-workgroup sum, per-axis sum, and per-axis argmax. Comparison and logic shaders implement >, <, ==, != and boolean and/or/not. A dedicated tiled Flash Attention shader runs at workgroup (8,8,1). This is a concise reference for implementing a WebGPU/WGSL-based deep learning inference or training backend in JavaScript or TypeScript.

Born's WebGPU backend ships with 53 embedded WGSL compute shaders covering 9 operator categories. Below is the complete list from Appendix B of the book.

Element-wise Binary Operations (workgroup_size = 256)

| Shader | Expression | |--------|------------| | addShader | result[i] = a[i] + b[i] | | subShader | result[i] = a[i] - b[i] | | mulShader | result[i] = a[i] * b[i] | | divShader | result[i] = a[i] / b[i] |

Element-wise Unary Operations

| Shader | Expression | |--------|------------| | negShader | -a[i] | | expShader | exp(a[i]) | | logShader | log(a[i]) | | sqrtShader | sqrt(a[i]) | | reluShader | max(0.0, a[i]) | | sigmoidShader | 1.0 / (1.0 + exp(-a[i])) | | siluShader | a[i] / (1.0 + exp(-a[i])) |

Matrix Operations

| Shader | Workgroup | Description | |--------|-----------|-------------| | matmulShader | (16,16) | Standard matrix multiplication | | batchMatMulShader | (8,8,1) | Batched matrix multiplication |

Convolution and Pooling

| Shader | Workgroup | Description | |--------|-----------|-------------| | conv2dShader | (16,16) | 2D convolution | | maxPool2dShader | (16,16) | Max pooling |

Reductions

| Shader | Description | |--------|-------------| | sumShader | Global sum | | globalSumShader | Cross-workgroup sum | | sumDimShader | Sum along an axis | | argmaxShader | Argmax along an axis |

Comparison and Logic

| Shader | Description | |--------|-------------| | greaterShader, lowerShader | >, < | | equalShader, notEqualShader | ==, != | | andShader, orShader, notShader | Logical operations |

Flash Attention

| Shader | Workgroup | Description | |--------|-----------|-------------| | flashAttentionShader | (8,8,1) | Tiled Flash Attention |

---

Total: 53 shaders

📘 *Born* is a serialized technical book; this is Appendix B, part 4.

Tags

#webgpu#wgsl#compute-shaders#deep-learning#flash-attention#matrix-multiplication#gpu-computing#book-born

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/177981256