forked from halide/Halide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix two minor bugs triggered by an or reduction with early-out (halid…
…e#6807) * Fix two minor bugs triggered by a or reduction with early-out * Gotta print success * Appease clang-tidy
- Loading branch information
Showing
4 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "Halide.h" | ||
|
||
using namespace Halide; | ||
|
||
int main(int argc, char **argv) { | ||
// This is a test case that performs an or reduction using a where clause to | ||
// get early-out behavior on the reduction loop. It triggered two bugs. | ||
// | ||
// First, there's a param that's only used in a specialization of a wrapper | ||
// func, and this wasn't picked up by InferArguments. | ||
// | ||
// Second, there's a variable-free condition | ||
// that feeds into bounds inference (test()), and bounds inference assumed | ||
// that being variable-free meant it only depended on params and could be | ||
// lifted out into a bounds expression. | ||
// | ||
// Both of these bugs caused compilation failures, so this test just | ||
// verifies that things compile. | ||
|
||
Param<int> height; | ||
|
||
Var y; | ||
|
||
Func test_rows("test_rows"); | ||
test_rows(y) = y < 100; | ||
|
||
Func test("test"); | ||
test() = cast<bool>(false); | ||
RDom ry(0, 1024); | ||
ry.where(!test()); | ||
test() = test_rows(ry); | ||
|
||
Func output; | ||
output() = select(test(), cast<uint8_t>(0), cast<uint8_t>(1)); | ||
|
||
Expr num_slices = (height + 255) / 256; | ||
Expr slice_size = (height + num_slices - 1) / num_slices; | ||
|
||
test_rows.in() | ||
.compute_root() | ||
.specialize(height > slice_size) | ||
.parallel(y, slice_size, TailStrategy::ShiftInwards); | ||
|
||
output.compile_jit(); | ||
|
||
printf("Success!\n"); | ||
|
||
return 0; | ||
} |