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

[Lang] Add ti.static_assert for compile-time assertations #1344

Merged
merged 26 commits into from
Jul 5, 2020

Conversation

archibate
Copy link
Collaborator

@archibate archibate commented Jun 27, 2020

Related issue = #

[Click here for the format server]


  • TODO: add check_out_of_bound doc too.

@archibate archibate requested a review from Rullec June 27, 2020 14:09
@codecov
Copy link

codecov bot commented Jun 27, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@28e005c). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1344   +/-   ##
=========================================
  Coverage          ?   66.76%           
=========================================
  Files             ?       37           
  Lines             ?     5197           
  Branches          ?      933           
=========================================
  Hits              ?     3470           
  Misses            ?     1566           
  Partials          ?      161           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 28e005c...bd2e4a3. Read the comment docs.

docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@isdanni isdanni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 🚀 🎸

docs/debugging.rst Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
def is_odd(x: ti.template()):
ti.static_assert(x.data_type() == ti.i32, "is_odd() is only supported for i32")
return x % 2 == 1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may give ti.static_assert a function demonstration here? so that people can realize it receive 2 parameters, the first one is assert expresstion and the second is a statement.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought all Python users who know assert knows this failure message feature?

docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
@Rullec
Copy link
Contributor

Rullec commented Jun 28, 2020

Good morning @archibate !

Thanks for your hard work! It's a very nice doc that explains the usage of debugging tools clearly. only + few nits.

docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
Co-authored-by: Yuanming Hu <[email protected]>
Co-authored-by: Xudong Feng <[email protected]>
Co-authored-by: Danni <[email protected]>
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@isdanni isdanni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing much for me to add here! 🚀

@archibate archibate added python Python engineering related large changeset The PR contains a large changeset and reviewing may take times labels Jul 2, 2020
@archibate archibate requested a review from isdanni July 3, 2020 16:59
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
Copy link
Member

@yuanming-hu yuanming-hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! LGTM except for a few more wording nits.

docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
docs/debugging.rst Outdated Show resolved Hide resolved
@archibate archibate requested a review from yuanming-hu July 4, 2020 03:38
@archibate
Copy link
Collaborator Author

Great! I'll merge once CI pass, hope our doc&tools could help users to debug their program easier!

@archibate archibate added doc Documentation related issues & PRs and removed large changeset The PR contains a large changeset and reviewing may take times labels Jul 4, 2020
Copy link
Member

@yuanming-hu yuanming-hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I think this PR is ready to merge anytime.

tests/python/test_assert.py Outdated Show resolved Hide resolved
@archibate archibate merged commit eb40824 into taichi-dev:master Jul 5, 2020
@FantasyVR FantasyVR mentioned this pull request Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Documentation related issues & PRs python Python engineering related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants