From 050a9bf79db17d581febf0554aa6526c785e278e Mon Sep 17 00:00:00 2001 From: Jacek Czaja Date: Wed, 8 Jul 2020 08:30:21 +0200 Subject: [PATCH] [oneDNN] LRN cleanup (#25416) --- paddle/fluid/operators/mkldnn/lrn_mkldnn_op.cc | 11 +---------- .../tests/unittests/mkldnn/test_lrn_mkldnn_op.py | 4 +++- .../unittests/white_list/no_check_set_white_list.py | 1 + 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/paddle/fluid/operators/mkldnn/lrn_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/lrn_mkldnn_op.cc index 4bfaeb41ee8..00c10cecbf4 100644 --- a/paddle/fluid/operators/mkldnn/lrn_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/lrn_mkldnn_op.cc @@ -59,15 +59,6 @@ class LRNMKLDNNOpKernel : public paddle::framework::OpKernel { {MKLDNN_ARG_DST, *dst_memory}, {MKLDNN_ARG_WORKSPACE, *workspace_memory}}); } else { - // mid has to be allocated and filled - // k to pass LRN unit tests - // TODO(jczaja): Disable checking mid in unit tests (Require API change) - mid->mutable_data(ctx.GetPlace()); - auto e_mid = framework::EigenTensor::From(*mid); - const float k = ctx.Attr("k"); - e_mid = e_mid.constant(k); - mid->set_format(platform::GetMKLDNNFormat(*dst_memory)); - lrn_p->execute(astream, {{MKLDNN_ARG_SRC, *src_memory}, {MKLDNN_ARG_DST, *dst_memory}}); } @@ -85,7 +76,7 @@ class LRNMKLDNNGradOpKernel : public paddle::framework::OpKernel { const bool is_float_type = std::is_same::value; PADDLE_ENFORCE_EQ(is_float_type, true, platform::errors::PreconditionNotMet( - "DNNL LRN GradOpKernl must use float data.")); + "DNNL LRN GradOpKernel must use float data.")); PADDLE_ENFORCE_EQ(platform::is_cpu_place(ctx.GetPlace()), true, paddle::platform::errors::PreconditionNotMet( "Operator DNNL LRNGrad must use CPUPlace")); diff --git a/python/paddle/fluid/tests/unittests/mkldnn/test_lrn_mkldnn_op.py b/python/paddle/fluid/tests/unittests/mkldnn/test_lrn_mkldnn_op.py index 5c9fccd4eca..ba7c8abc56d 100644 --- a/python/paddle/fluid/tests/unittests/mkldnn/test_lrn_mkldnn_op.py +++ b/python/paddle/fluid/tests/unittests/mkldnn/test_lrn_mkldnn_op.py @@ -26,8 +26,10 @@ class TestLRNMKLDNNOp(TestLRNOp): return attrs def test_check_output(self): + # We cannot validate MidOut as LRN REF has diffrent meaning in it # TODO(wangzhongpu): support mkldnn op in dygraph mode - self.check_output(atol=0.002, check_dygraph=False) + self.check_output( + atol=0.002, no_check_set=['MidOut'], check_dygraph=False) def test_check_grad_normal(self): # TODO(wangzhongpu): support mkldnn op in dygraph mode diff --git a/python/paddle/fluid/tests/unittests/white_list/no_check_set_white_list.py b/python/paddle/fluid/tests/unittests/white_list/no_check_set_white_list.py index 816e7c6ea09..19af0c92154 100644 --- a/python/paddle/fluid/tests/unittests/white_list/no_check_set_white_list.py +++ b/python/paddle/fluid/tests/unittests/white_list/no_check_set_white_list.py @@ -17,6 +17,7 @@ no_check_set_white_list = [ 'fake_quantize_range_abs_max', 'coalesce_tensor', 'flatten2', + 'lrn', 'squeeze2', 'reshape2', 'transpose2', -- GitLab