metal : dequantize q8_0 using packed types (#27370)
This commit is contained in:
@@ -656,13 +656,13 @@ void dequantize_q5_1_t4(device const block_q5_1 * xb, short il, thread type4 & r
|
|||||||
|
|
||||||
template <typename type4x4>
|
template <typename type4x4>
|
||||||
void dequantize_q8_0(device const block_q8_0 *xb, short il, thread type4x4 & reg) {
|
void dequantize_q8_0(device const block_q8_0 *xb, short il, thread type4x4 & reg) {
|
||||||
device const int8_t * qs = ((device const int8_t *)xb->qs);
|
device const packed_char4 * qs = (device const packed_char4 *) xb->qs;
|
||||||
const float d = xb->d;
|
const float d = xb->d;
|
||||||
|
|
||||||
float4x4 reg_f;
|
float4x4 reg_f;
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
reg_f[i/4][i%4] = (qs[i + 16*il] * d);
|
reg_f[i] = float4(qs[4*il + i]) * d;
|
||||||
}
|
}
|
||||||
|
|
||||||
reg = (type4x4) reg_f;
|
reg = (type4x4) reg_f;
|
||||||
@@ -670,12 +670,10 @@ void dequantize_q8_0(device const block_q8_0 *xb, short il, thread type4x4 & reg
|
|||||||
|
|
||||||
template <typename type4>
|
template <typename type4>
|
||||||
void dequantize_q8_0_t4(device const block_q8_0 *xb, short il, thread type4 & reg) {
|
void dequantize_q8_0_t4(device const block_q8_0 *xb, short il, thread type4 & reg) {
|
||||||
device const int8_t * qs = ((device const int8_t *)xb->qs);
|
device const packed_char4 * qs = (device const packed_char4 *) xb->qs;
|
||||||
const float d = xb->d;
|
const float d = xb->d;
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
reg = (type4) (float4(qs[il]) * d);
|
||||||
reg[i] = (qs[4*(il%4) + i + 16*(il/4)] * d);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename type4x4>
|
template <typename type4x4>
|
||||||
|
|||||||
Reference in New Issue
Block a user