16 lines
594 B
Plaintext
16 lines
594 B
Plaintext
// Definiujemy matematyczne zasady dla pamięci:
|
|
// Wymiar macierzy musi być większy od zera.
|
|
type ValidDim = i32{d | d > 0}
|
|
|
|
// Indeks wątku na GPU (thread_id) nie może być ujemny.
|
|
type SafeIndex = i32{i | i >= 0}
|
|
|
|
// Jądro GPU: Czysta funkcja, brak globalnego stanu, brak wyścigów danych!
|
|
gpu fn matmul_step(weight: f32, activation: f32, current_sum: f32) -> f32:
|
|
// Niewidzialny Borrow Checker konsumuje 'weight' i 'activation'
|
|
let product = weight * activation
|
|
|
|
// Konsumujemy 'current_sum' i 'product'
|
|
let new_sum = current_sum + product
|
|
|
|
return new_sum |