Skip to content

Commit

Permalink
Add outliers to test, remove static_assert
Browse files Browse the repository at this point in the history
  • Loading branch information
saharNooby committed Apr 19, 2023
1 parent eaf92f6 commit 5f52998
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/test_Q4_1_O.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ typedef struct {
uint8_t qs[QK4_1_O / 2];
} block_q4_1_o;

static_assert(sizeof(block_q4_1_o) == 8 + QK4_1_O / 2, "Wrong q4_1_o block size/padding");

int main(int argc, const char ** argv) {
GGML_ASSERT(sizeof(block_q4_1_o) == 8 + QK4_1_O / 2, "Wrong q4_1_o block size/padding");

// Needed to initialize FP16 lookup table
{
struct ggml_init_params params = { 0, NULL };
Expand Down Expand Up @@ -116,6 +116,11 @@ int main(int argc, const char ** argv) {
GGML_SET_ELEMENT_F32(mat, i, RANDOM_FLOAT());
}

// Add outliers
for (int i = 0; i < 4; i++) {
GGML_SET_ELEMENT_F32(mat, i * QK4_1_O + 1, RANDOM_FLOAT() * 100.0F);
}

struct ggml_tensor * quantized_mat = ggml_new_tensor_2d(ctx, GGML_TYPE_Q4_1_O, QK4_1_O, 4);

int64_t histogram[16];
Expand Down Expand Up @@ -152,7 +157,7 @@ int main(int argc, const char ** argv) {

float diff_average = diff_sum / 4;

GGML_ASSERT(diff_average <= 0.086357F, "Unexpected average difference value %f", diff_average);
GGML_ASSERT(diff_average <= 0.111999F, "Unexpected average difference value %f", diff_average);

ggml_print_objects(ctx);

Expand Down

0 comments on commit 5f52998

Please sign in to comment.