Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions paddle/cinn/common/integer_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ cas_intervals_t CollectVarIntervalsOfExprs(const std::vector<ir::Expr>& exprs,
if (var->upper_bound.defined()) {
upper_bound = var->upper_bound;
}
if (var->is_symbolic_constant) {
lower_bound = ir::Expr(1);
}
var_intervals.insert(
{var->name, CasInterval(lower_bound, upper_bound)});
}
Expand Down Expand Up @@ -118,32 +121,32 @@ std::optional<bool> SymbolicExprAnalyzer::ProveGE(const ir::Expr& lhs,
if (lhs == rhs) {
return true;
}
if (lhs == SymbolicExprLimit::positive_inf ||
rhs == SymbolicExprLimit::negative_inf) {
return true;
}
if (rhs == SymbolicExprLimit::positive_inf ||
lhs == SymbolicExprLimit::negative_inf) {
return false;
}
ir::Expr diff = AutoSimplify(ir::Sub::Make(lhs, rhs), var_intervals_);
VLOG(6) << "diff of " << ir::Sub::Make(lhs, rhs) << " = " << diff;
if (diff.is_constant() && diff.get_constant() >= 0) {
if (lhs == SymbolicExprLimit::positive_inf ||
rhs == SymbolicExprLimit::negative_inf) {
return true;
}
ir::Expr diff = AutoSimplify(ir::Sub::Make(lhs, rhs), var_intervals_);
VLOG(6) << "diff of " << ir::Sub::Make(lhs, rhs) << " = " << diff;
if (diff.is_constant() && diff.get_constant() < 0) {
return false;
}
ir::Expr diff_lower_bound = LowerBound(diff);
VLOG(6) << "lower bound of " << diff << " = " << diff_lower_bound;
if (diff_lower_bound.is_constant() && diff_lower_bound.get_constant() >= 0) {
if (diff.is_constant() && diff.get_constant() >= 0) {
return true;
}
ir::Expr diff_upper_bound = UpperBound(diff);
VLOG(6) << "upper bound of " << diff << " = " << diff_upper_bound;
if (diff_upper_bound.is_constant() && diff_upper_bound.get_constant() < 0) {
return false;
}
ir::Expr diff_lower_bound = LowerBound(diff);
VLOG(6) << "lower bound of " << diff << " = " << diff_lower_bound;
if (diff_lower_bound.is_constant() && diff_lower_bound.get_constant() >= 0) {
return true;
}
return std::nullopt;
}

Expand All @@ -157,32 +160,33 @@ std::optional<bool> SymbolicExprAnalyzer::ProveGT(const ir::Expr& lhs,
if (lhs == rhs) {
return false;
}
if (lhs == SymbolicExprLimit::positive_inf ||
rhs == SymbolicExprLimit::negative_inf) {
return true;
}
if (rhs == SymbolicExprLimit::positive_inf ||
lhs == SymbolicExprLimit::negative_inf) {
return false;
}
ir::Expr diff = AutoSimplify(ir::Sub::Make(lhs, rhs), var_intervals_);
VLOG(6) << "diff of " << ir::Sub::Make(lhs, rhs) << " = " << diff;
if (diff.is_constant() && diff.get_constant() > 0) {
if (lhs == SymbolicExprLimit::positive_inf ||
rhs == SymbolicExprLimit::negative_inf) {
return true;
}
ir::Expr diff = AutoSimplify(ir::Sub::Make(lhs, rhs), var_intervals_);
VLOG(6) << "diff of " << ir::Sub::Make(lhs, rhs) << " = " << diff;
if (diff.is_constant() && diff.get_constant() <= 0) {
return false;
}
ir::Expr diff_lower_bound = LowerBound(diff);
VLOG(6) << "lower bound of " << diff << " = " << diff_lower_bound;
if (diff_lower_bound.is_constant() && diff_lower_bound.get_constant() > 0) {
if (diff.is_constant() && diff.get_constant() > 0) {
return true;
}
ir::Expr diff_upper_bound = UpperBound(diff);
VLOG(6) << "upper bound of " << diff << " = " << diff_upper_bound;
if (diff_upper_bound.is_constant() && diff_upper_bound.get_constant() <= 0) {
return false;
}
ir::Expr diff_lower_bound = LowerBound(diff);
VLOG(6) << "lower bound of " << diff << " = " << diff_lower_bound;
if (diff_lower_bound.is_constant() && diff_lower_bound.get_constant() > 0) {
return true;
}

return std::nullopt;
}

Expand Down
22 changes: 22 additions & 0 deletions paddle/cinn/ir/group_schedule/tactic/tile_first_general_tactic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,36 @@ void TileFirstGeneralTactic::Apply(ir::IRSchedule* sch,
const std::string& block_id) {
if (ir::IsReduceInitTensorName(block_id)) return;
MergeFlattenAxis(sch, block_id);
VLOG(6) << "After MergeFlattenAxis on block: [" << block_id
<< "], loop nest:\n"
<< sch->GetLoops(block_id)[0];
MergeReduceAxis(sch, block_id);
VLOG(6) << "After MergeReduceAxis on block: [" << block_id
<< "], loop nest:\n"
<< sch->GetLoops(block_id)[0];
SplitFlattenInner(sch, block_id);
VLOG(6) << "After SplitFlattenInner on block: [" << block_id
<< "], loop nest:\n"
<< sch->GetLoops(block_id)[0];
SplitReduceInner(sch, block_id);
VLOG(6) << "After SplitReduceInner on block: [" << block_id
<< "], loop nest:\n"
<< sch->GetLoops(block_id)[0];
ReorderFlattenInnerWithReduceAxis(sch, block_id);
VLOG(6) << "After ReorderFlattenInnerWithReduceAxis on block: [" << block_id
<< "], loop nest:\n"
<< sch->GetLoops(block_id)[0];
SplitWarpNumber(sch, block_id);
VLOG(6) << "After SplitWarpNumber on block: [" << block_id
<< "], loop nest:\n"
<< sch->GetLoops(block_id)[0];
BindCudaInfo(sch, block_id);
VLOG(6) << "After BindCudaInfo on block: [" << block_id << "], loop nest:\n"
<< sch->GetLoops(block_id)[0];
VariableTypeAssignment(sch, block_id);
Unroll(sch, block_id);
VLOG(6) << "After Unroll on block: [" << block_id << "], loop nest:\n"
<< sch->GetLoops(block_id)[0];
SetReduceType(sch, block_id);
}

Expand Down