Skip to content

Commit b81928f

Browse files
committed
Address PR feedback
1 parent 0b14906 commit b81928f

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

ggml/src/ggml-cpu/ops.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7427,7 +7427,7 @@ static void ggml_compute_forward_upscale_f32(
74277427
return std::max(1.0f - fabsf(x), 0.0f);
74287428
};
74297429

7430-
// support and invscale, maximum 1 pixel for bilinear
7430+
// support and invscale, minimum 1 pixel for bilinear
74317431
const float support1 = std::max(1.0f, 1.0f / sf1);
74327432
const float invscale1 = 1.0f / support1;
74337433
const float support0 = std::max(1.0f, 1.0f / sf0);

ggml/src/ggml-cuda/upscale.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static __global__ void upscale_f32_bilinear_antialias(const float * src0, float
107107
const float y = ((float)i11_dst + pixel_offset) / sf1;
108108
const float x = ((float)i10_dst + pixel_offset) / sf0;
109109

110-
// support and invscale, maximum 1 pixel for bilinear
110+
// support and invscale, minimum 1 pixel for bilinear
111111
const float support1 = max(1.0f / sf1, 1.0f);
112112
const float invscale1 = 1.0f / support1;
113113
const float support0 = max(1.0f / sf0, 1.0f);
@@ -281,7 +281,7 @@ void ggml_cuda_op_upscale(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
281281
if (mode == GGML_SCALE_MODE_NEAREST) {
282282
upscale_f32_cuda(src0_d, dst_d, src0->nb[0], src0->nb[1], src0->nb[2], src0->nb[3], dst->ne[0], dst->ne[1], dst->ne[2], dst->ne[3], sf0, sf1, sf2, sf3, stream);
283283
} else if (mode == GGML_SCALE_MODE_BILINEAR) {
284-
bool antialias = (mode_flags & GGML_SCALE_FLAG_ANTIALIAS);
284+
const bool antialias = (mode_flags & GGML_SCALE_FLAG_ANTIALIAS);
285285
upscale_f32_bilinear_cuda(src0_d, dst_d, src0->nb[0], src0->nb[1], src0->nb[2], src0->nb[3],
286286
src0->ne[0], src0->ne[1], dst->ne[0], dst->ne[1], dst->ne[2], dst->ne[3],
287287
sf0, sf1, sf2, sf3, pixel_offset, antialias, stream);

ggml/src/ggml.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4891,6 +4891,8 @@ static struct ggml_tensor * ggml_interpolate_impl(
48914891
int64_t ne3,
48924892
uint32_t mode) {
48934893
GGML_ASSERT((mode & 0xFF) < GGML_SCALE_MODE_COUNT);
4894+
// TODO: implement antialias for modes other than bilinear
4895+
GGML_ASSERT(!(mode & GGML_SCALE_FLAG_ANTIALIAS) || (mode & 0xFF) == GGML_SCALE_MODE_BILINEAR);
48944896

48954897
struct ggml_tensor * result = ggml_new_tensor_4d(ctx, a->type, ne0, ne1, ne2, ne3);
48964898

tools/mtmd/clip.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2787,6 +2787,7 @@ struct clip_model_loader {
27872787
{
27882788
get_u32(KEY_PROJ_SCALE_FACTOR, hparams.n_merge, false);
27892789
// ref: https://huggingface.co/LiquidAI/LFM2-VL-3B/blob/main/preprocessor_config.json
2790+
// config above specifies number of tokens after downsampling, while here it is before, relax lowerbound to 64
27902791
hparams.set_limit_image_tokens(64, 1024);
27912792
} break;
27922793
case PROJECTOR_TYPE_PIXTRAL:

0 commit comments

Comments
 (0)