未验证 提交 af58cc37 编写于 作者: 傅剑寒 提交者: GitHub

[CINN] Re-Implement operator = for two Expr Tree (#55145)

* optimize expr operator = implementation

* fix codestyle
上级 77e289ae
...@@ -825,6 +825,7 @@ bool CanbeInline(Node* node, ...@@ -825,6 +825,7 @@ bool CanbeInline(Node* node,
} }
auto& op_pattern_dict = Operator::GetAttrs<OpPatternKind>("OpPattern"); auto& op_pattern_dict = Operator::GetAttrs<OpPatternKind>("OpPattern");
for (auto consumer : consumers) { for (auto consumer : consumers) {
if (op_pattern_dict[consumer->op()] == framework::kReduction) { if (op_pattern_dict[consumer->op()] == framework::kReduction) {
return false; return false;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <unordered_set> #include <unordered_set>
#include "paddle/cinn/ir/ir_compare.h"
#include "paddle/cinn/ir/ir_printer.h" #include "paddle/cinn/ir/ir_printer.h"
#include "paddle/cinn/ir/tensor.h" #include "paddle/cinn/ir/tensor.h"
#include "paddle/cinn/utils/string.h" #include "paddle/cinn/utils/string.h"
...@@ -25,8 +26,8 @@ namespace ir { ...@@ -25,8 +26,8 @@ namespace ir {
bool operator==(Expr a, Expr b) { bool operator==(Expr a, Expr b) {
if (a.get() == b.get()) return true; if (a.get() == b.get()) return true;
// TODO(Superjomn) implement with a more accurate one IrEqualVisitor cmp;
return utils::GetStreamCnt(a) == utils::GetStreamCnt(b); return cmp.Compare(a, b);
} }
bool operator!=(Expr a, Expr b) { return !(a == b); } bool operator!=(Expr a, Expr b) { return !(a == b); }
......
...@@ -112,6 +112,7 @@ const CinnCompiledObject &CinnCompiler::Compile( ...@@ -112,6 +112,7 @@ const CinnCompiledObject &CinnCompiler::Compile(
auto compiled_res = auto compiled_res =
CompileGraph(graph, input_tensors, target, compiled_num, stream); CompileGraph(graph, input_tensors, target, compiled_num, stream);
std::unique_lock<std::mutex> guard(lock_); std::unique_lock<std::mutex> guard(lock_);
// double check cache_by_struct_ // double check cache_by_struct_
if (!cache_by_struct_.count(cur_key_by_struct)) { if (!cache_by_struct_.count(cur_key_by_struct)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册