WGSL type system using phantom types for type safety. These types are used at the Lean level to ensure type correctness, but compile down to WGSL primitive types.
WGSL scalar types
- f32 : ScalarType
- f16 : ScalarType
- i32 : ScalarType
- u32 : ScalarType
- u64 : ScalarType
- bool : ScalarType
- atomicI32 : ScalarType
- atomicU32 : ScalarType
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Hesper.WGSL.instBEqScalarType.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Equations
Memory address spaces in WGSL
- storage : MemorySpace
- uniform : MemorySpace
- workgroup : MemorySpace
- priv : MemorySpace
- func : MemorySpace
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- Hesper.WGSL.instBEqMemorySpace.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
WGSL composite types
- scalar : ScalarType → WGSLType
- vec2 : ScalarType → WGSLType
- vec3 : ScalarType → WGSLType
- vec4 : ScalarType → WGSLType
- mat2x2 : ScalarType → WGSLType
- mat3x3 : ScalarType → WGSLType
- mat4x4 : ScalarType → WGSLType
- array : WGSLType → Nat → WGSLType
- runtimeArray : WGSLType → WGSLType
- bufferArray : WGSLType → Nat → WGSLType
Array of N separate runtime-sized storage buffers, indexed at runtime by layer index. Used for cross-layer kernel fusion: e.g. 42 layers of Q4_K weights accessed by the same kernel via
readBufferArray name layer elem. On CUDA lowers to a pointer-table constant in global memory; on WGSL lowers to abinding_array<...>(binding_array extension). - ptr : MemorySpace → WGSLType → WGSLType
- struct : String → WGSLType
- subgroupMatrixLeft : ScalarType → Nat → Nat → WGSLType
- subgroupMatrixRight : ScalarType → Nat → Nat → WGSLType
- subgroupMatrixResult : ScalarType → Nat → Nat → WGSLType
- texture2D : String → WGSLType
- sampler : WGSLType
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Hesper.WGSL.instReprWGSLType = { reprPrec := Hesper.WGSL.instReprWGSLType.repr }
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Struct field definition
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Buffer usage flags (corresponds to WebGPU buffer usage)
- storage : BufferUsage
- uniform : BufferUsage
- copy_src : BufferUsage
- copy_dst : BufferUsage
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- Hesper.WGSL.instBEqBufferUsage.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- Hesper.WGSL.instBEqLayoutRule.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Binding layout information for type-safe pipeline creation
- group : Nat
- binding : Nat
- type : WGSLType
- usage : BufferUsage
Instances For
Shader layout - collection of bindings with type information
- bindings : List BindingInfo
Instances For
Equations
- Hesper.WGSL.instInhabitedLayout.default = { bindings := default }
Instances For
Equations
Convert scalar type to WGSL string
Equations
- Hesper.WGSL.ScalarType.f32.toWGSL = "f32"
- Hesper.WGSL.ScalarType.f16.toWGSL = "f16"
- Hesper.WGSL.ScalarType.i32.toWGSL = "i32"
- Hesper.WGSL.ScalarType.u32.toWGSL = "u32"
- Hesper.WGSL.ScalarType.u64.toWGSL = "u64"
- Hesper.WGSL.ScalarType.bool.toWGSL = "bool"
- Hesper.WGSL.ScalarType.atomicI32.toWGSL = "atomic<i32>"
- Hesper.WGSL.ScalarType.atomicU32.toWGSL = "atomic<u32>"
Instances For
Convert memory space to WGSL string
Equations
- Hesper.WGSL.MemorySpace.storage.toWGSL = "storage"
- Hesper.WGSL.MemorySpace.uniform.toWGSL = "uniform"
- Hesper.WGSL.MemorySpace.workgroup.toWGSL = "workgroup"
- Hesper.WGSL.MemorySpace.priv.toWGSL = "private"
- Hesper.WGSL.MemorySpace.func.toWGSL = "function"
Instances For
Convert WGSL type to WGSL string
Equations
- One or more equations did not get rendered due to their size.
- (Hesper.WGSL.WGSLType.scalar a).toWGSL = a.toWGSL
- (Hesper.WGSL.WGSLType.vec2 a).toWGSL = toString "vec2<" ++ toString a.toWGSL ++ toString ">"
- (Hesper.WGSL.WGSLType.vec3 a).toWGSL = toString "vec3<" ++ toString a.toWGSL ++ toString ">"
- (Hesper.WGSL.WGSLType.vec4 a).toWGSL = toString "vec4<" ++ toString a.toWGSL ++ toString ">"
- (Hesper.WGSL.WGSLType.mat2x2 a).toWGSL = toString "mat2x2<" ++ toString a.toWGSL ++ toString ">"
- (Hesper.WGSL.WGSLType.mat3x3 a).toWGSL = toString "mat3x3<" ++ toString a.toWGSL ++ toString ">"
- (Hesper.WGSL.WGSLType.mat4x4 a).toWGSL = toString "mat4x4<" ++ toString a.toWGSL ++ toString ">"
- (a.array a_1).toWGSL = toString "array<" ++ toString a.toWGSL ++ toString ", " ++ toString a_1 ++ toString ">"
- a.runtimeArray.toWGSL = toString "array<" ++ toString a.toWGSL ++ toString ">"
- (a.bufferArray a_1).toWGSL = toString "binding_array<array<" ++ toString a.toWGSL ++ toString ">, " ++ toString a_1 ++ toString ">"
- (Hesper.WGSL.WGSLType.ptr a a_1).toWGSL = toString "ptr<" ++ toString a.toWGSL ++ toString ", " ++ toString a_1.toWGSL ++ toString ">"
- (Hesper.WGSL.WGSLType.struct a).toWGSL = a
- (Hesper.WGSL.WGSLType.texture2D a).toWGSL = toString "texture_2d<" ++ toString a ++ toString ">"
- Hesper.WGSL.WGSLType.sampler.toWGSL = "sampler"
Instances For
Byte size of a scalar type
Equations
- Hesper.WGSL.ScalarType.f32.byteSize = 4
- Hesper.WGSL.ScalarType.f16.byteSize = 2
- Hesper.WGSL.ScalarType.i32.byteSize = 4
- Hesper.WGSL.ScalarType.u32.byteSize = 4
- Hesper.WGSL.ScalarType.u64.byteSize = 8
- Hesper.WGSL.ScalarType.bool.byteSize = 4
- Hesper.WGSL.ScalarType.atomicI32.byteSize = 4
- Hesper.WGSL.ScalarType.atomicU32.byteSize = 4
Instances For
Calculate byte size of a type (for buffer allocation)
Equations
- (Hesper.WGSL.WGSLType.scalar a).byteSize = a.byteSize
- (Hesper.WGSL.WGSLType.vec2 a).byteSize = 2 * a.byteSize
- (Hesper.WGSL.WGSLType.vec3 a).byteSize = 3 * a.byteSize
- (Hesper.WGSL.WGSLType.vec4 a).byteSize = 4 * a.byteSize
- (Hesper.WGSL.WGSLType.mat2x2 a).byteSize = 4 * a.byteSize
- (Hesper.WGSL.WGSLType.mat3x3 a).byteSize = 9 * a.byteSize
- (Hesper.WGSL.WGSLType.mat4x4 a).byteSize = 16 * a.byteSize
- (a.array a_1).byteSize = a_1 * a.byteSize
- a.runtimeArray.byteSize = 0
- (a.bufferArray a_1).byteSize = 0
- (Hesper.WGSL.WGSLType.ptr a a_1).byteSize = 8
- (Hesper.WGSL.WGSLType.struct a).byteSize = 0
- (Hesper.WGSL.WGSLType.subgroupMatrixLeft a a_1 a_2).byteSize = a_1 * a_2 * a.byteSize
- (Hesper.WGSL.WGSLType.subgroupMatrixRight a a_1 a_2).byteSize = a_1 * a_2 * a.byteSize
- (Hesper.WGSL.WGSLType.subgroupMatrixResult a a_1 a_2).byteSize = a_1 * a_2 * a.byteSize
- (Hesper.WGSL.WGSLType.texture2D a).byteSize = 0
- Hesper.WGSL.WGSLType.sampler.byteSize = 0
Instances For
Alignment of a scalar type
Equations
- Hesper.WGSL.ScalarType.f32.alignment = 4
- Hesper.WGSL.ScalarType.f16.alignment = 2
- Hesper.WGSL.ScalarType.i32.alignment = 4
- Hesper.WGSL.ScalarType.u32.alignment = 4
- Hesper.WGSL.ScalarType.u64.alignment = 8
- Hesper.WGSL.ScalarType.bool.alignment = 4
- Hesper.WGSL.ScalarType.atomicI32.alignment = 4
- Hesper.WGSL.ScalarType.atomicU32.alignment = 4
Instances For
Calculate alignment of a type according to layout rules
Equations
- Hesper.WGSL.WGSLType.alignment rule (Hesper.WGSL.WGSLType.scalar a) = a.alignment
- Hesper.WGSL.WGSLType.alignment rule (Hesper.WGSL.WGSLType.vec2 a) = 2 * a.alignment
- Hesper.WGSL.WGSLType.alignment Hesper.WGSL.LayoutRule.std140 (Hesper.WGSL.WGSLType.vec3 a) = 16
- Hesper.WGSL.WGSLType.alignment Hesper.WGSL.LayoutRule.std430 (Hesper.WGSL.WGSLType.vec3 a) = 4 * a.alignment
- Hesper.WGSL.WGSLType.alignment rule (Hesper.WGSL.WGSLType.vec4 a) = 4 * a.alignment
- Hesper.WGSL.WGSLType.alignment rule (Hesper.WGSL.WGSLType.mat2x2 a) = 16
- Hesper.WGSL.WGSLType.alignment rule (Hesper.WGSL.WGSLType.mat3x3 a) = 16
- Hesper.WGSL.WGSLType.alignment rule (Hesper.WGSL.WGSLType.mat4x4 a) = 16
- Hesper.WGSL.WGSLType.alignment rule (a.array a_1) = Hesper.WGSL.WGSLType.alignment rule a
- Hesper.WGSL.WGSLType.alignment rule a.runtimeArray = Hesper.WGSL.WGSLType.alignment rule a
- Hesper.WGSL.WGSLType.alignment rule (a.bufferArray a_1) = Hesper.WGSL.WGSLType.alignment rule a
- Hesper.WGSL.WGSLType.alignment rule (Hesper.WGSL.WGSLType.ptr a a_1) = 8
- Hesper.WGSL.WGSLType.alignment rule (Hesper.WGSL.WGSLType.struct a) = 16
- Hesper.WGSL.WGSLType.alignment rule (Hesper.WGSL.WGSLType.subgroupMatrixLeft a a_1 a_2) = 16
- Hesper.WGSL.WGSLType.alignment rule (Hesper.WGSL.WGSLType.subgroupMatrixRight a a_1 a_2) = 16
- Hesper.WGSL.WGSLType.alignment rule (Hesper.WGSL.WGSLType.subgroupMatrixResult a a_1 a_2) = 16
- Hesper.WGSL.WGSLType.alignment rule (Hesper.WGSL.WGSLType.texture2D a) = 0
- Hesper.WGSL.WGSLType.alignment rule Hesper.WGSL.WGSLType.sampler = 0