omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / pytorch / kernels / addmm.om
| 1 | note addmm: o[M,N] = c[N] + a[M,K] @ b[K,N] (aten.addmm, beta 1, alpha 1, bias over rows), row-major |
| 2 | note f32. Each sum starts at the bias, is summed in f64 and rounded once to f32. |
| 3 | note The caller supplies const lines M K N MK KN MN before this text. |
| 4 | fn amdot c view f32 N a view f32 MK b view f32 KN i ulong j ulong to f64 |
| 5 | s = f64 get c j |
| 6 | ia = mul i K |
| 7 | rb = j |
| 8 | for k ulong K |
| 9 | s = add s mul f64 get a ia f64 get b rb |
| 10 | ia = add ia 1 |
| 11 | rb = add rb N |
| 12 | end |
| 13 | ret s |
| 14 | end |
| 15 | fn addmm c view f32 N a view f32 MK b view f32 KN o edit f32 MN to void |
| 16 | for i ulong M |
| 17 | for j ulong N |
| 18 | put o add mul i N j f32 amdot c a b i j |
| 19 | end |
| 20 | end |
| 21 | end |