Skip to content

Commit 113d803

Browse files
committed
SYCL: Remove misleading ggml_sycl_op_flatten function
1 parent add2a3a commit 113d803

File tree

12 files changed

+507
-605
lines changed

12 files changed

+507
-605
lines changed

ggml/src/ggml-sycl/common.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -66,41 +66,6 @@ int64_t downsample_sycl_global_range(int64_t accumulate_block_num, int64_t block
6666
return sycl_down_blk_size;
6767
}
6868

69-
void ggml_sycl_op_flatten(ggml_backend_sycl_context & ctx, const ggml_tensor *src0,
70-
const ggml_tensor *src1, ggml_tensor *dst,
71-
const ggml_sycl_op_flatten_t op) try {
72-
73-
const bool use_src1 = src1 != nullptr;
74-
if(use_src1)
75-
GGML_ASSERT(strcmp(src1->buffer->buft->iface.get_name(src1->buffer->buft), GGML_SYCL_NAME "_Split") != 0);
76-
GGML_ASSERT(strcmp(dst->buffer->buft->iface.get_name(dst->buffer->buft), GGML_SYCL_NAME "_Split") != 0);
77-
78-
// dd = data device
79-
float * src0_ddf = (float *) src0->data;
80-
float * src1_ddf = use_src1 ? (float *) src1->data : nullptr;
81-
float * dst_ddf = (float *) dst->data;
82-
83-
ggml_sycl_pool_alloc<float> src0_f(ctx.pool());
84-
ggml_sycl_pool_alloc<float> src1_f(ctx.pool());
85-
ggml_sycl_pool_alloc<float> dst_f(ctx.pool());
86-
87-
ggml_sycl_set_device(ctx.device);
88-
queue_ptr main_stream = ctx.stream();
89-
// GGML_SYCL_DEBUG("ctx.device=%d, main_stream=%p src0_on_device=%d, src1_on_device=%d, dst_on_device=%d\n",
90-
// ctx.device, main_stream, src0_on_device, src1_on_device, dst_on_device);
91-
92-
// do the computation
93-
op(ctx, src0, src1, dst, src0_ddf, src1_ddf, dst_ddf, main_stream);
94-
// print_ggml_tensor("tensor", dst);
95-
}
96-
catch (sycl::exception const &exc) {
97-
98-
std::cerr << exc.what() << "Exception caught at file:" << __FILE__
99-
<< ", line:" << __LINE__ << std::endl;
100-
std::exit(1);
101-
}
102-
103-
10469
void release_extra_gpu(ggml_tensor_extra_gpu * extra, std::vector<queue_ptr> streams) {
10570
for (int i = 0; i < ggml_sycl_info().device_count; ++i) {
10671
for (int64_t is = 0; is < GGML_SYCL_MAX_STREAMS; ++is) {

ggml/src/ggml-sycl/common.hpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,6 @@ static __dpct_inline__ Tp* get_pointer(sycl::local_accessor<Tp, dim> acc) {
463463

464464
int64_t downsample_sycl_global_range(int64_t accumulate_block_num, int64_t block_size);
465465

466-
typedef void (*ggml_sycl_op_flatten_t)(ggml_backend_sycl_context & ctx, const ggml_tensor *src0,
467-
const ggml_tensor *src1,
468-
ggml_tensor *dst, const float *src0_dd,
469-
const float *src1_dd, float *dst_dd,
470-
const queue_ptr &main_stream);
471-
472466
template<float (*bin_op)(const float, const float), typename src0_t, typename src1_t, typename dst_t>
473467
static void k_bin_bcast(const src0_t * src0, const src1_t * src1, dst_t * dst,
474468
int ne0, int ne1, int ne2, int ne3,
@@ -691,24 +685,23 @@ struct bin_bcast_sycl {
691685

692686
template <class op>
693687
inline void ggml_sycl_op_bin_bcast(ggml_backend_sycl_context & ctx, const ggml_tensor *src0,
694-
const ggml_tensor *src1, ggml_tensor *dst,
695-
const float *src0_dd, const float *src1_dd,
696-
float *dst_dd,
697-
const queue_ptr &main_stream) {
688+
const ggml_tensor *src1, ggml_tensor *dst) {
689+
/*TODO: Refactor bbincast */
690+
dpct::queue_ptr main_stream = ctx.stream();
698691

699692
if (src0->type == GGML_TYPE_F32 && dst->type == GGML_TYPE_F32) {
700-
op()(ctx, src0, src1, dst, src0_dd, src1_dd, dst_dd, main_stream);
693+
op()(ctx, src0, src1, dst, (const float *)src0->data, (const float *)src1->data, (float *)dst->data, main_stream);
701694
} else if (src0->type == GGML_TYPE_F16 && dst->type == GGML_TYPE_F16) {
702-
op()(ctx, src0, src1, dst, (const sycl::half *)src0_dd, src1_dd,
703-
(sycl::half *)dst_dd, main_stream);
695+
op()(ctx, src0, src1, dst, (const sycl::half *)src0->data, (const float *)src1->data,
696+
(sycl::half *)dst->data, main_stream);
704697
} else if (src0->type == GGML_TYPE_F16 && dst->type == GGML_TYPE_F32) {
705-
op()(ctx, src0, src1, dst, (const sycl::half *)src0_dd, src1_dd, dst_dd,
698+
op()(ctx, src0, src1, dst, (const sycl::half *)src0->data, (const float *)src1->data, (float *)dst->data,
706699
main_stream);
707700
} else if (src0->type == GGML_TYPE_I32 && dst->type == GGML_TYPE_I32) {
708-
op()(ctx, src0, src1, dst, (const int32_t *)src0_dd, (const int32_t *)src1_dd, (int32_t *)dst_dd,
701+
op()(ctx, src0, src1, dst, (const int32_t *)src0->data, (const int32_t *)src1->data, (int32_t *)dst->data,
709702
main_stream);
710703
} else if (src0->type == GGML_TYPE_I16 && dst->type == GGML_TYPE_I16) {
711-
op()(ctx, src0, src1, dst, (const int16_t *)src0_dd, (const int16_t *)src1_dd, (int16_t *)dst_dd,
704+
op()(ctx, src0, src1, dst, (const int16_t *)src0->data, (const int16_t *)src1->data, (int16_t *)dst->data,
712705
main_stream);
713706
} else {
714707
fprintf(stderr, "%s: unsupported types: dst: %s, src0: %s, src1: %s\n", __func__,
@@ -718,8 +711,4 @@ inline void ggml_sycl_op_bin_bcast(ggml_backend_sycl_context & ctx, const ggml_t
718711
}
719712

720713
bool gpu_has_xmx(sycl::device &dev);
721-
722-
void ggml_sycl_op_flatten(ggml_backend_sycl_context & ctx, const ggml_tensor *src0,
723-
const ggml_tensor *src1, ggml_tensor *dst,
724-
const ggml_sycl_op_flatten_t op);
725714
#endif // GGML_SYCL_COMMON_HPP

0 commit comments

Comments
 (0)