From ba4a34853103b81bef096a0956f4f74ce3e3429b Mon Sep 17 00:00:00 2001 From: zhaozhenlong Date: Fri, 24 Apr 2020 17:35:17 +0800 Subject: [PATCH] fix Cppcheck --- mindspore/ccsrc/transform/op_adapter_util.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mindspore/ccsrc/transform/op_adapter_util.cc b/mindspore/ccsrc/transform/op_adapter_util.cc index 0d9e56e510..07266c9eb2 100644 --- a/mindspore/ccsrc/transform/op_adapter_util.cc +++ b/mindspore/ccsrc/transform/op_adapter_util.cc @@ -38,18 +38,18 @@ std::vector ConvertAnyUtil(const ValuePtr &value, const std::string &na MS_EXCEPTION_IF_NULL(value); int64_t data = GetValue(value); std::vector list; - int size = 2; // 2 int in list if (name == "pad") { if (!value->isa()) { MS_LOG(EXCEPTION) << "Value should be ValueTuple, but got" << value->type_name(); } auto vec = value->cast(); - list.push_back(1); - list.push_back(1); - for (auto &it : vec->value()) { - list.push_back(static_cast(GetValue(it))); - } + list.resize(vec->value().size()+2); + list[0]=1; + list[1]=1; + (void)std::transform(vec->value().begin(), vec->value().end(), list.begin()+2, + [](const ValuePtr &val) { return static_cast(GetValue(val)); }); } else { + int size = 2; // 2 int in list list = TransformUtil::ConvertIntToList(data, size); }