@@ -397,6 +397,14 @@ static void acc_f32_sycl(const float *x, const float *y, float *dst,
397397 });
398398}
399399
400+ template <typename T>
401+ static void arange_kernel (T * dst, const int k, T start, T step,
402+ const sycl::nd_item<1 > &item_ct1) {
403+ SYCL_GLOBAL_ID_LOOP (k, item_ct1) {
404+ dst[i] = start + static_cast <T>(i) * step;
405+ }
406+ }
407+
400408template <typename T>
401409static void upscale_sycl (const T *x, T *dst, const int nb00, const int nb01,
402410 const int nb02, const int nb03, const int ne10, const int ne11,
@@ -565,6 +573,25 @@ static inline void dispatch_ggml_sycl_op_upscale(ggml_backend_sycl_context & ctx
565573}
566574
567575
576+ static inline void ggml_sycl_op_arange (ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
577+ GGML_ASSERT (dst->type == GGML_TYPE_F32);
578+ float start, stop, step;
579+ memcpy (&start, dst->op_params , sizeof (float ));
580+ memcpy (&stop, (float *) dst->op_params + 1 , sizeof (float ));
581+ memcpy (&step, (float *) dst->op_params + 2 , sizeof (float ));
582+ dpct::queue_ptr stream = ctx.stream ();
583+ SYCL_CHECK (ggml_sycl_set_device (ctx.device ));
584+ float * dst_ptr = (float *)dst->data ;
585+ const int k = (int )ggml_nelements (dst);
586+ const int num_blocks = ceil_div (k, SYCL_ARANGE_BLOCK_SIZE);
587+ stream->parallel_for (
588+ sycl::nd_range<1 >(sycl::range<1 >(num_blocks) * sycl::range<1 >(SYCL_ARANGE_BLOCK_SIZE),
589+ sycl::range<1 >(SYCL_ARANGE_BLOCK_SIZE)),
590+ [=](sycl::nd_item<1 > item_ct1) {
591+ arange_kernel (dst_ptr, k, start, step, item_ct1);
592+ });
593+ }
594+
568595} // namespace ggml_sycl_detail
569596
570597
@@ -1090,3 +1117,8 @@ void ggml_sycl_geglu_quick(ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
10901117 scope_op_debug_print scope_dbg_print (__func__, dst, /* num_src=*/ 1 );
10911118 ggml_sycl_op_geglu_quick (ctx, dst);
10921119}
1120+
1121+ void ggml_sycl_arange (ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
1122+ scope_op_debug_print scope_dbg_print (__func__, dst, /* num_src=*/ 0 );
1123+ ggml_sycl_detail::ggml_sycl_op_arange (ctx, dst);
1124+ }
0 commit comments