@@ -4,16 +4,15 @@ template <typename T>
44static void col2im_1d_sycl (
55 const T * col,
66 T * dst,
7- const int64_t T_in,
8- const int64_t T_out,
9- const int64_t OC ,
10- const int64_t K,
11- const int64_t K_OC ,
7+ const int T_in,
8+ const sycl::uint3 T_out_fd,
9+ const int K,
10+ const int K_OC ,
1211 const int32_t s0,
1312 const int32_t p0,
13+ const int total,
1414 dpct::queue_ptr stream) {
1515
16- const int64_t total = T_out * OC ;
1716 const uint32_t block_size = 256 ;
1817 const uint32_t num_blocks = (uint32_t ) ((total + block_size - 1 ) / block_size);
1918
@@ -22,27 +21,28 @@ static void col2im_1d_sycl(
2221 sycl::range<3 >(1 , 1 , num_blocks * block_size),
2322 sycl::range<3 >(1 , 1 , block_size)),
2423 [=](sycl::nd_item<3 > item_ct1) {
25- const int64_t idx = item_ct1.get_global_id (2 );
24+ const int idx = ( int ) item_ct1.get_global_id (2 );
2625 if (idx >= total) {
2726 return ;
2827 }
2928
30- const int64_t oc = idx / T_out;
31- const int64_t t_out = idx - oc * T_out;
32- const int64_t t_abs = t_out + p0;
29+ const sycl::uint2 qr = fast_div_modulo ((uint32_t ) idx, T_out_fd);
30+ const int oc = (int ) qr.x ();
31+ const int t_out = (int ) qr.y ();
32+ const int t_abs = t_out + p0;
3333
34- int64_t t_in_min = (t_abs - K + s0) / s0;
34+ int t_in_min = (t_abs - K + s0) / s0;
3535 if (t_in_min < 0 ) {
3636 t_in_min = 0 ;
3737 }
38- int64_t t_in_max = t_abs / s0;
38+ int t_in_max = t_abs / s0;
3939 if (t_in_max >= T_in) {
4040 t_in_max = T_in - 1 ;
4141 }
4242
4343 float sum = 0 .0f ;
44- for (int64_t t_in = t_in_min; t_in <= t_in_max; ++t_in) {
45- const int64_t k = t_abs - t_in * s0;
44+ for (int t_in = t_in_min; t_in <= t_in_max; ++t_in) {
45+ const int k = t_abs - t_in * s0;
4646 sum += (float ) col[(oc * K + k) + t_in * K_OC ];
4747 }
4848
@@ -61,35 +61,39 @@ void ggml_sycl_op_col2im_1d(ggml_backend_sycl_context & ctx, ggml_tensor * dst)
6161 const int32_t OC = ((const int32_t *) dst->op_params )[1 ];
6262 const int32_t p0 = ((const int32_t *) dst->op_params )[2 ];
6363
64- const int64_t K_OC = src0->ne [0 ];
65- const int64_t T_in = src0->ne [1 ];
66- const int64_t K = K_OC / OC ;
67- const int64_t T_out = dst->ne [0 ];
64+ const int K_OC = ( int ) src0->ne [0 ];
65+ const int T_in = ( int ) src0->ne [1 ];
66+ const int K = K_OC / OC ;
67+ const int T_out = ( int ) dst->ne [0 ];
6868
6969 GGML_ASSERT (OC > 0 );
7070 GGML_ASSERT (K_OC % OC == 0 );
7171
72+ const sycl::uint3 T_out_fd = init_fastdiv_values ((uint32_t ) T_out);
73+
74+ const int total = T_out * OC ;
75+
7276 dpct::queue_ptr stream = ctx.stream ();
7377
7478 switch (src0->type ) {
7579 case GGML_TYPE_F32 :
7680 col2im_1d_sycl<float >(
7781 (const float *) src0->data ,
7882 (float *) dst->data ,
79- T_in, T_out, OC , K, K_OC , s0, p0, stream);
83+ T_in, T_out_fd, K, K_OC , s0, p0, total , stream);
8084 break ;
8185 case GGML_TYPE_F16 :
8286 col2im_1d_sycl<sycl::half>(
8387 (const sycl::half *) src0->data ,
8488 (sycl::half *) dst->data ,
85- T_in, T_out, OC , K, K_OC , s0, p0, stream);
89+ T_in, T_out_fd, K, K_OC , s0, p0, total , stream);
8690 break ;
8791#ifdef GGML_SYCL_HAS_BF16
8892 case GGML_TYPE_BF16 :
8993 col2im_1d_sycl<sycl::ext::oneapi::bfloat16>(
9094 (const sycl::ext::oneapi::bfloat16 *) src0->data ,
9195 (sycl::ext::oneapi::bfloat16 *) dst->data ,
92- T_in, T_out, OC , K, K_OC , s0, p0, stream);
96+ T_in, T_out_fd, K, K_OC , s0, p0, total , stream);
9397 break ;
9498#endif
9599 default :
0 commit comments