ggerganov commited on
Commit
99d668a
·
1 Parent(s): fd57e47

metal : tune soft_max number of threads (#0)

Browse files
Files changed (1) hide show
  1. ggml-metal.m +2 -2
ggml-metal.m CHANGED
@@ -1378,7 +1378,7 @@ static enum ggml_status ggml_metal_graph_compute(
1378
  const bool use_f16 = (src1 && src1->type == GGML_TYPE_F16);
1379
 
1380
  if (ne00%4 == 0) {
1381
- while (nth < ne00/4 && nth < 256) {
1382
  nth *= 2;
1383
  }
1384
  if (use_f16) {
@@ -1387,7 +1387,7 @@ static enum ggml_status ggml_metal_graph_compute(
1387
  pipeline = ctx->kernels[GGML_METAL_KERNEL_TYPE_SOFT_MAX_F32_4].pipeline;
1388
  }
1389
  } else {
1390
- while (nth < ne00 && nth < 1024) {
1391
  nth *= 2;
1392
  }
1393
  if (use_f16) {
 
1378
  const bool use_f16 = (src1 && src1->type == GGML_TYPE_F16);
1379
 
1380
  if (ne00%4 == 0) {
1381
+ while (nth < ne00/4 && nth*ne01*ne02*ne03 < 256) {
1382
  nth *= 2;
1383
  }
1384
  if (use_f16) {
 
1387
  pipeline = ctx->kernels[GGML_METAL_KERNEL_TYPE_SOFT_MAX_F32_4].pipeline;
1388
  }
1389
  } else {
1390
+ while (nth < ne00 && nth*ne01*ne02*ne03 < 256) {
1391
  nth *= 2;
1392
  }
1393
  if (use_f16) {