| 136 | } |
| 137 | |
| 138 | bool test_neon_softmax_correctness() { |
| 139 | const size_t batch_size = 1, seq_len = 4, vocab_size = 3; |
| 140 | std::vector<__fp16> input = {1.0f, 2.0f, 3.0f, |
| 141 | 2.0f, 3.0f, 4.0f, |
| 142 | 3.0f, 4.0f, 5.0f, |
| 143 | 4.0f, 5.0f, 6.0f}; |
| 144 | std::vector<__fp16> result(input.size()); |
| 145 | |
| 146 | cactus_softmax_f16(input.data(), result.data(), batch_size, seq_len, vocab_size); |
| 147 | |
| 148 | for (size_t i = 0; i < seq_len; ++i) { |
| 149 | float row_sum = 0.0f; |
| 150 | for (size_t j = 0; j < vocab_size; ++j) { |
| 151 | row_sum += static_cast<float>(result[i * vocab_size + j]); |
| 152 | } |
| 153 | if (std::abs(row_sum - 1.0f) > 1e-2f) { |
| 154 | return false; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | return true; |
| 159 | } |
| 160 | |
| 161 | |
| 162 | bool test_neon_rope_correctness() { |
no test coverage detected