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

Update types.ipynb #2732

Closed
wants to merge 322 commits into from
Closed

Conversation

Trent-Fellbootman
Copy link

Fix English error

lattner and others added 30 commits May 2, 2024 14:15
This enhances type checking of type parameter expressions of
AnyTrait type to look through downcasts of the type itself and
allows downcast from a value of `AnyTrait[SomeTrait]` to
`SomeTrait`.  This is enough to enable us to type check the
fancy dependently typed `each` method on `VariadicPack` which
makes VariadicPack useful for non-AnyType trait requirements
as shown in the integration test!!!

This bumps up against a bug in the KGEN ParameterVerifier.  I
believe the fix is simple, but am not 100% confident about it,
so I temporarily disabled it and filed #36583 to discuss this.

MODULAR_ORIG_COMMIT_REV_ID: 816c623595bce4a995afc795bf5fd551c0c83900
This was previously removed, but is actually used by our manual and also
is generally useful. Since `Dict` can now be used by the interop,
implementing it is trivial.

MODULAR_ORIG_COMMIT_REV_ID: cd0cc86e047f4e49c57969942132f9dda03f2e4f
MODULAR_ORIG_COMMIT_REV_ID: ec6fa3cea82422f85f5be7f08f0d93f3222ea1d1
To make it easier to create an empty python list.

MODULAR_ORIG_COMMIT_REV_ID: ab43b2587bb32db7195a8f45cafb71279fb7e35a
`PythonObject` already implements the logic to create a Python `None`,
so there this method can just simply delegate. The patch also adds a
test case for this.

MODULAR_ORIG_COMMIT_REV_ID: 629355fcfd56b1dba249550c894193f69f71891c
This change fixes following bug: modularml#1630.

Upstream commit:
modularml@8544d8b

MODULAR_ORIG_COMMIT_REV_ID: ab9ccb453b1c928fde1d8ac69c382d2dfa925a6b
This new dictionary type is a wrapper over `Dict`, specializing on
`String` keys. In a subsequent patch, this type will be used by the
parser to pass variadic keyword arguments that are declared with `owned`
ownership semantics.

MODULAR_ORIG_COMMIT_REV_ID: ed73c202fa15d38f543f1baee525635b6aa989b4
Add `list.pop(index)` API to the stdlib as requested by
modularml#2017.

This API should handle the same functionality as the Python `list.pop`.

Unit tests includes:

- popping both positive and negative index
- making sure returned value is consistent
- making sure list len is consistent

Upstream commit: modularml@0e94191

MODULAR_ORIG_COMMIT_REV_ID: 2077b615fd49acdce1287ce587a21c8342f0da1d
Now that `List` has a `pop(index)` API, remove `pop_back()` from `List`.
`pop()` without any arguments has the same semantics.  Fix up the call sites
internally in the standard library.

While here, adjust `pop(index)` to consistently use `len(self)`.

Add a changelog entry for the new API in `List` and the removal of `pop_back()`.

MODULAR_ORIG_COMMIT_REV_ID: 76c8b15ac5c2dd2da879de4fd1f438dad3572c7d
We get type rebinds when metatypes are downcast - look through these
to infer from the original type before mapping.  In the example, we
are allowed to infer that the argument has type `element_types[i]`
even though the Reference type erased it down to `AnyType`.

MODULAR_ORIG_COMMIT_REV_ID: 8212deaf37c4b83a75195a86ae08bb2b931d4997
Why an extra blank line inside a fenced code block causes our MD
processor to lose its mind is another question, but it does, and this
fixes the issue in this instance.

