Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw an erorr if split is called with the same older and inner var name #7715

Merged
merged 7 commits into from
Jul 27, 2023
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
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;
}