Skip to content

Commit

Permalink
refine code
Browse files Browse the repository at this point in the history
  • Loading branch information
zyfncg committed Aug 23, 2023
1 parent 7009ac4 commit cd8af21
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions paddle/fluid/ir/drr/api/drr_pattern_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ class NormalAttribute {
std::string attr_name_;
};

using AttrComputeFunc = std::function<std::any(const MatchContext&)>;

class ComputeAttribute {
public:
explicit ComputeAttribute(
const std::function<std::any(const MatchContext&)>& attr_compute_func)
explicit ComputeAttribute(const AttrComputeFunc& attr_compute_func)
: attr_compute_func_(attr_compute_func) {}

const std::function<std::any(const MatchContext&)>& attr_compute_func()
const {
const AttrComputeFunc& attr_compute_func() const {
return attr_compute_func_;
}

private:
std::function<std::any(const MatchContext&)> attr_compute_func_;
AttrComputeFunc attr_compute_func_;
};

using Attribute = std::variant<NormalAttribute, ComputeAttribute>;
Expand Down Expand Up @@ -267,8 +267,7 @@ class ResultPattern {
Attribute Attr(const std::string& attr_name) const {
return NormalAttribute(attr_name);
}
Attribute Attr(
std::function<std::any(const MatchContext&)> attr_compute_func) const {
Attribute Attr(const AttrComputeFunc& attr_compute_func) const {
return ComputeAttribute(attr_compute_func);
}

Expand Down

0 comments on commit cd8af21

Please sign in to comment.