MODULAR_ORIG_COMMIT_REV_ID: 785e243082cedb89a5e5d0719ca33205bef441c2
…keyword arguments (#36540)

Instead of using a `Dict`, the parser will use a more specialized type
for passing variadic keyword arguments into callees. The patch also
simplifies some of the emission logic by moving `String` creation for
the keys into ``OwnedKwargsDict`.

MODULAR_ORIG_COMMIT_REV_ID: bc0bc6edced025903ee095fa5ca3bea248690e66
Change the tests to explicitly import what they use rather than using `from
<module> import *`.

Upstream commit:
modularml@48b91b7

MODULAR_ORIG_COMMIT_REV_ID: d7ad4220c1e478180d3e300b39f8ad815ffbd8a8
[Here](https://docs.python.org/3/library/stdtypes.html#dict.update) is the
python documentation about this method.

There should be another overload: `fn update(self, **kwargs: V)`
which we can't do yet since it would only work with keys that are
strings and we don't yet have conditional conformance (see
modularml#1876).

This is why we force the argument to be positional-only. If we allowed it
to be passed by keyword, it would break when we will introduce
the other overload of `Dict.update`.

Upstream commit:
modularml@b3a2f91

MODULAR_ORIG_COMMIT_REV_ID: d3fcf8609c6d97b4ea4d2bf866987d89e9e30a86
The `__init__ -> Self` is getting deprecated.  Switch over to "normal"
`__init__` constructors that accept `Self` as an `inout` argument instead within
the `os` module.

Upstream commit:
modularml@57b0b57

MODULAR_ORIG_COMMIT_REV_ID: 3382fe2636ae361e732a1b94a0c0dbdc4aef03a4
Just as the title says, it's a very common idiom in python, is even
recommended by PEP8:
https://peps.python.org/pep-0008/#programming-recommendations.

Comparisons to singletons like `None` should always be done with is or
is not, never the equality operators.
Also, beware of writing if x when you really mean if x is not None –
e.g. when testing whether a variable or argument that defaults to None
was set to some other value. The other value might have a type (such as
a container) that could be false in a boolean context!

While the warning does not apply to Mojo, Python users are quite used to
it and it's a small quality of life improvement which is inexpensive to
support.

Upstream commit: modularml@6308519

MODULAR_ORIG_COMMIT_REV_ID: 0961d7b5804b574df61806b8c433471e72cfcd67
… (#36719)

Disallow negative and invalid values in the shuffle mask value.

Closes [Internal link]

MODULAR_ORIG_COMMIT_REV_ID: dfac330b52860cf4418851b31807bfac0ccac2c8
…727)

MODULAR_ORIG_COMMIT_REV_ID: acf071cdc4ebba1ce41a3a059b5a2ef2077d896f
Fixes [Internal link]

Upstream commit:
modularml@bf5bdbd

MODULAR_ORIG_COMMIT_REV_ID: 7654fad7242cdb9d88759558a1ba7ca360889144
This is the big one: `VariadicPack` is now ready to take on the
heavy load for all non-register-passable packs, which notably
includes `print` and `String.join`.  This means deleting our
old friend `_StringableTuple`, replacing the logic with stuff
that is much simpler.

These examples use capturing values, so switch the
`VariadicPack.each` method to work with a capturing closure

This patch fixes a ton of bugs, because variadic packs of
memory-only type now work!

MODULAR_ORIG_COMMIT_REV_ID: 436b86a7496642a6a8f4c4921ef7234436618123
Fixes [Internal link]

- Adds an `address_space` parameter to `Reference`
- Wires `address_space` through `Reference` methods
- Updates `_LITRef` helper to speak `AddressSpace` types instead of an
MLIR type

---------

Co-authored-by: Chris Lattner <clattner@nondot.org>
MODULAR_ORIG_COMMIT_REV_ID: 887d6b06b1fa807fc4092fefafb627ed657bb524
MODULAR_ORIG_COMMIT_REV_ID: 1b22c60e8429217ec8f3e37a28e81f970a04a6c2
We goofed when adding backtick support and caused mblack to parse `!`
incorrectly.

Running mblack on the repo after making this change also caused a bunch
of other files to need formatting, so this PR includes those as well.

Fixes modularml#1963.

MODULAR_ORIG_COMMIT_REV_ID: daad7e9267589460a01cdf9612d8d34134479de9
That playground is gone now.

MODULAR_ORIG_COMMIT_REV_ID: 097e1bd349e1a181cf1526732d9f4f8ec0c3071a
This moves the testsuite off of `AnyRegType` packs and onto `AnyType`
packs as an initial step to making `AnyRegType` packs invalid.

MODULAR_ORIG_COMMIT_REV_ID: 79b5189ec41b113965c829837258680b9dcdbbec
Adding an AddressSpace parameter to AnyPointer to make it usable in GPU
contexts. This change includes fixes to the Dict implementation that
resolve compilation failures. Also, fixes to Mojo parser tests that are validating generated mlir that
changed due to the addition of the AddressSpace parameter.

Closes #31636

MODULAR_ORIG_COMMIT_REV_ID: 8ecb40292c2113cd19fc99c590910a0952b542c4
…(#36906)

`AnyRegType` variadic packs are a legacy feature that predated traits
(and possibly memory only types in general).  We are unifying on a
single consistent representation built around `VariadicPack`.

This takes the step of banning the old `AnyRegType` form in the
parser.  That said, we still have a few uses of the old form in the
tree, so it keeps them alive when explicitly declared "borrowed".
This will allow us to work through removing/replacing these cases
incrementally.

MODULAR_ORIG_COMMIT_REV_ID: 8e7642b4396f704020adabf48c2e7dfb01ec6e9d
…s (#36908)

To avoid bikeshedding on the topic and have a place to point users to
whenever the discussion comes up.

MODULAR_ORIG_COMMIT_REV_ID: d35bcddaea49e7fcaa4ec5ec3ef7f88aa7b3ca42
…6966)

Malloc and free do not make any sense except for the generic address
space, so constrain the functions so that folks cannot call them. Also
fixup the free in layout tensor which we can elide if we are not
operating on generic address space

MODULAR_ORIG_COMMIT_REV_ID: 112b8ac3ffb2da86ceaf1c99dd4737d29f444d6a
This just allows emitConstructorCall to infer the type arguments
of TupleType instead of doing it manually.

MODULAR_ORIG_COMMIT_REV_ID: dc48124f1dd3f259dd1a344c6260a3b2334ecc22
ConnorGray and others added 14 commits May 2, 2024 14:15
MODULAR_ORIG_COMMIT_REV_ID: af02416f98c8aa3b108ccff0cbf477e0dfe030e7
…556)

This means we can pass types conforming to `Boolable` to functions that
expect a `Bool`.

MODULAR_ORIG_COMMIT_REV_ID: 95b50e709a4fc67e42675c78f1178a26aa689f1f
…s (#38676)

MODULAR_ORIG_COMMIT_REV_ID: 4c7d20747d8d2179684ae162449d85ba6f14f229
…messages (#38653)

The patch also includes some refactoring and cleanup in the
`testing.mojo` to improve readability and code reuse.

MODULAR_ORIG_COMMIT_REV_ID: e02d18b05450fb0cb096e417ba313e373917ab53
docs cherrypick from
[Internal link]

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: ef5828a2a74c5ab8545f76bb840ccb93e722464e
Fixes #36699

MODULAR_ORIG_COMMIT_REV_ID: 90158c3c3d0f7700e3236fe9d0a98e3dcc55e3eb
…pick from main) (#38841)

MODULAR_ORIG_COMMIT_REV_ID: 0aa35ca858bf14a5df881c1aa3a9a5e1f16c274c
…om main) (#38844)

Fixes [Internal link]

MODULAR_ORIG_COMMIT_REV_ID: 1d832aabfdb84167f0def998ac386463b4ee266e
Co-authored-by: Ehsan M. Kermani <6980212+ehsanmok@users.noreply.github.com>
MODULAR_ORIG_COMMIT_REV_ID: 838ccd91a087d5c216f296a65f686299e5948fa6
MODULAR_ORIG_COMMIT_REV_ID: c414bcbd1731aaf80a339928c37af24394f8a564
…m main) (#39158)

Related to MOCO-564. (#39155)

MODULAR_ORIG_COMMIT_REV_ID: 8e5c4ff2796f0b30c00175b06e30223c01d9df51
The current test configs cover the `nightly` release but not the stable
release. This change updates the configs so that tests can be run with
the latest `mojo` release.

Signed-off-by: Patrick Dougherty <patrick.dougherty@modular.com>
Signed-off-by: Trent Fellbootman <78004741+Trent-Fellbootman@users.noreply.github.com>
@JoeLoser JoeLoser requested a review from a team May 20, 2024 23:35
@JoeLoser
Copy link
Collaborator

!sync

@JoeLoser JoeLoser removed their assignment May 20, 2024
@modularbot modularbot added the imported-internally Signals that a given pull request has been imported internally. label May 20, 2024
@JoeLoser JoeLoser removed the imported-internally Signals that a given pull request has been imported internally. label May 20, 2024
@Brian-M-J
Copy link

@Trent-Fellbootman Can you change your target branch to nightly so the Modular team can merge this PR? See here for some suggestions on how to do so.

@Brian-M-J Brian-M-J mentioned this pull request May 24, 2024
@Brian-M-J
Copy link

Brian-M-J commented May 24, 2024

P.S. This fix is a duplicate of the first one in #2512. We can merge whichever PR rebases on nightly first and close the other one.

Copy link
Collaborator

@arthurevans arthurevans left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

As noted, needs to be retargeted to nightly.

@Trent-Fellbootman Trent-Fellbootman changed the base branch from main to nightly May 25, 2024 02:18
@Trent-Fellbootman Trent-Fellbootman requested review from jackos and a team as code owners May 25, 2024 02:18
@Trent-Fellbootman
Copy link
Author

Thanks for the fix!

As noted, needs to be retargeted to nightly.

done

@Trent-Fellbootman
Copy link
Author

Trent-Fellbootman commented May 25, 2024

Rebasing caused some conflicts. I'm creating a new one directly based off the nightly branch and closing this PR. Refer to #2818.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet