Commit 2d8d00393 for llama.cpp
commit 2d8d003937b4ad42c1ada09dcdb0236eb3290a8f
Author: Leon <118652405+LeON-Nie-code@users.noreply.github.com>
Date: Fri Nov 20 15:36:58 2026 +0800
webgpu : add COL2IM_1D support (#31708)
diff --git a/docs/ops.md b/docs/ops.md
index bdf64ca0a..88e92c701 100644
--- a/docs/ops.md
+++ b/docs/ops.md
@@ -24,7 +24,7 @@ Legend:
| ARGSORT | ❌ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | 🟡 | ✅ | ✅ | ✅ | ❌ | ❌ |
| CEIL | ❌ | ❌ | ✅ | 🟡 | 🟡 | 🟡 | ✅ | ✅ | 🟡 | ✅ | ✅ | ✅ | ❌ | ❌ |
| CLAMP | ❌ | ✅ | ✅ | ✅ | 🟡 | ✅ | ✅ | ✅ | 🟡 | ✅ | ✅ | ✅ | ❌ | ❌ |
-| COL2IM_1D | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
+| COL2IM_1D | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | 🟡 | ❌ | ❌ |
| CONCAT | ❌ | ✅ | ✅ | 🟡 | 🟡 | 🟡 | ✅ | 🟡 | 🟡 | ✅ | ✅ | 🟡 | ❌ | ❌ |
| CONT | ❌ | 🟡 | ✅ | ✅ | 🟡 | 🟡 | ✅ | ✅ | 🟡 | ✅ | ✅ | 🟡 | ❌ | ❌ |
| CONV_1D_DW | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ |
diff --git a/docs/ops/WebGPU.csv b/docs/ops/WebGPU.csv
index 8b5e0c80e..2ad8ded65 100644
--- a/docs/ops/WebGPU.csv
+++ b/docs/ops/WebGPU.csv
@@ -5426,39 +5426,44 @@
"WebGPU: WebGPU","CONV_TRANSPOSE_1D","ne_input=[3,2,1,1],ne_kernel=[3,2,2,1],s0=1,p0=0,d0=1","support","0","no","WebGPU"
"WebGPU: WebGPU","CONV_TRANSPOSE_1D","ne_input=[3,2,1,1],ne_kernel=[3,1,2,1],s0=1,p0=0,d0=1","support","0","no","WebGPU"
"WebGPU: WebGPU","CONV_TRANSPOSE_1D","ne_input=[2,1,1,1],ne_kernel=[3,1,1,1],s0=1,p0=0,d0=1","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f32,K=16,OC=32,T_in=197,s0=8,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f32,K=4,OC=3,T_in=7,s0=2,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f32,K=1,OC=5,T_in=13,s0=1,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f32,K=6,OC=4,T_in=11,s0=3,p0=1","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f32,K=2,OC=3,T_in=9,s0=3,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f32,K=5,OC=4,T_in=11,s0=2,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f32,K=8,OC=4,T_in=13,s0=4,p0=2","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f32,K=4,OC=3,T_in=1,s0=2,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f32,K=16,OC=1,T_in=197,s0=8,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f32,K=1,OC=5,T_in=13,s0=3,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f32,K=8,OC=2,T_in=3,s0=2,p0=5","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f16,K=16,OC=32,T_in=197,s0=8,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f16,K=4,OC=3,T_in=7,s0=2,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f16,K=1,OC=5,T_in=13,s0=1,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f16,K=6,OC=4,T_in=11,s0=3,p0=1","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f16,K=2,OC=3,T_in=9,s0=3,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f16,K=5,OC=4,T_in=11,s0=2,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f16,K=8,OC=4,T_in=13,s0=4,p0=2","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f16,K=4,OC=3,T_in=1,s0=2,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f16,K=16,OC=1,T_in=197,s0=8,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f16,K=1,OC=5,T_in=13,s0=3,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=f16,K=8,OC=2,T_in=3,s0=2,p0=5","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=16,OC=32,T_in=197,s0=8,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=4,OC=3,T_in=7,s0=2,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=1,OC=5,T_in=13,s0=1,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=6,OC=4,T_in=11,s0=3,p0=1","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=2,OC=3,T_in=9,s0=3,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=5,OC=4,T_in=11,s0=2,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=8,OC=4,T_in=13,s0=4,p0=2","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=4,OC=3,T_in=1,s0=2,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=16,OC=1,T_in=197,s0=8,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=1,OC=5,T_in=13,s0=3,p0=0","support","0","no","WebGPU"
-"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=8,OC=2,T_in=3,s0=2,p0=5","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=16,OC=32,T_in=197,s0=8,p0=0,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=4,OC=3,T_in=7,s0=2,p0=0,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=1,OC=5,T_in=13,s0=1,p0=0,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=6,OC=4,T_in=11,s0=3,p0=1,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=2,OC=3,T_in=9,s0=3,p0=0,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=5,OC=4,T_in=11,s0=2,p0=0,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=8,OC=4,T_in=13,s0=4,p0=2,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=4,OC=3,T_in=1,s0=2,p0=0,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=16,OC=1,T_in=197,s0=8,p0=0,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=1,OC=5,T_in=13,s0=3,p0=0,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=8,OC=2,T_in=3,s0=2,p0=5,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f16,K=16,OC=32,T_in=197,s0=8,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f16,K=4,OC=3,T_in=7,s0=2,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f16,K=1,OC=5,T_in=13,s0=1,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f16,K=6,OC=4,T_in=11,s0=3,p0=1,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f16,K=2,OC=3,T_in=9,s0=3,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f16,K=5,OC=4,T_in=11,s0=2,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f16,K=8,OC=4,T_in=13,s0=4,p0=2,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f16,K=4,OC=3,T_in=1,s0=2,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f16,K=16,OC=1,T_in=197,s0=8,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f16,K=1,OC=5,T_in=13,s0=3,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f16,K=8,OC=2,T_in=3,s0=2,p0=5,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=16,OC=32,T_in=197,s0=8,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=4,OC=3,T_in=7,s0=2,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=1,OC=5,T_in=13,s0=1,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=6,OC=4,T_in=11,s0=3,p0=1,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=2,OC=3,T_in=9,s0=3,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=5,OC=4,T_in=11,s0=2,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=8,OC=4,T_in=13,s0=4,p0=2,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=4,OC=3,T_in=1,s0=2,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=16,OC=1,T_in=197,s0=8,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=1,OC=5,T_in=13,s0=3,p0=0,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=bf16,K=8,OC=2,T_in=3,s0=2,p0=5,view=0","support","0","no","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=5,OC=3,T_in=17,s0=2,p0=1,view=1","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=1,OC=1,T_in=255,s0=1,p0=0,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=1,OC=1,T_in=256,s0=1,p0=0,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=1,OC=1,T_in=257,s0=1,p0=0,view=0","support","1","yes","WebGPU"
+"WebGPU: WebGPU","COL2IM_1D","type=f32,K=1,OC=1,T_in=16777217,s0=1,p0=0,view=0","support","1","yes","WebGPU"
"WebGPU: WebGPU","CONV_TRANSPOSE_2D","kernel_type=f32,ne_input=[3,2,3,1],ne_kernel=[2,2,1,3],stride=1","support","0","no","WebGPU"
"WebGPU: WebGPU","CONV_TRANSPOSE_2D","kernel_type=f32,ne_input=[10,10,9,1],ne_kernel=[3,3,1,9],stride=2","support","0","no","WebGPU"
"WebGPU: WebGPU","CONV_TRANSPOSE_2D","kernel_type=f32,ne_input=[129,63,35,1],ne_kernel=[3,3,48,35],stride=1","support","0","no","WebGPU"
diff --git a/ggml/src/ggml-webgpu/ggml-webgpu-shader-lib.hpp b/ggml/src/ggml-webgpu/ggml-webgpu-shader-lib.hpp
index 52b1bcc88..cc7f660ef 100644
--- a/ggml/src/ggml-webgpu/ggml-webgpu-shader-lib.hpp
+++ b/ggml/src/ggml-webgpu/ggml-webgpu-shader-lib.hpp
@@ -1269,6 +1269,7 @@ class ggml_webgpu_shader_lib {
std::unordered_map<int, webgpu_pipeline> argsort_pipelines; // key is order
std::unordered_map<int, webgpu_pipeline> argsort_merge_pipelines; // key is order
std::unordered_map<int, webgpu_pipeline> cumsum_pipelines; // key is fixed, no variants yet
+ std::unordered_map<int, webgpu_pipeline> col2im_1d_pipelines; // key is fixed, no variants yet
std::unordered_map<int, webgpu_pipeline> arange_pipelines; // key is fixed, no variants yet
std::unordered_map<int, webgpu_pipeline> count_equal_pipelines; // key is src_overlap
std::unordered_map<int, webgpu_pipeline> timestep_embedding_pipelines; // key is fixed, no variants yet
@@ -2096,6 +2097,23 @@ class ggml_webgpu_shader_lib {
return pool2d_pipelines[key];
}
+ webgpu_pipeline get_col2im_1d_pipeline(const ggml_webgpu_shader_lib_context & context) {
+ auto it = col2im_1d_pipelines.find(1);
+ if (it != col2im_1d_pipelines.end()) {
+ return it->second;
+ }
+
+ const uint32_t wg_size = std::min(256u, context.max_wg_size);
+ std::vector<std::string> defines = { "WG_SIZE=" + std::to_string(wg_size) };
+ auto processed = preprocessor.preprocess(wgsl_col2im_1d, defines);
+ auto decisions = std::make_shared<ggml_webgpu_generic_shader_decisions>();
+ decisions->wg_size = wg_size;
+ webgpu_pipeline pipeline = ggml_webgpu_create_pipeline(device, processed, "col2im_1d");
+ pipeline.context = decisions;
+ col2im_1d_pipelines[1] = pipeline;
+ return pipeline;
+ }
+
webgpu_pipeline get_pad_pipeline(const ggml_webgpu_shader_lib_context & context) {
ggml_webgpu_pad_pipeline_key key = {};
key.reflect = context.dst->op == GGML_OP_PAD_REFLECT_1D;
diff --git a/ggml/src/ggml-webgpu/ggml-webgpu.cpp b/ggml/src/ggml-webgpu/ggml-webgpu.cpp
index 6aa0cc92a..75527b111 100644
--- a/ggml/src/ggml-webgpu/ggml-webgpu.cpp
+++ b/ggml/src/ggml-webgpu/ggml-webgpu.cpp
@@ -908,6 +908,32 @@ static webgpu_encoded_op ggml_webgpu_arange(webgpu_context & ctx, ggml_tensor *
return ggml_backend_webgpu_build(ctx, pipeline, params, entries, wg_x, wg_y);
}
+static webgpu_encoded_op ggml_webgpu_col2im_1d(webgpu_context & ctx, ggml_tensor * src, ggml_tensor * dst) {
+ ggml_webgpu_shader_lib_context shader_lib_ctx = {};
+ shader_lib_ctx.max_wg_size = ctx->global_ctx->capabilities.limits.maxComputeInvocationsPerWorkgroup;
+ webgpu_pipeline pipeline = ctx->shader_lib->get_col2im_1d_pipeline(shader_lib_ctx);
+ auto * decisions = static_cast<ggml_webgpu_generic_shader_decisions *>(pipeline.context.get());
+
+ std::vector<uint32_t> params = {
+ (uint32_t) ggml_nelements(dst),
+ (uint32_t) (ggml_webgpu_tensor_misalignment(ctx, src) / sizeof(float)),
+ (uint32_t) (ggml_webgpu_tensor_misalignment(ctx, dst) / sizeof(float)),
+ (uint32_t) src->ne[0],
+ (uint32_t) src->ne[1],
+ (uint32_t) dst->ne[0],
+ (uint32_t) (src->ne[0] / dst->ne[1]),
+ (uint32_t) ggml_get_op_params_i32(dst, 0),
+ (uint32_t) ggml_get_op_params_i32(dst, 2),
+ };
+ std::vector<wgpu::BindGroupEntry> entries = { ggml_webgpu_make_tensor_bind_group_entry(ctx, 0, src),
+ ggml_webgpu_make_tensor_bind_group_entry(ctx, 1, dst) };
+ uint32_t wg_x;
+ uint32_t wg_y;
+ const uint32_t total_wg = CEIL_DIV(ggml_nelements(dst), decisions->wg_size);
+ compute_2d_workgroups(total_wg, ctx->global_ctx->capabilities.limits.maxComputeWorkgroupsPerDimension, wg_x, wg_y);
+ return ggml_backend_webgpu_build(ctx, pipeline, params, entries, wg_x, wg_y);
+}
+
static webgpu_encoded_op ggml_webgpu_pad(webgpu_context & ctx, ggml_tensor * src, ggml_tensor * dst) {
ggml_webgpu_shader_lib_context shader_lib_ctx = {};
shader_lib_ctx.src0 = src;
@@ -3712,6 +3738,8 @@ static std::optional<webgpu_encoded_op> ggml_webgpu_encode(webgpu_context ctx,
return ggml_webgpu_arange(ctx, node);
case GGML_OP_POOL_2D:
return ggml_webgpu_pool2d(ctx, src0, node);
+ case GGML_OP_COL2IM_1D:
+ return ggml_webgpu_col2im_1d(ctx, src0, node);
case GGML_OP_PAD_REFLECT_1D:
case GGML_OP_PAD:
return ggml_webgpu_pad(ctx, src0, node);
@@ -5292,6 +5320,10 @@ static bool ggml_backend_webgpu_device_supports_op(ggml_backend_dev_t dev, const
supports_op = src0->type == GGML_TYPE_I32 && src1->type == GGML_TYPE_I32 && ggml_is_contiguous(src0) &&
ggml_is_contiguous(src1);
break;
+ case GGML_OP_COL2IM_1D:
+ supports_op = op->type == GGML_TYPE_F32 && src0->type == GGML_TYPE_F32 && ggml_is_contiguous(src0) &&
+ ggml_is_contiguous(op);
+ break;
case GGML_OP_SUM_ROWS:
case GGML_OP_MEAN:
supports_op = op->type == GGML_TYPE_F32 && src0->type == op->type && ggml_is_contiguous_rows(src0);
diff --git a/ggml/src/ggml-webgpu/wgsl-shaders/col2im_1d.wgsl b/ggml/src/ggml-webgpu/wgsl-shaders/col2im_1d.wgsl
new file mode 100644
index 000000000..f89528f24
--- /dev/null
+++ b/ggml/src/ggml-webgpu/wgsl-shaders/col2im_1d.wgsl
@@ -0,0 +1,45 @@
+@group(0) @binding(0)
+var<storage, read_write> src: array<f32>;
+
+@group(0) @binding(1)
+var<storage, read_write> dst: array<f32>;
+
+struct Params {
+ ne: u32,
+ offset_src: u32,
+ offset_dst: u32,
+ src_ne0: u32,
+ t_in: u32,
+ t_out: u32,
+ kernel: u32,
+ stride: u32,
+ padding: u32,
+};
+
+@group(0) @binding(2)
+var<uniform> params: Params;
+
+@compute @workgroup_size(WG_SIZE)
+fn main(@builtin(num_workgroups) num_wg: vec3<u32>,
+ @builtin(global_invocation_id) gid: vec3<u32>) {
+ let idx = gid.x + num_wg.x * WG_SIZE * gid.y;
+ if (idx >= params.ne) {
+ return;
+ }
+
+ let channel = idx / params.t_out;
+ let t_abs = idx % params.t_out + params.padding;
+ var first: u32 = 0;
+ if (t_abs >= params.kernel) {
+ first = (t_abs - params.kernel) / params.stride + 1;
+ }
+ let last = min(t_abs / params.stride, params.t_in - 1);
+
+ // Gather overlapping columns in the same order as the CPU reference.
+ var sum: f32 = 0.0;
+ for (var t = first; t <= last; t++) {
+ let k = t_abs - t * params.stride;
+ sum += src[params.offset_src + t * params.src_ne0 + channel * params.kernel + k];
+ }
+ dst[params.offset_dst + idx] = sum;
+}
diff --git a/tests/test-backend-ops.cpp b/tests/test-backend-ops.cpp
index 6d99453d8..a870016b0 100644
--- a/tests/test-backend-ops.cpp
+++ b/tests/test-backend-ops.cpp
@@ -6940,9 +6940,10 @@ struct test_col2im_1d : public test_case {
const int64_t T_in; // input length (number of columns)
const int s0; // stride
const int p0; // padding cropped from both sides
+ const bool view;
std::string vars() override {
- return VARS_TO_STR6(type, K, OC, T_in, s0, p0);
+ return VARS_TO_STR7(type, K, OC, T_in, s0, p0, view);
}
double max_nmse_err() override {
@@ -6951,11 +6952,17 @@ struct test_col2im_1d : public test_case {
test_col2im_1d(ggml_type type = GGML_TYPE_F32,
int64_t K = 4, int64_t OC = 3, int64_t T_in = 7,
- int s0 = 2, int p0 = 0)
- : type(type), K(K), OC(OC), T_in(T_in), s0(s0), p0(p0) {}
+ int s0 = 2, int p0 = 0, bool view = false)
+ : type(type), K(K), OC(OC), T_in(T_in), s0(s0), p0(p0), view(view) {}
ggml_tensor * build_graph(ggml_context * ctx) override {
- ggml_tensor * cols = ggml_new_tensor_2d(ctx, type, K*OC, T_in);
+ ggml_tensor * cols;
+ if (view) {
+ ggml_tensor * base = ggml_new_tensor_1d(ctx, type, K * OC * T_in + 1);
+ cols = ggml_view_2d(ctx, base, K * OC, T_in, K * OC * ggml_type_size(type), ggml_type_size(type));
+ } else {
+ cols = ggml_new_tensor_2d(ctx, type, K * OC, T_in);
+ }
ggml_set_name(cols, "cols");
ggml_tensor * out = ggml_col2im_1d(ctx, cols, s0, (int) OC, p0);
@@ -11341,6 +11348,11 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
test_cases.emplace_back(new test_col2im_1d(type, 8, 2, 3, 2, 5)); // cropping eats most of the signal, T_out = 2
}
+ test_cases.emplace_back(new test_col2im_1d(GGML_TYPE_F32, 5, 3, 17, 2, 1, true));
+ for (int64_t n : {255, 256, 257, 16777217}) {
+ test_cases.emplace_back(new test_col2im_1d(GGML_TYPE_F32, 1, 1, n, 1, 0));
+ }
+
for (ggml_type kernel_type : {GGML_TYPE_F32, GGML_TYPE_F16}) {
test_cases.emplace_back(new test_conv_transpose_2d({3, 2, 3, 1}, {2, 2, 1, 3}, 1, kernel_type));
test_cases.emplace_back(new test_conv_transpose_2d({10, 10, 9, 1}, {3, 3, 1, 9}, 2, kernel_type));