From c2150d1157018c30dd842a9bc7e6ee321ca54206 Mon Sep 17 00:00:00 2001 From: huzhiqiang <912790387@qq.com> Date: Wed, 5 Aug 2020 20:04:17 +0800 Subject: [PATCH] [Framework] Remove some useless op_attributes to reduce memory usage and model size (#4052) --- lite/model_parser/compatible_pb.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lite/model_parser/compatible_pb.cc b/lite/model_parser/compatible_pb.cc index 44b26485e1..4167fa1629 100644 --- a/lite/model_parser/compatible_pb.cc +++ b/lite/model_parser/compatible_pb.cc @@ -153,11 +153,19 @@ void OpAttrsAnyToCpp(const OpDescType &any_desc, cpp::OpDesc *cpp_desc) { LOG(FATAL) << "Unsupported attr type found " << static_cast(type); } }; - + // On arm backend, some op attributes have no effect on inference process, we + // abandoned these attributes to reduce model_size and run-time memory usage. + // This process is operated on opt tool, so it will not increase + // initialization time. + std::vector skiped_attributes = {"op_callstack", + "op_namescope", + "op_role", + "workspace_size_MB", + "op_role_var"}; for (const auto &attr_name : any_desc.AttrNames()) { - // note: since `op_callstack` attribute has no effect on inference process, - // we will not load it into op_desc. - if (attr_name != "op_callstack") { + auto it = std::find( + skiped_attributes.begin(), skiped_attributes.end(), attr_name); + if (it == skiped_attributes.end()) { auto type = any_desc.GetAttrType(attr_name); set_attr(attr_name, type); } -- GitLab