-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[stdlib] Improve type refinement for pack_bits
#4345
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
Conversation
| return DType.uint64 | ||
| # fmt: off | ||
| return ( | ||
| DType.uint8 if n == 8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the if expression since hlcf.if is not supported in builtin.
7069a15 to
103f2d7
Compare
Signed-off-by: Yiwu Chen <210at85@gmail.com>
103f2d7 to
136ec29
Compare
|
!sync |
|
✅🟣 This contribution has been merged 🟣✅ Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the main branch during the next Mojo nightly release, typically within the next 24-48 hours. We use Copybara to merge external contributions, click here to learn more. |
|
Landed in a638dc7! Thank you for your contribution 🎉 |
|
Thanks @soraros . Just catching up: the point of always_inline(builtin) isn't to inline everything that "could be constant folded". It is really about things that are necessary to use in dependent types. There is longer term work to improve the Mojo intepreter that may make it more powerful - this will be useful for this sort of thing as well as for requires clauses - but the parser-time interpreter will always be limited to not knowing about the target (e.g. pointer sizes) so it will be inherently limited in what it can do. |
[External] [stdlib] Improve type refinement for `pack_bits` So the following works without `rebind`: ```mojo var v: UInt8 = pack_bits(SIMD[DType.bool, 8](1)) ``` `_uint` gets inlined even when `n` isn't concrete, cluttering tooltips and types. Can call-by-value be triggered only when `n` is concrete? CC @lattner since it's related to `@always_inline("builtin")`. Co-authored-by: soraros <soraros@users.noreply.github.com> Closes #4345 MODULAR_ORIG_COMMIT_REV_ID: e5fea6172778283a2b9cb7999e82702f2da8ba1a
So the following works without
rebind:_uintgets inlined even whennisn't concrete, cluttering tooltips and types.Can call-by-value be triggered only when
nis concrete?CC @lattner since it's related to
@always_inline("builtin").