From 7f408f97f41ae5ebeedc3f70b05e338e91044819 Mon Sep 17 00:00:00 2001 From: Jacek Czaja Date: Mon, 9 Aug 2021 14:19:18 +0200 Subject: [PATCH] - Faulty UT workaround --- .../operators/elementwise/mkldnn/elementwise_mkldnn_op.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/elementwise/mkldnn/elementwise_mkldnn_op.h b/paddle/fluid/operators/elementwise/mkldnn/elementwise_mkldnn_op.h index 77b57318383..51ad81b9dd4 100644 --- a/paddle/fluid/operators/elementwise/mkldnn/elementwise_mkldnn_op.h +++ b/paddle/fluid/operators/elementwise/mkldnn/elementwise_mkldnn_op.h @@ -54,8 +54,12 @@ class EltwiseMKLDNNKernel : public framework::OpKernel { const auto src_x_memory = handler.AcquireSrcMemory(x); const auto src_y_memory = handler.AcquireSecondSrcMemory(y); // For Inplace src and and dst are the same memory object - auto dst_memory = - x->IsSharedBufferWith(*z) ? src_x_memory : handler.AcquireDstMemory(z); + // (jczaja) UT mechanics is testing inplace for this op + // regardless shapes, which is wrong when X is to be broadcasted as output + // is of bigger shape that X. + auto dst_memory = (x->numel() == z->numel() && x->IsSharedBufferWith(*z)) + ? src_x_memory + : handler.AcquireDstMemory(z); const auto binary_prim = handler.AcquireForwardPrimitive(); -- GitLab