Skip to content

Commit

Permalink
Throw an erorr if split is called with the same older and inner var n…
Browse files Browse the repository at this point in the history
…ame (#7715)

* throw an erorr if split is called with the same older and inner name

* update

* fix naming

* rewording

* add test

---------

Co-authored-by: Steven Johnson <srj@google.com>
  • Loading branch information
TH3CHARLie and steven-johnson committed Jul 27, 2023
1 parent 09c5d1d commit df4c981
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,12 @@ void Stage::split(const string &old, const string &outer, const string &inner, c

definition.schedule().touched() = true;

user_assert(inner != outer) << "In schedule for " << name()
<< ", can't split " << old << " into "
<< outer << " and " << inner
<< " because the new Vars have the same name.\n"
<< dump_argument_list();

// Check that the new names aren't already in the dims list.
for (auto &dim : dims) {
string new_names[2] = {inner, outer};
Expand Down
1 change: 1 addition & 0 deletions test/error/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ tests(GROUPS error
specialize_fail.cpp
split_inner_wrong_tail_strategy.cpp
split_non_innermost_predicated.cpp
split_same_var_names.cpp
thread_id_outside_block_id.cpp
too_many_args.cpp
tuple_arg_select_undef.cpp
Expand Down
13 changes: 13 additions & 0 deletions test/error/split_same_var_names.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "Halide.h"

using namespace Halide;

int main(int argc, char **argv) {
Var x;
Func f;
f(x) = x;
f.split(x, x, x, 16, TailStrategy::RoundUp);

printf("Success!\n");
return 0;
}

0 comments on commit df4c981

Please sign in to comment.