-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python_bindings: acquire GIL before printing
- Loading branch information
Showing
2 changed files
with
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import halide as hl | ||
from io import StringIO | ||
from contextlib import redirect_stdout | ||
|
||
|
||
def test_warnings(): | ||
i = hl.Var() | ||
f = hl.Func("f") | ||
f[i] = 0.0 | ||
f.bound(i, 0, 127) | ||
|
||
g = hl.Func("g") | ||
g[i] = f[i * i] | ||
|
||
expected_warning = "Warning: It is meaningless to bound dimension v0 of function f to be within [0, 127] because " \ | ||
"the function is scheduled inline.\n" | ||
|
||
buffer = StringIO() | ||
with redirect_stdout(buffer): | ||
g.realize([16]) | ||
|
||
buffer.seek(0) | ||
stdout_lines = buffer.readlines() | ||
assert stdout_lines == [expected_warning] * 3 | ||
|
||
|
||
if __name__ == '__main__': | ||
test_warnings() |
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