未验证 提交 c2150d11 编写于 作者: H huzhiqiang 提交者: GitHub

[Framework] Remove some useless op_attributes to reduce memory usage and model size (#4052)

上级 7ba5c331
...@@ -153,11 +153,19 @@ void OpAttrsAnyToCpp(const OpDescType &any_desc, cpp::OpDesc *cpp_desc) { ...@@ -153,11 +153,19 @@ void OpAttrsAnyToCpp(const OpDescType &any_desc, cpp::OpDesc *cpp_desc) {
LOG(FATAL) << "Unsupported attr type found " << static_cast<int>(type); LOG(FATAL) << "Unsupported attr type found " << static_cast<int>(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<std::string> skiped_attributes = {"op_callstack",
"op_namescope",
"op_role",
"workspace_size_MB",
"op_role_var"};
for (const auto &attr_name : any_desc.AttrNames()) { for (const auto &attr_name : any_desc.AttrNames()) {
// note: since `op_callstack` attribute has no effect on inference process, auto it = std::find(
// we will not load it into op_desc. skiped_attributes.begin(), skiped_attributes.end(), attr_name);
if (attr_name != "op_callstack") { if (it == skiped_attributes.end()) {
auto type = any_desc.GetAttrType(attr_name); auto type = any_desc.GetAttrType(attr_name);
set_attr(attr_name, type); set_attr(attr_name, type);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册