提交 fe915901 编写于 作者: L luotao1

update Opdesc's HasAttr

test=develop
上级 6776e928
......@@ -237,6 +237,17 @@ void OpDesc::SetOutput(const std::string &param_name,
this->outputs_[param_name] = args;
}
bool OpDesc::HasAttr(const std::string &name) const {
const proto::OpProto &proto = OpInfoMap::Instance().Get(desc_.type()).Proto();
for (int i = 0; i != proto.attrs_size(); ++i) {
const proto::OpProto::Attr &attr = proto.attrs(i);
if (attr.name() == name) {
return true;
}
}
return false;
}
proto::AttrType OpDesc::GetAttrType(const std::string &name) const {
auto it = attrs_.find(name);
PADDLE_ENFORCE(it != attrs_.end(), "Attribute %s is not found", name);
......
......@@ -61,9 +61,7 @@ class OpDesc {
void SetOutput(const std::string &param_name,
const std::vector<std::string> &args);
bool HasAttr(const std::string &name) const {
return attrs_.find(name) != attrs_.end();
}
bool HasAttr(const std::string &name) const;
proto::AttrType GetAttrType(const std::string &name) const;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册