@@ -124,6 +124,11 @@ static __dpct_inline__ T op_exp(T x) {
124124 return sycl::exp (x);
125125}
126126
127+ template <typename T>
128+ static __dpct_inline__ T op_expm1 (T x) {
129+ return sycl::expm1 (x);
130+ }
131+
127132template <typename T>
128133static __dpct_inline__ T op_log (T x) {
129134 if (x <= static_cast <T>(0 )) {
@@ -605,6 +610,12 @@ static inline void ggml_sycl_op_exp(ggml_backend_sycl_context & ctx, ggml_tensor
605610 });
606611}
607612
613+ static inline void ggml_sycl_op_expm1 (ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
614+ ggml_sycl_detail::ggml_sycl_op_unary (ctx, dst, [](auto x) {
615+ return op_expm1 (x);
616+ });
617+ }
618+
608619static inline void ggml_sycl_op_log (ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
609620 ggml_sycl_detail::dispatch_ggml_sycl_op_unary (ctx, dst,
610621 [](const auto * src, auto * dst_ptr, int k_elements, queue_ptr stream) {
@@ -728,16 +739,9 @@ static inline void ggml_sycl_op_clamp(ggml_backend_sycl_context & ctx, ggml_tens
728739}
729740
730741static inline void ggml_sycl_op_floor (ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
731- ggml_sycl_detail::dispatch_ggml_sycl_op_unary (ctx, dst,
732- [](const auto * src, auto * dst_ptr, int k_elements, queue_ptr stream) {
733- const int num_blocks = ceil_div (k_elements, 256 );
734- stream->parallel_for (
735- sycl::nd_range<1 >(sycl::range<1 >(num_blocks) * sycl::range<1 >(256 ),
736- sycl::range<1 >(256 )),
737- [=](sycl::nd_item<1 > item_ct1) {
738- unary_op_floor_kernel (src, dst_ptr, k_elements, item_ct1);
739- });
740- });
742+ ggml_sycl_detail::ggml_sycl_op_unary (ctx, dst, [](auto x) {
743+ return op_floor (x);
744+ });
741745}
742746
743747static inline void ggml_sycl_op_ceil (ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
@@ -747,29 +751,15 @@ static inline void ggml_sycl_op_ceil(ggml_backend_sycl_context & ctx, ggml_tenso
747751}
748752
749753static inline void ggml_sycl_op_round (ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
750- ggml_sycl_detail::dispatch_ggml_sycl_op_unary (ctx, dst,
751- [](const auto * src, auto * dst_ptr, int k_elements, queue_ptr stream) {
752- const int num_blocks = ceil_div (k_elements, 256 );
753- stream->parallel_for (
754- sycl::nd_range<1 >(sycl::range<1 >(num_blocks) * sycl::range<1 >(256 ),
755- sycl::range<1 >(256 )),
756- [=](sycl::nd_item<1 > item_ct1) {
757- unary_op_round_kernel (src, dst_ptr, k_elements, item_ct1);
758- });
759- });
754+ ggml_sycl_detail::ggml_sycl_op_unary (ctx, dst, [](auto x) {
755+ return op_round (x);
756+ });
760757}
761758
762759static inline void ggml_sycl_op_trunc (ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
763- ggml_sycl_detail::dispatch_ggml_sycl_op_unary (ctx, dst,
764- [](const auto * src, auto * dst_ptr, int k_elements, queue_ptr stream) {
765- const int num_blocks = ceil_div (k_elements, 256 );
766- stream->parallel_for (
767- sycl::nd_range<1 >(sycl::range<1 >(num_blocks) * sycl::range<1 >(256 ),
768- sycl::range<1 >(256 )),
769- [=](sycl::nd_item<1 > item_ct1) {
770- unary_op_trunc_kernel (src, dst_ptr, k_elements, item_ct1);
771- });
772- });
760+ ggml_sycl_detail::ggml_sycl_op_unary (ctx, dst, [](auto x) {
761+ return op_trunc (x);
762+ });
773763}
774764
775765static inline void ggml_sycl_op_acc (ggml_backend_sycl_context & ctx, ggml_tensor *dst) {
@@ -1018,6 +1008,11 @@ void ggml_sycl_exp(ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
10181008 ggml_sycl_op_exp (ctx, dst);
10191009}
10201010
1011+ void ggml_sycl_expm1 (ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
1012+ scope_op_debug_print scope_dbg_print (__func__, dst, /* num_src=*/ 1 );
1013+ ggml_sycl_op_expm1 (ctx, dst);
1014+ }
1015+
10211016void ggml_sycl_log (ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
10221017 scope_op_debug_print scope_dbg_print (__func__, dst, /* num_src=*/ 1 );
10231018 ggml_sycl_op_log (ctx, dst);
0 commit comments