Skip to content

Commit

Permalink
Remove PurifyRVar split type.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreinking committed Dec 11, 2024
1 parent 87e5242 commit c4fef0c
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 67 deletions.
4 changes: 0 additions & 4 deletions src/ApplySplit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ vector<ApplySplitResult> apply_split(const Split &split, const string &prefix,
}
} break;
case Split::RenameVar:
case Split::PurifyRVar:
result.emplace_back(prefix + split.old_var, outer, ApplySplitResult::Substitution);
result.emplace_back(prefix + split.old_var, outer, ApplySplitResult::LetStmt);
break;
Expand Down Expand Up @@ -201,9 +200,6 @@ vector<std::pair<string, Expr>> compute_loop_bounds_after_split(const Split &spl
let_stmts.emplace_back(prefix + split.outer + ".loop_max", old_var_max);
let_stmts.emplace_back(prefix + split.outer + ".loop_extent", old_var_extent);
break;
case Split::PurifyRVar:
// Do nothing for purify
break;
}

return let_stmts;
Expand Down
2 changes: 0 additions & 2 deletions src/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ Split::SplitType Deserializer::deserialize_split_type(Serialize::SplitType split
return Split::SplitType::RenameVar;
case Serialize::SplitType::FuseVars:
return Split::SplitType::FuseVars;
case Serialize::SplitType::PurifyRVar:
return Split::SplitType::PurifyRVar;
default:
user_error << "unknown split type " << (int)split_type << "\n";
return Split::SplitType::SplitVar;
Expand Down
48 changes: 0 additions & 48 deletions src/Func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ void check_for_race_conditions_in_split_with_blend(const StageSchedule &sched) {
}
break;
case Split::RenameVar:
case Split::PurifyRVar:
if (parallel.count(split.outer)) {
parallel.insert(split.old_var);
}
Expand All @@ -454,7 +453,6 @@ void check_for_race_conditions_in_split_with_blend(const StageSchedule &sched) {
}
break;
case Split::RenameVar:
case Split::PurifyRVar:
if (parallel.count(split.old_var)) {
parallel.insert(split.outer);
}
Expand Down Expand Up @@ -793,7 +791,6 @@ pair<vector<Split>, vector<Split>> Stage::rfactor_validate_args(const std::vecto
var_splits.emplace_back(split);
}
break;
case Split::PurifyRVar:
case Split::RenameVar:
if (rdims.contains(split.old_var)) {
rdims.pop(split.old_var);
Expand Down Expand Up @@ -1068,7 +1065,6 @@ void Stage::split(const string &old, const string &outer, const string &inner, c
}
break;
case Split::RenameVar:
case Split::PurifyRVar:
if (inner_vars.count(s.old_var)) {
inner_vars.insert(s.outer);
}
Expand Down Expand Up @@ -1103,7 +1099,6 @@ void Stage::split(const string &old, const string &outer, const string &inner, c
}
break;
case Split::RenameVar:
case Split::PurifyRVar:
if (inner_vars.count(s.old_var)) {
inner_vars.insert(s.outer);
}
Expand Down Expand Up @@ -1165,7 +1160,6 @@ void Stage::split(const string &old, const string &outer, const string &inner, c
}
break;
case Split::RenameVar:
case Split::PurifyRVar:
if (it != descends_from_shiftinwards_outer.end()) {
descends_from_shiftinwards_outer[s.outer] = it->second;
}
Expand Down Expand Up @@ -1352,46 +1346,6 @@ void Stage::specialize_fail(const std::string &message) {
s.failure_message = message;
}

Stage &Stage::purify(const VarOrRVar &old_var, const VarOrRVar &new_var) {
user_assert(old_var.is_rvar && !new_var.is_rvar)
<< "In schedule for " << name()
<< ", can't rename " << (old_var.is_rvar ? "RVar " : "Var ") << old_var.name()
<< " to " << (new_var.is_rvar ? "RVar " : "Var ") << new_var.name()
<< "; purify must take a RVar as old_Var and a Var as new_var\n";

debug(4) << "In schedule for " << name() << ", purify RVar "
<< old_var.name() << " to Var " << new_var.name() << "\n";

StageSchedule &schedule = definition.schedule();

// Replace the old dimension with the new dimensions in the dims list
bool found = false;
string old_name, new_name = new_var.name();
vector<Dim> &dims = schedule.dims();

for (size_t i = 0; (!found) && i < dims.size(); i++) {
if (dim_match(dims[i], old_var)) {
found = true;
old_name = dims[i].var;
dims[i].var = new_name;
dims[i].dim_type = DimType::PureVar;
}
}

if (!found) {
user_error
<< "In schedule for " << name()
<< ", could not find rename dimension: "
<< old_var.name()
<< "\n"
<< dump_argument_list();
}

Split split = {old_name, new_name, "", 1, false, TailStrategy::RoundUp, Split::PurifyRVar};
definition.schedule().splits().push_back(split);
return *this;
}

void Stage::remove(const string &var) {
debug(4) << "In schedule for " << name() << ", remove " << var << "\n";

Expand Down Expand Up @@ -1469,7 +1423,6 @@ void Stage::remove(const string &var) {
}
break;
case Split::RenameVar:
case Split::PurifyRVar:
debug(4) << " replace/rename " << split.old_var
<< " into " << split.outer << "\n";
if (should_remove(split.outer)) {
Expand Down Expand Up @@ -1558,7 +1511,6 @@ Stage &Stage::rename(const VarOrRVar &old_var, const VarOrRVar &new_var) {
break;
case Split::SplitVar:
case Split::RenameVar:
case Split::PurifyRVar:
if (split.inner == old_name) {
split.inner = new_name;
found = true;
Expand Down
1 change: 0 additions & 1 deletion src/Func.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class Stage {
void split(const std::string &old, const std::string &outer, const std::string &inner,
const Expr &factor, bool exact, TailStrategy tail);
void remove(const std::string &var);
Stage &purify(const VarOrRVar &old_name, const VarOrRVar &new_name);

const std::vector<Internal::StorageDim> &storage_dims() const {
return function.schedule().storage_dims();
Expand Down
2 changes: 0 additions & 2 deletions src/Inline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ void validate_schedule_inlined_function(Function f) {
<< split.inner << " because "
<< f.name() << " is scheduled inline.\n";

break;
case Split::PurifyRVar:
break;
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/Schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,19 +332,14 @@ struct Split {

enum SplitType { SplitVar = 0,
RenameVar,
FuseVars,
PurifyRVar };
FuseVars };

// If split_type is Rename, then this is just a renaming of the
// old_var to the outer and not a split. The inner var should
// be ignored, and factor should be one. Renames are kept in
// the same list as splits so that ordering between them is
// respected.

// If split type is Purify, this replaces the old_var RVar to
// the outer Var. The inner var should be ignored, and factor
// should be one.

// If split_type is Fuse, then this does the opposite of a
// split, it joins the outer and inner into the old_var.
SplitType split_type;
Expand Down
1 change: 0 additions & 1 deletion src/ScheduleFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,6 @@ bool validate_schedule(Function f, const Stmt &s, const Target &target, bool is_
}
break;
case Split::RenameVar:
case Split::PurifyRVar:
if (parallel_vars.count(split.outer)) {
parallel_vars.insert(split.old_var);
}
Expand Down
2 changes: 0 additions & 2 deletions src/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,6 @@ Serialize::SplitType Serializer::serialize_split_type(const Split::SplitType &sp
return Serialize::SplitType::RenameVar;
case Split::SplitType::FuseVars:
return Serialize::SplitType::FuseVars;
case Split::SplitType::PurifyRVar:
return Serialize::SplitType::PurifyRVar;
default:
user_error << "Unsupported split type\n";
return Serialize::SplitType::SplitVar;
Expand Down
1 change: 0 additions & 1 deletion src/halide_ir.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,6 @@ enum SplitType: ubyte {
SplitVar,
RenameVar,
FuseVars,
PurifyRVar,
}

table Split {
Expand Down

0 comments on commit c4fef0c

Please sign in to comment.