webgpu : add COL2IM_1D support (#31708)

This commit is contained in:
Leon authored and GitHub committed 2026-11-20 09:36:58 +02:00
1 parent 7e960f40fb
commit 2d8d003937
6 files changed
+150 -38

No files matched your search

+16 -4
View File
@@ -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));