Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/gpu/nvidia/om/apiviews/bf16.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / gpu / nvidia / om / apiviews / bf16.om` 35 lines ยท 832 bytes Raw Blame History 1 om2 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 note f32 to bf16 over the live view. md 0 is round-to-nearest-even (payload-quiet NaN). 4 note md 1 is the gdn state_put rule: any NaN becomes 0x7fc0, sign cleared. 5 note 0x7fffffff `2147483647`, 0x7f800000 `2139095040`, 0x7fff 32767, 0x7fc0 32704. 6 fn av_rne u uint to uint 7 a = and u `2139095040` 8 if eq a `2139095040` 9 if ne and u `8388607` 0 10 ret or shr u 16 64 11 end 12 ret shr u 16 13 end 14 ret shr add add u 32767 and shr u 16 1 16 15 end 16 fn av_stbf u uint to uint 17 if gt and u `2147483647` `2139095040` 18 ret 32704 19 end 20 ret shr add add u 32767 and shr u 16 1 16 21 end 22 fn av_bf16 md ulong x view f32 * y edit ushort * to ulong 23 if ne len x len y 24 ret 1 25 end 26 for i ulong len x 27 u = bitcast uint get x i 28 if eq md 0 29 put y i ushort and av_rne u 65535 30 else 31 put y i ushort and av_stbf u 65535 32 end 33 end 34 ret 0 35 end