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

add an assert primitive #8773

Merged
merged 1 commit into from Dec 2, 2021
Merged

add an assert primitive #8773

merged 1 commit into from Dec 2, 2021

Conversation

mattjj
Copy link
Member

@mattjj mattjj commented Dec 2, 2021

The assert primitive has an effectful API and so it can't be staged out; it's only a trace-time primitive. It can be discharged to the functional form.

We might want to have separate transforms for discharging errors and for adding error checks. But right now they're just bundled together in the checkify transform.

The assert primitive has an effectful API and so it can't be staged out;
it's only a trace-time primitive. It can be discharged to the functional
form.

We might want to have separate transforms for discharging errors and for
adding error checks. But right now they're just bundled together in the
checkify transform.
@mattjj mattjj added the pull ready Ready for copybara import and testing label Dec 2, 2021
@google-cla google-cla bot added the cla: yes label Dec 2, 2021
@@ -212,6 +214,24 @@ def check_errors_traceable(msgs, err, code, *args):
yield outs


## assert primitive

def assert_(pred: Bool, msg: str) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could probably use a nicer public symbol name, but we can think of that later? I guess you're not supposed to overwrite keywords, and we can't provide a checkify.assert?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can't overwrite assert actually; it's a syntax error. (I tried, of course!)

You're right that this name is bad. But what's a good one? jassert? assert2? asssert? jax_assert? buttert? (Brainstormed those with @skye...)

Copy link
Member Author

Choose a reason for hiding this comment

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

allege?

Copy link
Contributor

@LenaMartens LenaMartens left a comment

Choose a reason for hiding this comment

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

LGTM!

@copybara-service copybara-service bot merged commit 250d160 into google:main Dec 2, 2021
@mattjj mattjj deleted the checkify branch December 2, 2021 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes pull ready Ready for copybara import and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants