From 06d0f91e42a33e739b9aba72e14748f2a5c94ac0 Mon Sep 17 00:00:00 2001 From: chraac Date: Thu, 8 Jan 2026 10:16:50 +0800 Subject: [PATCH] wip --- ggml/src/ggml-opencl/ggml-opencl.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ggml/src/ggml-opencl/ggml-opencl.cpp b/ggml/src/ggml-opencl/ggml-opencl.cpp index 89c5ed9082..982fa59e43 100644 --- a/ggml/src/ggml-opencl/ggml-opencl.cpp +++ b/ggml/src/ggml-opencl/ggml-opencl.cpp @@ -2678,6 +2678,8 @@ struct ggml_tensor_extra_cl { } }; +namespace /* anonymous */ { + template struct cl_kernel_arg_setter {}; template <> struct cl_kernel_arg_setter { @@ -2713,14 +2715,14 @@ template <> struct cl_kernel_arg_setter { } }; -template <> struct cl_kernel_arg_setter { +template <> struct cl_kernel_arg_setter { static size_t set_arg(cl_kernel kernel, size_t index, const int64_t (&ne)[GGML_MAX_DIMS]) { static_assert(GGML_MAX_DIMS == 4, "GGML_MAX_DIMS changed, update cl_kernel_arg_setter accordingly"); - const int ne0 = (int)ne[0]; - const int ne1 = (int)ne[1]; - const int ne2 = (int)ne[2]; - const int ne3 = (int)ne[3]; + const int ne0 = (int) ne[0]; + const int ne1 = (int) ne[1]; + const int ne2 = (int) ne[2]; + const int ne3 = (int) ne[3]; CL_CHECK(clSetKernelArg(kernel, index, sizeof(int), &ne0)); CL_CHECK(clSetKernelArg(kernel, index + 1, sizeof(int), &ne1)); CL_CHECK(clSetKernelArg(kernel, index + 2, sizeof(int), &ne2)); @@ -2729,7 +2731,7 @@ template <> struct cl_kernel_arg_setter { } }; -template <> struct cl_kernel_arg_setter { +template <> struct cl_kernel_arg_setter { static size_t set_arg(cl_kernel kernel, size_t index, const size_t (&nb)[GGML_MAX_DIMS]) { static_assert(GGML_MAX_DIMS == 4, "GGML_MAX_DIMS changed, update cl_kernel_arg_setter accordingly"); @@ -2745,16 +2747,20 @@ template <> struct cl_kernel_arg_setter { } }; -template static inline size_t cl_set_kernel_args(cl_kernel kernel, _TArgs&&... args) { +template static inline size_t cl_set_kernel_args(cl_kernel kernel, _TArgs &&... args) { size_t index = 0; ( [&] { - index = cl_kernel_arg_setter>>>::set_arg(kernel, index, args); + index = cl_kernel_arg_setter< + std::remove_const_t>>>::set_arg(kernel, index, + args); }(), ...); return index; } +} // namespace + // Additional tensor extra structs for quantized tensors. // These tensors are loaded from files and should not be allocated in scratch -- // they should always be allocated from the pool. Hence, they do not have an