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 / gpu / nvidia / checks / arest-bf16.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note gpu/nvidia/checks/arest-bf16.om: ar_bf16 (gpu/nvidia/om/apirest/bf16.om over apiviews/bf16.om) and artcperm |
| 3 | note (tcperm.om), as data_parts() and misc_parts() of CUDApp tests/api_rest_partitions.h call them. Composed |
| 4 | note before arestg.om. |
| 5 | text t_name "AREST-BF16" |
| 6 | text t_bf16 "bf16" |
| 7 | text t_tcperm "tcperm" |
| 8 | note the test's nine bit patterns |
| 9 | fn ax_bits k ulong to uint |
| 10 | if eq k 0 |
| 11 | ret 0 |
| 12 | end |
| 13 | if eq k 1 |
| 14 | ret 1 |
| 15 | end |
| 16 | if eq k 2 |
| 17 | ret 0x3f807fff |
| 18 | end |
| 19 | if eq k 3 |
| 20 | ret 0x3f808000 |
| 21 | end |
| 22 | if eq k 4 |
| 23 | ret 0x3f808001 |
| 24 | end |
| 25 | if eq k 5 |
| 26 | ret 0x7f800000 |
| 27 | end |
| 28 | if eq k 6 |
| 29 | ret 0x7f800001 |
| 30 | end |
| 31 | if eq k 7 |
| 32 | ret 0xfffffffe |
| 33 | end |
| 34 | ret 0xffffffff |
| 35 | end |
| 36 | note Q n and the output length; f[i] is pattern i % 9; output 0 the digest of the n bf16 |
| 37 | fn ax_bf16 q view ulong 256 nq ulong o edit ulong 256 to ulong |
| 38 | n = get q 0 |
| 39 | yl = get q 1 |
| 40 | if or or ne nq 2 gt n 36 gt yl 40 |
| 41 | ckbad |
| 42 | end |
| 43 | x = new f32 36 0.0f32 |
| 44 | for i ulong 36 |
| 45 | put x i bitcast f32 ax_bits rem i 9 |
| 46 | end |
| 47 | y = new ushort 40 0x5a5a |
| 48 | r = ar_bf16 part x 0 n part y 0 yl |
| 49 | if ne r 0 |
| 50 | ret r |
| 51 | end |
| 52 | h = ardg0 |
| 53 | for i ulong n bound 36 |
| 54 | h = ardg h ulong get y i |
| 55 | end |
| 56 | put o 0 h |
| 57 | ret r |
| 58 | end |
| 59 | note Q the fill (0: (float)(i % 17), 1: (float)(i * 3)), m, the output length; output 0 the digest of the m bf16 |
| 60 | fn ax_tcperm q view ulong 256 nq ulong o edit ulong 256 to ulong |
| 61 | m = get q 1 |
| 62 | yl = get q 2 |
| 63 | if or or ne nq 3 gt m 512 gt yl 512 |
| 64 | ckbad |
| 65 | end |
| 66 | x = new f32 512 0.0f32 |
| 67 | for i ulong 512 |
| 68 | if eq get q 0 0 |
| 69 | put x i f32 rem i 17 |
| 70 | else |
| 71 | put x i f32 mul i 3 |
| 72 | end |
| 73 | end |
| 74 | y = new ushort 512 0x5a5a |
| 75 | r = artcperm part x 0 m part y 0 yl |
| 76 | if ne r 0 |
| 77 | ret r |
| 78 | end |
| 79 | h = ardg0 |
| 80 | for i ulong m bound 512 |
| 81 | h = ardg h ulong get y i |
| 82 | end |
| 83 | put o 0 h |
| 84 | ret r |
| 85 | end |
| 86 | fn arop q view ulong 256 nq ulong ny ulong o edit ulong 256 to ulong |
| 87 | if ckis 0 t_bf16 |
| 88 | ret ax_bf16 q nq o |
| 89 | end |
| 90 | if ckis 0 t_tcperm |
| 91 | ret ax_tcperm q nq o |
| 92 | end |
| 93 | ckbad |
| 94 | ret 0 |
| 95 | end |