@@ -355,6 +355,18 @@ void ggml_fp32_to_fp16_row(const float * x, ggml_fp16_t * y, int n) {
355
355
}
356
356
}
357
357
358
+ static void ggml_i32_to_f32_row(const int32_t * x, float * y, int n) {
359
+ for (int i = 0; i < n; i++) {
360
+ y[i] = (float) x[i];
361
+ }
362
+ }
363
+
364
+ static void ggml_f32_to_i32_row(const float * x, int32_t * y, int n) {
365
+ for (int i = 0; i < n; i++) {
366
+ y[i] = (int32_t) x[i];
367
+ }
368
+ }
369
+
358
370
//
359
371
// timing
360
372
//
@@ -454,6 +466,9 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
454
466
.blck_size = 1,
455
467
.type_size = sizeof(int32_t),
456
468
.is_quantized = false,
469
+ .to_float = (ggml_to_float_t) ggml_i32_to_f32_row,
470
+ .from_float = (ggml_from_float_t) ggml_f32_to_i32_row,
471
+ .from_float_reference = (ggml_from_float_t) ggml_f32_to_i32_row,
457
472
},
458
473
[GGML_TYPE_F32] = {
459
474
.type_name = "f32",
@@ -469,10 +484,10 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
469
484
.blck_size = 1,
470
485
.type_size = sizeof(ggml_fp16_t),
471
486
.is_quantized = false,
472
- .to_float = (ggml_to_float_t) ggml_fp16_to_fp32_row,
487
+ .to_float = (ggml_to_float_t) ggml_fp16_to_fp32_row,
473
488
.from_float = (ggml_from_float_t) ggml_fp32_to_fp16_row,
474
489
.from_float_reference = (ggml_from_float_t) ggml_fp32_to_fp16_row,
475
- .vec_dot = (ggml_vec_dot_t) ggml_vec_dot_f16,
490
+ .vec_dot = (ggml_vec_dot_t) ggml_vec_dot_f16,
476
491
.vec_dot_type = GGML_TYPE_F16,
477
492
.nrows = 1,
478
493
},
@@ -481,8 +496,8 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
481
496
.blck_size = QK4_0,
482
497
.type_size = sizeof(block_q4_0),
483
498
.is_quantized = true,
484
- .to_float = (ggml_to_float_t) dequantize_row_q4_0,
485
- .from_float = quantize_row_q4_0,
499
+ .to_float = (ggml_to_float_t) dequantize_row_q4_0,
500
+ .from_float = (ggml_from_float_t) quantize_row_q4_0,
486
501
.from_float_reference = (ggml_from_float_t) quantize_row_q4_0_reference,
487
502
.vec_dot = ggml_vec_dot_q4_0_q8_0,
488
503
.vec_dot_type = GGML_TYPE_Q8_0,
@@ -497,8 +512,8 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
497
512
.blck_size = QK4_1,
498
513
.type_size = sizeof(block_q4_1),
499
514
.is_quantized = true,
500
- .to_float = (ggml_to_float_t) dequantize_row_q4_1,
501
- .from_float = quantize_row_q4_1,
515
+ .to_float = (ggml_to_float_t) dequantize_row_q4_1,
516
+ .from_float = (ggml_from_float_t) quantize_row_q4_1,
502
517
.from_float_reference = (ggml_from_float_t) quantize_row_q4_1_reference,
503
518
.vec_dot = ggml_vec_dot_q4_1_q8_1,
504
519
.vec_dot_type = GGML_TYPE_Q8_1,
@@ -537,8 +552,8 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
537
552
.blck_size = QK5_0,
538
553
.type_size = sizeof(block_q5_0),
539
554
.is_quantized = true,
540
- .to_float = (ggml_to_float_t) dequantize_row_q5_0,
541
- .from_float = quantize_row_q5_0,
555
+ .to_float = (ggml_to_float_t) dequantize_row_q5_0,
556
+ .from_float = (ggml_from_float_t) quantize_row_q5_0,
542
557
.from_float_reference = (ggml_from_float_t) quantize_row_q5_0_reference,
543
558
.vec_dot = ggml_vec_dot_q5_0_q8_0,
544
559
.vec_dot_type = GGML_TYPE_Q8_0,
@@ -549,8 +564,8 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
549
564
.blck_size = QK5_1,
550
565
.type_size = sizeof(block_q5_1),
551
566
.is_quantized = true,
552
- .to_float = (ggml_to_float_t) dequantize_row_q5_1,
553
- .from_float = quantize_row_q5_1,
567
+ .to_float = (ggml_to_float_t) dequantize_row_q5_1,
568
+ .from_float = (ggml_from_float_t) quantize_row_q5_1,
554
569
.from_float_reference = (ggml_from_float_t) quantize_row_q5_1_reference,
555
570
.vec_dot = ggml_vec_dot_q5_1_q8_1,
556
571
.vec_dot_type = GGML_TYPE_Q8_1,
@@ -561,8 +576,8 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
561
576
.blck_size = QK8_0,
562
577
.type_size = sizeof(block_q8_0),
563
578
.is_quantized = true,
564
- .to_float = (ggml_to_float_t) dequantize_row_q8_0,
565
- .from_float = quantize_row_q8_0,
579
+ .to_float = (ggml_to_float_t) dequantize_row_q8_0,
580
+ .from_float = (ggml_from_float_t) quantize_row_q8_0,
566
581
.from_float_reference = (ggml_from_float_t) quantize_row_q8_0_reference,
567
582
.vec_dot = ggml_vec_dot_q8_0_q8_0,
568
583
.vec_dot_type = GGML_TYPE_Q8_0,
@@ -577,7 +592,7 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
577
592
.blck_size = QK8_1,
578
593
.type_size = sizeof(block_q8_1),
579
594
.is_quantized = true,
580
- .from_float = quantize_row_q8_1,
595
+ .from_float = (ggml_from_float_t) quantize_row_q8_1,
581
596
.from_float_reference = (ggml_from_float_t) quantize_row_q8_1_reference,
582
597
.vec_dot_type = GGML_TYPE_Q8_1,
583
598
.nrows = 1,
@@ -587,8 +602,8 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
587
602
.blck_size = QK_K,
588
603
.type_size = sizeof(block_q2_K),
589
604
.is_quantized = true,
590
- .to_float = (ggml_to_float_t) dequantize_row_q2_K,
591
- .from_float = quantize_row_q2_K,
605
+ .to_float = (ggml_to_float_t) dequantize_row_q2_K,
606
+ .from_float = (ggml_from_float_t) quantize_row_q2_K,
592
607
.from_float_reference = (ggml_from_float_t) quantize_row_q2_K_reference,
593
608
.vec_dot = ggml_vec_dot_q2_K_q8_K,
594
609
.vec_dot_type = GGML_TYPE_Q8_K,
@@ -599,8 +614,8 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
599
614
.blck_size = QK_K,
600
615
.type_size = sizeof(block_q3_K),
601
616
.is_quantized = true,
602
- .to_float = (ggml_to_float_t) dequantize_row_q3_K,
603
- .from_float = quantize_row_q3_K,
617
+ .to_float = (ggml_to_float_t) dequantize_row_q3_K,
618
+ .from_float = (ggml_from_float_t) quantize_row_q3_K,
604
619
.from_float_reference = (ggml_from_float_t) quantize_row_q3_K_reference,
605
620
.vec_dot = ggml_vec_dot_q3_K_q8_K,
606
621
.vec_dot_type = GGML_TYPE_Q8_K,
@@ -611,8 +626,8 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
611
626
.blck_size = QK_K,
612
627
.type_size = sizeof(block_q4_K),
613
628
.is_quantized = true,
614
- .to_float = (ggml_to_float_t) dequantize_row_q4_K,
615
- .from_float = quantize_row_q4_K,
629
+ .to_float = (ggml_to_float_t) dequantize_row_q4_K,
630
+ .from_float = (ggml_from_float_t) quantize_row_q4_K,
616
631
.from_float_reference = (ggml_from_float_t) quantize_row_q4_K_reference,
617
632
.vec_dot = ggml_vec_dot_q4_K_q8_K,
618
633
.vec_dot_type = GGML_TYPE_Q8_K,
@@ -623,8 +638,8 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
623
638
.blck_size = QK_K,
624
639
.type_size = sizeof(block_q5_K),
625
640
.is_quantized = true,
626
- .to_float = (ggml_to_float_t) dequantize_row_q5_K,
627
- .from_float = quantize_row_q5_K,
641
+ .to_float = (ggml_to_float_t) dequantize_row_q5_K,
642
+ .from_float = (ggml_from_float_t) quantize_row_q5_K,
628
643
.from_float_reference = (ggml_from_float_t) quantize_row_q5_K_reference,
629
644
.vec_dot = ggml_vec_dot_q5_K_q8_K,
630
645
.vec_dot_type = GGML_TYPE_Q8_K,
@@ -635,8 +650,8 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
635
650
.blck_size = QK_K,
636
651
.type_size = sizeof(block_q6_K),
637
652
.is_quantized = true,
638
- .to_float = (ggml_to_float_t) dequantize_row_q6_K,
639
- .from_float = quantize_row_q6_K,
653
+ .to_float = (ggml_to_float_t) dequantize_row_q6_K,
654
+ .from_float = (ggml_from_float_t) quantize_row_q6_K,
640
655
.from_float_reference = (ggml_from_float_t) quantize_row_q6_K_reference,
641
656
.vec_dot = ggml_vec_dot_q6_K_q8_K,
642
657
.vec_dot_type = GGML_TYPE_Q8_K,
@@ -671,9 +686,9 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
671
686
.blck_size = QK_K,
672
687
.type_size = sizeof(block_iq3_xxs),
673
688
.is_quantized = true,
674
- .to_float = (ggml_to_float_t) dequantize_row_iq3_xxs,
675
- .from_float = quantize_row_iq3_xxs,
676
- .from_float_reference = (ggml_from_float_t)quantize_row_iq3_xxs_reference,
689
+ .to_float = (ggml_to_float_t) dequantize_row_iq3_xxs,
690
+ .from_float = (ggml_from_float_t) quantize_row_iq3_xxs,
691
+ .from_float_reference = (ggml_from_float_t) quantize_row_iq3_xxs_reference,
677
692
.vec_dot = ggml_vec_dot_iq3_xxs_q8_K,
678
693
.vec_dot_type = GGML_TYPE_Q8_K,
679
694
.nrows = 1,
@@ -695,9 +710,9 @@ static const ggml_type_traits_t type_traits[GGML_TYPE_COUNT] = {
695
710
.blck_size = QK4_NL,
696
711
.type_size = sizeof(block_iq4_nl),
697
712
.is_quantized = true,
698
- .to_float = (ggml_to_float_t) dequantize_row_iq4_nl,
699
- .from_float = quantize_row_iq4_nl,
700
- .from_float_reference = (ggml_from_float_t)quantize_row_iq4_nl_reference,
713
+ .to_float = (ggml_to_float_t) dequantize_row_iq4_nl,
714
+ .from_float = (ggml_from_float_t) quantize_row_iq4_nl,
715
+ .from_float_reference = (ggml_from_float_t) quantize_row_iq4_nl_reference,
701
716
.vec_dot = ggml_vec_dot_iq4_nl_q8_0,
702
717
.vec_dot_type = GGML_TYPE_Q8_0,
703
718
.nrows = 1,
0 commit comments