Skip to content

Commit faeb7f3

Browse files
committed
feat(sycl): add contiguous tensor copy support and device checks
Adds a memcpy path for contiguous tensors of the same type to optimize data transfer. Updates device support checks to recognize contiguous tensor operations, improving compatibility and performance.
1 parent 608e881 commit faeb7f3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

ggml/src/ggml-sycl/cpy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "cpy.hpp"
22

33
#include <float.h>
4+
#include <string>
45

56
#include "dequantize.hpp"
67
#include "ggml-sycl/common.hpp"
@@ -759,9 +760,8 @@ void ggml_sycl_cpy(ggml_backend_sycl_context & ctx, const ggml_tensor * src0, co
759760

760761
char * src0_ddc = (char *) src0->data;
761762
char * src1_ddc = (char *) src1->data;
762-
GGML_SYCL_DEBUG("[SYCL] %s: Tensor supplied: %s to %s\n", __func__, ggml_type_name(src0->type),
763-
ggml_type_name(src1->type));
764763
if ((src0->type == src1->type) && (ggml_is_contiguous(src0) && ggml_is_contiguous(src1))) {
764+
GGML_SYCL_DEBUG("%s: memcpy path\n", __func__);
765765
main_stream->memcpy(src1_ddc, src0_ddc, ggml_nbytes(src0));
766766
} else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_F32) {
767767
ggml_cpy_f32_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,

ggml/src/ggml-sycl/ggml-sycl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4226,6 +4226,9 @@ static bool ggml_backend_sycl_device_supports_op(ggml_backend_dev_t dev, const g
42264226
{
42274227
ggml_type src0_type = op->src[0]->type;
42284228
ggml_type src1_type = op->src[1]->type;
4229+
if (src0_type == src1_type && (ggml_is_contiguous(op->src[0]) && ggml_is_contiguous(op->src[1]))) {
4230+
return true;
4231+
}
42294232
if (src0_type == GGML_TYPE_F32 && src1_type == GGML_TYPE_F32) {
42304233
return true;
42314234
}

0 commit comments

Comments
 (0)