class

MicroGPT::Mat

Inherits Reference < Object

Constructors

new(rows : Int32, cols : Int32, data : Array(Float32))
Source
new(rows : Int32, cols : Int32, gpu_ptr : Pointer(Void))

GPU-resident constructor (no CPU data yet)

Source
new(rows : Int32, cols : Int32)
Source
randn(rows : Int32, cols : Int32, scale : Float64 = 1.0) : Mat
Source
zeros(rows : Int32, cols : Int32) : Mat
Source

Class methods

allocated_bytes
Source
max_bytes
Source
max_bytes=(limit : Int64)
Source

Instance methods

*(other : Mat) : Mat
Source
*(scalar : Float32) : Mat
Source
*(scalar : Float64) : Mat
Source
+(other : Mat) : Mat
Source
[](r : Int32, c : Int32) : Float32
Source
[]=(r : Int32, c : Int32, val : Float32)
Source
[]=(r : Int32, c : Int32, val : Float64)
Source
add!(other : Mat)
Source
byte_size
Source
cols
Source
cpu_valid?
Source
data

Access CPU data — triggers download from GPU if needed

Source
finalize
Source
free_gpu
Source
gpu_ptr
Source
gpu_valid?
Source
invalidate_gpu

Mark CPU data as modified

Source
mark_gpu_only

Mark GPU data as authoritative (used by backends after GPU computation)

Source
raw_data
Source
rows
Source
scale!(scalar : Float32)
Source
scale!(scalar : Float64)
Source
set_store_ptr(ptr : Pointer(Void))

Assign a GPU pointer from a WeightStore (no allocation, no free)

Source
store_backed
Source
store_backed=(store_backed : Bool)
Source
sync_to_cpu
Source
sync_to_gpu
Source
zero!
Source