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

[Doc] Update debugging.md #6238

Merged
merged 1 commit into from
Oct 8, 2022
Merged
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: 5 additions & 1 deletion docs/lang/articles/debug/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,19 @@ You can use `assert` statements in the Taichi scope to verify the assertion cond
Ensure that you activate `debug` mode before using `assert` statements in the Taichi scope:

```python
import taichi as ti
ti.init(arch=ti.cpu, debug=True)

x = ti.field(ti.f32, 128)
x.fill(-1)

@ti.kernel
def do_sqrt_all():
for i in x:
assert x[i] >= 0
assert x[i] >= 0, f"The {i}-th element cannot be negative"
x[i] = ti.sqrt(x[i])

do_sqrt_all()
```

When you are done with debugging, set `debug=False`. Then, the program ignores all `assert` statements in the Taichi scope, which can avoid additional runtime overhead.
Expand Down