-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[stdlib] Update stdlib corresponding to 2024-05-03 nightly/mojo #2480
Merged
Conversation
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
[External] [stdlib] Removed FileCheck from the dev guide Related to modularml#2024 Co-authored-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com> Closes modularml#2451 MODULAR_ORIG_COMMIT_REV_ID: a32efb8642527372845fa6eeb43b997824f8f2be
Only one test case is failing in debug builds on Graviton; so, disable that one test only rather than the whole test file. We could do fancy things and keep the test enabled on other arch, but just disable the test for all arches right now for simplicity. MODULAR_ORIG_COMMIT_REV_ID: ee81e10cc7d6d6fb15fe6618674b75b7f3e800e2
…777) To achieve this, the patch also introduces a `Floorable` trait. This method is in `math` in Python, so we also should expose it there. However, unlike, Python, the generic `floor` method doesn't return an integer, but rather the same type as its input. To ensure that builtins can use `Floorable` without depending on `math`, a hidden `builtin._math` module is introduced, which should eventually be removed in favor of an open source `math` module. MODULAR_ORIG_COMMIT_REV_ID: 75c763ca35050fe81ca0e61d78686c705c9d3803
Similarly to `floor`, this relies on a `Ceilable` trait, implemented in `builtin._math`. The implementation of `SIMD.__{floor,ceil}__` is also refactored to allow more code reuse. MODULAR_ORIG_COMMIT_REV_ID: 96764b377b3c3efd13aab193b78e483d64bf7a86
…nd list too (#38859) [External] [stdlib] Allow `String()` to be created from `UInt8` ptr and list too This is related to modularml#2317. It allows a graceful and slow migration to UInt8 as the primary byte type. This allows everyone to give whatever (Int8 or UInt8) to the String struct and it just works™ When everything uses Uint8, we can remove the old methods that work with Int8, and the migration will be complete. Co-authored-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com> Closes modularml#2448 MODULAR_ORIG_COMMIT_REV_ID: d12649d6dfa178eb756d56df563ad155b5240093
`platform.processor()` on Apple Silicon machines returns `arm`. This handles both Linux and macOS `aarch64` return values. Without this test_aarch64_target.mojo was not running. MODULAR_ORIG_COMMIT_REV_ID: 4c82ada0c567ff7b4a9187e9a38ca927054043cf
Move the recently introduced `min` and `max` functions from `utils/_math.mojo` to be built-ins as they are in Python. Note the Python `min` and `max` functions work on any iterable, but ours aren't quite that powerful yet. We only support `min` and `max` on `Int` and `SIMD` types right now. Eventually, it will improve as we get further along with iterables in the library. MODULAR_ORIG_COMMIT_REV_ID: 545aed9299d0ff0093562d06ff600f427bb5b4e5
Now that the `max` and `min` functions are available in the open source parts of the standard library, apply it and remove all the file-local `max`-equivalent definitions. Similar for `min`. A follow-up will do the same for `abs`. MODULAR_ORIG_COMMIT_REV_ID: 2a352f4d9b6ff18514036bdec1bfb0a4a453aa4c
L0 telemetry is now required and cannot be disabled. As such, update docs to document the `telemetry.level` config instead of `telemetry.enabled` which is misleading because if set `false` it will still collect the L0 data. RE: [Internal link] MODULAR_ORIG_COMMIT_REV_ID: 3b5a1b390c74a7cb0b4199d0cb8c6e0b7ea90be6
…lmost_equal` (#38991) [External] [stdlib] Enhance Handling of Infinity and NaN in `assert_almost_equal` This PR enhances the `assert_almost_equal` function to correctly handle cases involving infinity and NaN. According to `test_assert_almost_equal` added to `/test/testing/test_assertion.mojo`, the current implementation of `assert_almost_equal` results in errors in the following cases: ```mojo alias float_type = DType.float32 alias _inf = inf[float_type]() alias _nan = nan[float_type]() ... _should_succeed( SIMD[float_type, 2](-_inf, _inf), SIMD[float_type, 2](-_inf, _inf) ) ... _should_fail( SIMD[float_type, 2](-_inf, 0.0), SIMD[float_type, 2](_inf, 0.0), rtol=0.1, ) _should_fail( SIMD[float_type, 2](_inf, 0.0), SIMD[float_type, 2](0.0, 0.0), rtol=0.1, ) ... _should_fail( SIMD[float_type, 2](_nan, 0.0), SIMD[float_type, 2](0.0, 0.0), equal_nan=True, ) ``` This PR also: - Eliminates the use of `and` and `or` in the `_isclose` function due to the issue outlined in modularml#2374. - Explicitly reduces boolean vectors to boolean scalar values instead of counting on implicit conversions for clarity. - Avoids arithmetic operations in `_isclose` and `assert_almost_equal` when the type is boolean, as these operations are not supported in this case. - Clarifies the behavior of `assert_almost_equal` in the docstring, highlighting differences from similar functions such as `numpy.testing.assert_allclose`. - Adds the `inf` function to `utils/_numerics` along with corresponding tests in `test/utils/test_numerics.mojo`. ORIGINAL_AUTHOR=Leandro Augusto Lacerda Campos <15185896+leandrolcampos@users.noreply.github.com> PUBLIC_PR_LINK=modularml#2375 Co-authored-by: Leandro Augusto Lacerda Campos <15185896+leandrolcampos@users.noreply.github.com> Closes modularml#2375 MODULAR_ORIG_COMMIT_REV_ID: 2e8b24461dd3279bc841877cc0167acaa104f273
[External] [stdlib] SIMD.shuffle with StaticIntTuple mask Implement modularml#2293. New overloads for `SIMD.shuffle()` like this: ``` fn shuffle[mask: StaticIntTuple[size]](self) -> Self: ``` additionally: - added tests for `SIMD.join()` and `SIMD.shuffle()` - simplified `join` implementation and always use shuffle rather than 2 inserts when mask size > 32 - cleaned up doc strings about shuffle output length - minor refactor of original `_shuffle_list` to use `output_size` parameter rather than calculate `len(mask)` many times As I mentioned in the issue, this can be nicer when inferred parameters are implemented but I guess that is true of most things. ORIGINAL_AUTHOR=Michael Kowalski <1331470+mikowals@users.noreply.github.com> PUBLIC_PR_LINK=modularml#2315 Co-authored-by: Michael Kowalski <1331470+mikowals@users.noreply.github.com> Closes modularml#2315 MODULAR_ORIG_COMMIT_REV_ID: db6215999badc9da09f81700ee9b070db8e93a5b
…#38803) [External] [stdlib] Add `repr()` function and `Representable` trait This PR is a follow up on the discussion there: modularml#2207 There is no `RepresentableRaising` trait yet, this can come later on. We assume here that `42` is the Mojo representation of `Int(42)` because this is how it materializes. Same we assume that `"hello"` is the Mojo string representation of `String("hello")` because StringLiteral materializes into String. We could have used `Int(42)` and `String("hello")` as Mojo representations but that seems very cumbersome and not aligned with the evolution of the language. The discussion is still open for other types. The `__repr__` implementation for String is very simplistic and I believe it's enough as a start, we can push the complexity in other separate PRs (handling `\` and so on). I will open an issue when this PR is merged requesting contributor help to improve it. I will create another issue after this PR is merged to track the conformance of (all?) library types to the `Representable` trait. Co-authored-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com> Closes modularml#2361 MODULAR_ORIG_COMMIT_REV_ID: 82c5e2b83582a61341b8e4a5bfa9d66f7c4f34ab
Staged here: [Internal link] MODULAR_ORIG_COMMIT_REV_ID: ebdd02b89271a9bec41b9014147d7bae03d18ead
…y and NaN in `assert_almost_equal`" (#39024) Reverts modularml/modular#38991 because it breaks some Framework tests. MODULAR_ORIG_COMMIT_REV_ID: db540c7ffc762b30c234ba2daa81f9def5a338af
[External] [mojo-stdlib] Add `List.count(value)` method Add `List.count(value)` method to count the number of occurrences of a value in the `List`. Fixes modularml#2263 --------- Co-authored-by: Kaushal Phulgirkar <kaushalpp01@gmail.com> Closes modularml#2406 MODULAR_ORIG_COMMIT_REV_ID: e9e9be6db11d56f951e94daf22fd0ff8520615fa
…9053) There are some situations in which we logically include the docsite domain, such as in the CLI man page descriptions because users will see these links outside the docs website. But we don't want these fully-qualified URLs in the generated docs because then they don't work properly in a local docsite build of on a staging website (because the links instead go do docs.modular.com). So this new post-process function finds and removes all instances of "docs.modular.com" in the docs build output. Fixes: [Internal link] Example diff: [Internal link] MODULAR_ORIG_COMMIT_REV_ID: dbee988ab3677d129a3d3a3c708fd210b98bafb5
This treats traits as an "Interface" symbol type. This also required resetting IR values when clearing out trait function bodies (because otherwise ASTDecls carry around garbage state that crashes anything trying to introspect it). Fixes modularml#2363 MODULAR_ORIG_COMMIT_REV_ID: 2472dad9150eb93185232cfe0e1237cde5fc9b5e
There is no corresponding python method in `math`, and since the current implementation is not generic, there is no reason for it to live in `math`, especially since `SIMD` already has similar `min` and `max` methods. MODULAR_ORIG_COMMIT_REV_ID: dee81979ae0359fb5b722d2f64b032cd1d8350be
The implementation is just a straightforward call to division and floor. Fixes MSTDL-244 MODULAR_ORIG_COMMIT_REV_ID: 2ed9d01a7af8558108e55582cc9c7e563cdda9f6
Because they are trivial, but untested, and only used in one place. MODULAR_ORIG_COMMIT_REV_ID: 51563e59314219b60dbf675f124207ec4b727907
… fix (#39065) MODULAR_ORIG_COMMIT_REV_ID: 58a6ad6ec925fd7cce0569a520bda2ced24927a8
Like `abs`, mention `min` and `max` were previously in `math` package, but are now built-ins. MODULAR_ORIG_COMMIT_REV_ID: 4049380225b038132c44a7960a7cdd2e3b117032
…8 (#38989) [External] [stdlib] Allow `StringRef` to work with both Int8 and UInt8 This is related to modularml#2317 This is similar to modularml#2448 but for StringRef. With this, users and maintainers can work with both Int8 and UInt8 and will allow a graceful transition. This should also allow users to switch during the next release. Co-authored-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com> Closes modularml#2454 MODULAR_ORIG_COMMIT_REV_ID: 4ef46b217579ad62ca22defc2d8a31930ef37c5a
…(#38943) These are not needed in the `math` module, so a new `nn.math` submodule is created, since they are expected by **** with a certain signature. Some other functions are also moved there from `nn.activations`. A few unused imports are also cleaned up along the way. MODULAR_ORIG_COMMIT_REV_ID: c5d9b36d8edf5a61ed81f4a8390baad6946620e1
Several contributions made it in after the branch cut for MAX 24.3, but the changelog was in a holding state. So, update the changelog now that it's free to claim with post-24.3 changes. MODULAR_ORIG_COMMIT_REV_ID: ec5701466879ed3cf2d59fc832a8979b2c9bba71
Remove the file-local definitions of `_abs` now that `abs` is a built-in function in the open source parts of the standard library. MODULAR_ORIG_COMMIT_REV_ID: 472ee40c9d226d5413035c2cef3989593209c254
MODULAR_ORIG_COMMIT_REV_ID: ea19b2d71729d72d8fc5554ec5d420e8bacd6660
- Legendary -> Highlights (saving legendary for the really big releases) - Added a few highlights, demoted tuple change to make room - Tweaked formatting for contributors - Removed some surplus headers MODULAR_ORIG_COMMIT_REV_ID: bd82abd605b4fb69ceb95b4d5705d84bf9fb34c6
…115) This uses `reversed(range(x))` instead of `range(x-1,-1,-1)` to iterate in reverse order. This better conveys the intent of the traversal and makes it more literate. MODULAR_ORIG_COMMIT_REV_ID: 8f3549642f7ad16ee584829b1b1bb3b1f47069b8
…BRARY` set (#39130) Currently, we just print but continue as normal, which can lead to segfaults and other ungraceful errors. This patch changes the logic so that we abort. This might not be the ideal solution, but at least it will guarantee a deterministic and early failure while we figure out a better solution. Fixes MSTDL-380 MODULAR_ORIG_COMMIT_REV_ID: 47c111f37e6fbce2141db1b88cdcf0c7acc1e335
This method is currently not generic, and since it doesn't appear in python's `math` module, we shouldn't have it there. MODULAR_ORIG_COMMIT_REV_ID: 421b716cd344799af8627fa57b86552539ed71ab
This should enable documentation to be generated for the `exit` functions. Fixes MSTDL-351 MODULAR_ORIG_COMMIT_REV_ID: 0a382413c01500278599dee94e0b7bda9ea6d5e4
…(#38984) A new `builtin.round` module is introduced, also containing a `Roundable` trait. The implementation for `SIMD`, `Int`, and `IntLiteral are also added. The implementation for `FloatLiteral` will be done in a subsequent patch. MODULAR_ORIG_COMMIT_REV_ID: d0d2e7c444a81163dd4db6310385838d386183fe
…564. (#39155) MODULAR_ORIG_COMMIT_REV_ID: 686f9578c2290e0103a6a43dc90cd4c39c75d2c2
…(#39168) This modernizes a random collection of register passable types to stop using legacy `-> Self` initializer syntax. NFC. MODULAR_ORIG_COMMIT_REV_ID: f90dbe21a089dfe55a2941f642461359a524d4b5
MODULAR_ORIG_COMMIT_REV_ID: 04b3c94002b5e6dc461426405dbe7469783a55c7
Technically, URLs are case sensitive. Although our server still resolves urls with case insensitivity, it technically redirects and briefly fails which our linkchecker receives as a 404 (you can also see a flicker in the browser before getting the page) MODULAR_ORIG_COMMIT_REV_ID: b375ec2886fb4989b3013661c19cd2f6a3a033cb
This modernizes some more code. MODULAR_ORIG_COMMIT_REV_ID: 3fa22f2f7b60003a193974cb04193feab8947dba
`List.index` previously took `owned` values which copies the value. This may not be desirable for performance reasons. So remove the `owned` memory convention for the argument `value`. Unit tests cannot be made for this change yet since `List` type requires elements to be Copyable. MODULAR_ORIG_COMMIT_REV_ID: bbf364245ee88494f0d70a9b38763063b5d6f115
…(#39110) The llvm intrinsic would not work on the GPU since we do not compile compilerrt for it. The function is simple to implement and we already have the implementation, so just use that and avoid the special case and use the russian peasant algorithm in both cases. --------- Co-authored-by: Hengjie Wang <hengjiewang@modular.com> MODULAR_ORIG_COMMIT_REV_ID: 5600caab5cb05411af0a3e68dfb6e8680508e6d9
This continues the purge. MODULAR_ORIG_COMMIT_REV_ID: 7e5a4b071a777474e7ba67c0afce325473ab7642
This PR moves the `!pop.coroutine` type to th `co` dialect and renames it to the `!co.routine` type. Otherwise, this patch is NFC. MODULAR_ORIG_COMMIT_REV_ID: 3ff23ac4b4747d8145694dc725c4e36cebb68f47
Update `COMPATIBLE_COMPILER_VERSION` to reflect latest nightly mojo. Signed-off-by: Joe Loser <joeloser@fastmail.com>
This was referenced May 3, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This updates the stdlib with the internal commits corresponding to today's nightly release: mojo 2024.5.303.