apply review

Signed-off-by: Junhee Yoo <junhee.yoo@navercorp.com>
This commit is contained in:
Junhee Yoo 2024-10-23 17:00:17 +09:00
parent bb9949b3f6
commit 746e79e9a5
2 changed files with 31 additions and 25 deletions

View file

@ -854,7 +854,6 @@ static bool ggml_metal_supports_op(const struct ggml_backend_metal_device_contex
case GGML_OP_POOL_1D:
return false;
case GGML_OP_POOL_2D:
return true;
case GGML_OP_UPSCALE:
case GGML_OP_PAD:
case GGML_OP_ARANGE:
@ -2554,6 +2553,8 @@ static void ggml_metal_encode_node(
} break;
case GGML_OP_IM2COL:
{
GGML_ASSERT(ggml_is_contiguous(src0));
GGML_ASSERT(ggml_is_contiguous(src1));
GGML_ASSERT(src0->type == GGML_TYPE_F16);
GGML_ASSERT(src1->type == GGML_TYPE_F32);
GGML_ASSERT( dst->type == GGML_TYPE_F16 || dst->type == GGML_TYPE_F32);
@ -3034,6 +3035,7 @@ static void ggml_metal_encode_node(
} break;
case GGML_OP_POOL_2D:
{
GGML_ASSERT(ggml_is_contiguous(src0));
GGML_ASSERT(src0t == GGML_TYPE_F32 && src0t == dstt);
const int32_t * opts = dst->op_params;

View file

@ -6488,6 +6488,7 @@ kernel void kernel_pool_2d_max_f32(
const int start_w = cur_ow * s0 - p0;
const int bw = MAX(0, start_w);
const int ew = MIN(IW, start_w + k0);
float res = -INFINITY;
for (int i = bh; i < eh; i += 1) {
@ -6495,6 +6496,7 @@ kernel void kernel_pool_2d_max_f32(
res = MAX(res, i_ptr[i * IW + j]);
}
}
o_ptr[cur_oh * OW + cur_ow] = res;
}
@ -6536,6 +6538,7 @@ kernel void kernel_pool_2d_avg_f32(
const int ew = MIN(IW, start_w + k0);
// const float scale = 1. / ((eh - bh) * (ew - bw));
const float scale = 1. / (k0 * k1);
float res = 0;
for (int i = bh; i < eh; i += 1) {
@ -6544,5 +6547,6 @@ kernel void kernel_pool_2d_avg_f32(
res += cur * scale;
}
}
o_ptr[cur_oh * OW + cur_ow] = res;
}