From d878f971f203446c97a64ed8ddc87f1dafa3c908 Mon Sep 17 00:00:00 2001 From: chentianyu03 Date: Mon, 9 May 2022 10:56:38 +0800 Subject: [PATCH] fix split stride_numel may be 0 (#42537) --- paddle/fluid/operators/strided_memcpy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddle/fluid/operators/strided_memcpy.h b/paddle/fluid/operators/strided_memcpy.h index 90cf4128aae..a9ee03e4473 100644 --- a/paddle/fluid/operators/strided_memcpy.h +++ b/paddle/fluid/operators/strided_memcpy.h @@ -134,7 +134,7 @@ inline void StridedMemcpyWithAxis0( for (size_t i = 0; i < outputs->size(); ++i) { auto out_stride = stride_numel(shape_refer[i]->dims()); auto out = outputs->at(i); - if (out != nullptr && out->initialized()) { + if (out != nullptr && out->initialized() && out->numel() > 0) { StridedNumelCopyWithAxis(dev_ctx, axis, out->data(), out_stride, input.data() + input_offset, in_stride, out_stride[axis]); -- GitLab