From bdcc2ad46699d19065bfcd248a755ee9b4fb9982 Mon Sep 17 00:00:00 2001 From: baoachun <962571062@qq.com> Date: Mon, 25 Oct 2021 14:15:34 +0800 Subject: [PATCH] fix interpolate mkldnn op error (#36662) --- paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc index 90f0de60b59..f567f466053 100644 --- a/paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc @@ -104,8 +104,10 @@ class InterpolateMKLDNNKernel : public framework::OpKernel { scale.push_back(scale[0]); } else { // v2 std::vector scale_attr = ctx.Attr>("scale"); - scale.resize(3, scale_attr[0]); - std::copy(scale_attr.begin(), scale_attr.end(), scale.begin()); + if (scale_attr.size() > 0) { + scale.resize(3, scale_attr[0]); + std::copy(scale_attr.begin(), scale_attr.end(), scale.begin()); + } } } if (scale[0] > 0.0f && scale[1] > 0.0f && scale[2] > 0.0f) { -- GitLab