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/bridge/core/test.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 / bridge / core / test.om` 218 lines ยท 5999 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note bridge/core/test.om: positive & negative control test suite for 3 note omega-bridge Native ABI v2 and ggml-omega tensor-bridge descriptor/op dispatch. 4 note Compose with: si/directives/om2.om bridge/core/abi_ggml.om bridge/core/test.om 5 6 text t_pass "PASS " 7 text t_fail "FAIL " 8 text t_nl "\n" 9 10 text t_c1 "abi_v2_param_slot_budget_and_overflow_controls" 11 text t_c2 "abi_v2_layout_bounds_and_field_disjointness" 12 text t_c3 "abi_v2_single_edit_aliasing_and_trap_status" 13 text t_c4 "ggml_row_bytes_and_q8_0_block_alignment" 14 text t_c5 "ggml_tensor_stride_validation_and_negative_controls" 15 text t_c6 "ggml_supports_op_dispatch_and_refusals" 16 text t_c7 "ggml_tile_plan_exact_reconstruction" 17 text t_done "PASS bridge-abi-ggml all 7 test suites passed\n" 18 19 fn report_case name view uchar * ok bool to int 20 if ok 21 w1 = br_write_all int 1 t_pass 22 w2 = br_write_all int 1 name 23 w3 = br_write_all int 1 t_nl 24 if and w1 and w2 w3 25 ret int 0 26 end 27 ret int 1 28 end 29 w4 = br_write_all int 1 t_fail 30 w5 = br_write_all int 1 name 31 w6 = br_write_all int 1 t_nl 32 if and w4 and w5 w6 33 ret int 1 34 end 35 ret int 1 36 end 37 38 fn test_slot_budget to bool 39 if ne br_check_param_slots ulong 2 ulong 0 ulong 2 BR_OK 40 ret false 41 end 42 if ne br_check_param_slots ulong 0 ulong 0 ulong 3 BR_OK 43 ret false 44 end 45 note Negative controls: 2 unsized views + 3 scalars = 7 slots (error 9 in omc) 46 if ne br_check_param_slots ulong 3 ulong 0 ulong 2 BR_ERR_SLOT_OVERFLOW 47 ret false 48 end 49 if ne br_check_param_slots ulong 7 ulong 0 ulong 0 BR_ERR_SLOT_OVERFLOW 50 ret false 51 end 52 ret true 53 end 54 55 fn test_layout_bounds to bool 56 if ne br_validate_layout_field ulong 64 ulong 0 ulong 8 ulong 4 BR_OK 57 ret false 58 end 59 if ne br_validate_layout_field ulong 64 ulong 32 ulong 4 ulong 8 BR_OK 60 ret false 61 end 62 note Negative controls: zero layout, >4096 layout, zero count, field OOB 63 if ne br_validate_layout_field ulong 0 ulong 0 ulong 4 ulong 1 BR_ERR_BAD_LAYOUT_SIZE 64 ret false 65 end 66 if ne br_validate_layout_field ulong 4097 ulong 0 ulong 4 ulong 1 BR_ERR_BAD_LAYOUT_SIZE 67 ret false 68 end 69 if ne br_validate_layout_field ulong 64 ulong 0 ulong 4 ulong 0 BR_ERR_BAD_FIELD_COUNT 70 ret false 71 end 72 if ne br_validate_layout_field ulong 64 ulong 60 ulong 8 ulong 1 BR_ERR_FIELD_OOB 73 ret false 74 end 75 if not br_spans_disjoint ulong 0 ulong 32 ulong 32 ulong 32 76 ret false 77 end 78 if br_spans_disjoint ulong 0 ulong 33 ulong 32 ulong 32 79 ret false 80 end 81 ret true 82 end 83 84 fn test_aliasing_and_traps to bool 85 if ne br_check_single_edit ulong 1000 ulong 64 ulong 1064 ulong 64 BR_OK 86 ret false 87 end 88 if ne br_check_single_edit ulong 1000 ulong 64 ulong 1032 ulong 64 BR_ERR_ALIAS_OVERLAP 89 ret false 90 end 91 if ne br_check_single_edit ulong 1000 ulong 64 ulong 1000 ulong 64 BR_ERR_ALIAS_OVERLAP 92 ret false 93 end 94 if ne br_check_exit_status ulong 0 BR_OK 95 ret false 96 end 97 if ne br_check_exit_status ulong 103 BR_ERR_OMEGA_TRAP 98 ret false 99 end 100 if ne br_check_exit_status ulong 114 BR_ERR_OMEGA_TRAP 101 ret false 102 end 103 if ne br_check_exit_status ulong 1 BR_ERR_HOST_FAILURE 104 ret false 105 end 106 ret true 107 end 108 109 fn test_ggml_row_bytes to bool 110 if ne ggml_row_bytes GGML_F32 ulong 128 ulong 512 111 ret false 112 end 113 if ne ggml_row_bytes GGML_F16 ulong 128 ulong 256 114 ret false 115 end 116 if ne ggml_row_bytes GGML_Q8_0 ulong 64 ulong 68 117 ret false 118 end 119 note Negative controls: misaligned Q8_0 (not multiple of 32), zero ne0, unknown dtype 120 if ne ggml_row_bytes GGML_Q8_0 ulong 33 ulong 0 121 ret false 122 end 123 if ne ggml_row_bytes GGML_F32 ulong 0 ulong 0 124 ret false 125 end 126 if ne ggml_row_bytes ulong 99 ulong 32 ulong 0 127 ret false 128 end 129 ret true 130 end 131 132 fn test_ggml_strides to bool 133 if ne ggml_validate_tensor GGML_F32 ulong 64 ulong 4 ulong 4 ulong 256 BR_OK 134 ret false 135 end 136 if ne ggml_validate_tensor GGML_Q8_0 ulong 64 ulong 4 ulong 34 ulong 68 BR_OK 137 ret false 138 end 139 note Negative controls: nb1 < row_bytes (overlapping rows!), nb0 < elem_size, misaligned Q8_0 140 if ne ggml_validate_tensor GGML_F32 ulong 64 ulong 4 ulong 4 ulong 200 BR_ERR_BAD_STRIDE 141 ret false 142 end 143 if ne ggml_validate_tensor GGML_F32 ulong 64 ulong 4 ulong 2 ulong 256 BR_ERR_BAD_STRIDE 144 ret false 145 end 146 if ne ggml_validate_tensor GGML_Q8_0 ulong 30 ulong 4 ulong 34 ulong 68 BR_ERR_BAD_BLOCK_ALIGN 147 ret false 148 end 149 if ne ggml_validate_tensor ulong 77 ulong 64 ulong 4 ulong 4 ulong 256 BR_ERR_BAD_DTYPE 150 ret false 151 end 152 ret true 153 end 154 155 fn test_ggml_ops to bool 156 if ne ggml_supports_op GGML_OP_ADD GGML_F32 GGML_F32 GGML_F32 ulong 64 BR_OK 157 ret false 158 end 159 if ne ggml_supports_op GGML_OP_MUL_MAT GGML_Q8_0 GGML_F32 GGML_F32 ulong 256 BR_OK 160 ret false 161 end 162 if ne ggml_supports_op GGML_OP_MUL_MAT GGML_F16 GGML_F32 GGML_F32 ulong 128 BR_OK 163 ret false 164 end 165 if ne ggml_supports_op GGML_OP_CPY GGML_Q8_0 GGML_F32 GGML_F32 ulong 64 BR_OK 166 ret false 167 end 168 note Negative controls: F16 ADD unsupported, CPY to Q8_0 unsupported, misaligned Q8_0 MUL_MAT, unknown op 169 if ne ggml_supports_op GGML_OP_ADD GGML_F16 GGML_F16 GGML_F16 ulong 64 BR_ERR_UNSUPPORTED_OP 170 ret false 171 end 172 if ne ggml_supports_op GGML_OP_CPY GGML_F32 GGML_F32 GGML_Q8_0 ulong 64 BR_ERR_UNSUPPORTED_OP 173 ret false 174 end 175 if ne ggml_supports_op GGML_OP_MUL_MAT GGML_Q8_0 GGML_F32 GGML_F32 ulong 30 BR_ERR_BAD_BLOCK_ALIGN 176 ret false 177 end 178 if ne ggml_supports_op ulong 99 GGML_F32 GGML_F32 GGML_F32 ulong 64 BR_ERR_UNSUPPORTED_OP 179 ret false 180 end 181 ret true 182 end 183 184 fn test_ggml_tiling to bool 185 plan = new ulong 2 0 186 if ne ggml_tile_plan ulong 100 ulong 32 plan BR_OK 187 ret false 188 end 189 if or ne get plan 0 ulong 3 ne get plan 1 ulong 4 190 ret false 191 end 192 if ne add mul get plan 0 ulong 32 get plan 1 ulong 100 193 ret false 194 end 195 if ne ggml_tile_plan ulong 100 ulong 0 plan BR_ERR_BAD_TILE 196 ret false 197 end 198 ret true 199 end 200 201 fn main to int 202 fail = int 0 203 fail = add fail report_case t_c1 test_slot_budget 204 fail = add fail report_case t_c2 test_layout_bounds 205 fail = add fail report_case t_c3 test_aliasing_and_traps 206 fail = add fail report_case t_c4 test_ggml_row_bytes 207 fail = add fail report_case t_c5 test_ggml_strides 208 fail = add fail report_case t_c6 test_ggml_ops 209 fail = add fail report_case t_c7 test_ggml_tiling 210 if ne fail int 0 211 ret int 1 212 end 213 ok = br_write_all int 1 t_done 214 if not ok 215 ret int 1 216 end 217 ret int 0 218 end