Skip to content

Commit 32c180e

Browse files
committed
Review: add brackets for readability, remove ggml_set_param and add asserts
1 parent b80dd1d commit 32c180e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ggml/src/ggml-cuda/conv2d-transpose.cu

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ __global__ void conv2d_transpose_kernel(const float * __restrict__ input, const
1616
}
1717

1818
const int out_x_idx = global_idx % out_w;
19-
const int out_y_idx = global_idx / out_w % out_h;
20-
const int c_idx = global_idx / (out_w * out_h) % c_out;
19+
const int out_y_idx = (global_idx / out_w) % out_h;
20+
const int c_idx = (global_idx / (out_w * out_h)) % c_out;
2121
const int n_idx = global_idx / (out_w * out_h * c_out);
2222

2323
float accumulator = 0;
@@ -78,6 +78,10 @@ void ggml_cuda_conv_2d_transpose_p0(ggml_backend_cuda_context & ctx, ggml_tensor
7878

7979
cudaStream_t st = ctx.stream();
8080

81+
GGML_ASSERT(ggml_is_contiguous(input));
82+
GGML_ASSERT(ggml_is_contiguous(kernel));
83+
GGML_ASSERT(ggml_is_contiguous(dst));
84+
8185
const int total = (output_w * output_h * channels_out * batches);
8286
const int blocks = (total + CUDA_CONV2D_TRANSPOSE_BLOCK_SIZE - 1) / CUDA_CONV2D_TRANSPOSE_BLOCK_SIZE;
8387

tests/test-backend-ops.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,6 @@ struct test_case {
560560
}
561561

562562
double err = nmse(f1.data(), f2.data(), f1.size());
563-
564563
if (err > ud->max_err) {
565564
printf("[%s] NMSE = %.9f > %.9f ", ggml_op_desc(t1), err, ud->max_err);
566565
//for (int i = 0; i < (int) f1.size(); i++) {
@@ -2743,11 +2742,9 @@ struct test_conv_transpose_2d : public test_case {
27432742

27442743
ggml_tensor * build_graph(ggml_context * ctx) override {
27452744
ggml_tensor * input = ggml_new_tensor(ctx, GGML_TYPE_F32, 4, ne_input.data());
2746-
ggml_set_param(input);
27472745
ggml_set_name(input, "input");
27482746

27492747
ggml_tensor * kernel = ggml_new_tensor(ctx, GGML_TYPE_F16, 4, ne_kernel.data());
2750-
ggml_set_param(kernel);
27512748
ggml_set_name(kernel, "kernel");
27522749

27532750
ggml_tensor * out = ggml_conv_transpose_2d_p0(ctx, kernel, input, stride);

0 commit comments

Comments
 (0)