MCPcopy Create free account
hub / github.com/cactus-compute/cactus / test_neon_softmax_correctness

Function test_neon_softmax_correctness

tests/test_kernel.cpp:138–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138bool 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
162bool test_neon_rope_correctness() {

Callers 1

mainFunction · 0.85

Calls 3

cactus_softmax_f16Function · 0.85
sizeMethod · 0.80
dataMethod · 0.80

Tested by

no test coverage detected