struct

ML::Metal::ComputeEncoder

Inherits Struct / Value / Object

Compute encoder for setting up kernel dispatch

Constructors

new(command_buffer : CommandBuffer, concurrent : Bool = false)
Source

Instance methods

dispatch(grid_size : Tuple(Int32, Int32, Int32), threadgroup_size : Tuple(Int32, Int32, Int32)) : self

Dispatch with explicit grid/threadgroup sizes (total threads)

Source
dispatch_1d(count : Int32, threadgroup_size : Int32 = 256) : self

Dispatch 1D workload

Source
dispatch_2d(width : Int32, height : Int32, threadgroup_size : Tuple(Int32, Int32) = {16, 16}) : self

Dispatch 2D workload (e.g., images)

Source
dispatch_3d(width : Int32, height : Int32, depth : Int32, threadgroup_size : Tuple(Int32, Int32, Int32) = {8, 8, 8}) : self

Dispatch 3D workload

Source
dispatch_threadgroups(threadgroup_count : Tuple(Int32, Int32, Int32), threadgroup_size : Tuple(Int32, Int32, Int32)) : self

Dispatch with threadgroup count (not total threads)

Source
dispatch_threadgroups_indirect(indirect_buffer : ML::MetalBuffer, offset : Int64, threadgroup_size : Tuple(Int32, Int32, Int32)) : self

Indirect dispatch — threadgroup counts come from GPU buffer

Source
end_encoding

End encoding

Source
memory_barrier

Insert memory barrier between dependent dispatches (concurrent encoder only)

Source
set_buffer(buffer : MetalBuffer, index : Int32, access : BufferAccess = BufferAccess::Read, offset : Int64 = 0, length : Int64 = -1, partition : Int32 = -1) : self

Bind Metal buffer at index (access/length/partition accepted for GraphEncoder API compat)

Source
set_bytes(data : Pointer(Void), length : Int32, index : Int32) : self

Bind raw bytes (for small constants)

Source
set_pipeline(pipeline : ComputePipeline) : self
Source
set_tensor(tensor : Tensor, index : Int32) : self

Bind tensor's underlying buffer

Source
set_threadgroup_memory(length : Int32, index : Int32) : self

Set threadgroup memory (for kernels using threadgroup storage)

Source
set_value(value : Float32, index : Int32) : self

Bind scalar value

Source
set_value(value : Int32, index : Int32) : self
Source
set_value(value : UInt32, index : Int32) : self
Source
set_value(value : StaticArray(Float32, 3), index : Int32) : self

Set float3 (as StaticArray(Float32, 3))

Source
set_value(value : StaticArray(Float32, 4), index : Int32) : self

Set float4 (as StaticArray(Float32, 4))

Source