omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / tests / arboris / gate-precision.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | fn main to int |
| 3 | coeff = new uint 64 0 |
| 4 | arboris_cubic_table coeff |
| 5 | error = f32 0 |
| 6 | worst = ulong 0 |
| 7 | for h ulong 65536 |
| 8 | if ne and h 0x7c00 0x7c00 |
| 9 | x = f32of f16to32 h |
| 10 | y = arboris_cubic_gate x coeff |
| 11 | if or lt y f32 0 gt y f32 1 |
| 12 | ret 1 |
| 13 | end |
| 14 | diff = fabs sub y ag_sigmoid x |
| 15 | if gt diff error |
| 16 | error = diff |
| 17 | worst = h |
| 18 | end |
| 19 | end |
| 20 | end |
| 21 | metrics = new uchar 8 0 |
| 22 | for i ulong 4 |
| 23 | put metrics i uchar and shr bitsof error mul 8 i 255 |
| 24 | put metrics add 4 i uchar and shr worst mul 8 i 255 |
| 25 | end |
| 26 | src = new ushort 32 0 |
| 27 | block = new uint 5 0 |
| 28 | put src 0 0x4700 |
| 29 | put src 1 0xc700 |
| 30 | put src 2 0x4100 |
| 31 | put src 3 0x4300 |
| 32 | if not arboris_q4_pack src block |
| 33 | ret 2 |
| 34 | end |
| 35 | if or ne arboris_q4_weight block 0 f32 7 ne arboris_q4_weight block 1 neg f32 7 |
| 36 | ret 3 |
| 37 | end |
| 38 | if or ne arboris_q4_weight block 2 f32 2 ne arboris_q4_weight block 3 f32 4 |
| 39 | ret 4 |
| 40 | end |
| 41 | put src 31 0x7e00 |
| 42 | if arboris_q4_pack src block |
| 43 | ret 5 |
| 44 | end |
| 45 | if ne write 1 metrics 0 8 8 |
| 46 | ret 6 |
| 47 | end |
| 48 | ret 0 |
| 49 | end |