Skip to content

Commit

Permalink
[CINN] Re-Implement operator = for two Expr Tree (PaddlePaddle#55145)
Browse files Browse the repository at this point in the history
* optimize expr operator = implementation

* fix codestyle
  • Loading branch information
Courtesy-Xs authored and cqulilujia committed Jul 24, 2023
1 parent 2d1d11a commit f3bbb03
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions paddle/cinn/hlir/framework/op_lowering_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@ bool CanbeInline(Node* node,
}

auto& op_pattern_dict = Operator::GetAttrs<OpPatternKind>("OpPattern");

for (auto consumer : consumers) {
if (op_pattern_dict[consumer->op()] == framework::kReduction) {
return false;
Expand Down
5 changes: 3 additions & 2 deletions paddle/cinn/ir/ir_visitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <unordered_set>

#include "paddle/cinn/ir/ir_compare.h"
#include "paddle/cinn/ir/ir_printer.h"
#include "paddle/cinn/ir/tensor.h"
#include "paddle/cinn/utils/string.h"
Expand All @@ -25,8 +26,8 @@ namespace ir {

bool operator==(Expr a, Expr b) {
if (a.get() == b.get()) return true;
// TODO(Superjomn) implement with a more accurate one
return utils::GetStreamCnt(a) == utils::GetStreamCnt(b);
IrEqualVisitor cmp;
return cmp.Compare(a, b);
}

bool operator!=(Expr a, Expr b) { return !(a == b); }
Expand Down
1 change: 1 addition & 0 deletions paddle/fluid/framework/paddle2cinn/cinn_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const CinnCompiledObject &CinnCompiler::Compile(

auto compiled_res =
CompileGraph(graph, input_tensors, target, compiled_num, stream);

std::unique_lock<std::mutex> guard(lock_);
// double check cache_by_struct_
if (!cache_by_struct_.count(cur_key_by_struct)) {
Expand Down

0 comments on commit f3bbb03

Please sign in to comment.