Skip to content

Commit cb187a9

Browse files
committed
Fix too relaxed check on CUDA "fast copy" (can_be_transposed) condition
1 parent f66598e commit cb187a9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ggml/src/ggml-cuda/cpy.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ void ggml_cuda_cpy(ggml_backend_cuda_context & ctx, const ggml_tensor * src0, gg
384384
char * src1_ddc = (char *) src1->data;
385385

386386
const bool contiguous_srcs = ggml_is_contiguous(src0) && ggml_is_contiguous(src1);
387-
const bool can_be_transposed = nb01 == (int64_t)ggml_element_size(src0) && src0->ne[3] == 1;
387+
const bool can_be_transposed = nb01 == (int64_t)ggml_element_size(src0) &&
388+
src0->ne[3] == 1 && nb02 == ne00 * ne01 * (int64_t)ggml_element_size(src0);
388389

389390
if (src0->type == src1->type && contiguous_srcs) {
390391
GGML_ASSERT(ggml_nbytes(src0) == ggml_nbytes(src1));

0 commit comments

Comments
 (0)