[JIT] Disallow plain Dict type annotation without arg#44334
[JIT] Disallow plain Dict type annotation without arg#44334SplitInfinity wants to merge 8 commits intogh/splitinfinity/41/basefrom
Conversation
**Summary** This commit detects and prohibits the case in which `typing.Dict` is used as an annotation without type arguments (i.e. `typing.Dict[K, V]`). At present, `typing.Dict` is always assumed to have two arguments, and when it is used without them, `typing.Dict.__args__` is nonempty and contains some `typing.TypeVar` instances, which have no JIT type equivalent. Consequently, trying to convert `typing.Dict` to a JIT type results in a `c10::DictType` with `nullptr` for its key and value types, which can cause a segmentation fault. This is fixed by returning a `DictType` from `jit.annotations.try_ann_to_type` only if the key and value types are converted successfully to a JIT type and returning `None` otherwise. **Test Plan** This commit adds a unit test to `TestDict` that tests the plain `Dict` annotations throw an error. **Fixes** This commit closes #43530. [ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit fa5bf34 (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
**Summary** This commit detects and prohibits the case in which `typing.Dict` is used as an annotation without type arguments (i.e. `typing.Dict[K, V]`). At present, `typing.Dict` is always assumed to have two arguments, and when it is used without them, `typing.Dict.__args__` is nonempty and contains some `typing.TypeVar` instances, which have no JIT type equivalent. Consequently, trying to convert `typing.Dict` to a JIT type results in a `c10::DictType` with `nullptr` for its key and value types, which can cause a segmentation fault. This is fixed by returning a `DictType` from `jit.annotations.try_ann_to_type` only if the key and value types are converted successfully to a JIT type and returning `None` otherwise. **Test Plan** This commit adds a unit test to `TestDict` that tests the plain `Dict` annotations throw an error. **Fixes** This commit closes #43530. [ghstack-poisoned]
**Summary** This commit detects and prohibits the case in which `typing.Dict` is used as an annotation without type arguments (i.e. `typing.Dict[K, V]`). At present, `typing.Dict` is always assumed to have two arguments, and when it is used without them, `typing.Dict.__args__` is nonempty and contains some `typing.TypeVar` instances, which have no JIT type equivalent. Consequently, trying to convert `typing.Dict` to a JIT type results in a `c10::DictType` with `nullptr` for its key and value types, which can cause a segmentation fault. This is fixed by returning a `DictType` from `jit.annotations.try_ann_to_type` only if the key and value types are converted successfully to a JIT type and returning `None` otherwise. **Test Plan** This commit adds a unit test to `TestDict` that tests the plain `Dict` annotations throw an error. **Fixes** This commit closes #43530. [ghstack-poisoned]
**Summary** This commit detects and prohibits the case in which `typing.Dict` is used as an annotation without type arguments (i.e. `typing.Dict[K, V]`). At present, `typing.Dict` is always assumed to have two arguments, and when it is used without them, `typing.Dict.__args__` is nonempty and contains some `typing.TypeVar` instances, which have no JIT type equivalent. Consequently, trying to convert `typing.Dict` to a JIT type results in a `c10::DictType` with `nullptr` for its key and value types, which can cause a segmentation fault. This is fixed by returning a `DictType` from `jit.annotations.try_ann_to_type` only if the key and value types are converted successfully to a JIT type and returning `None` otherwise. **Test Plan** This commit adds a unit test to `TestDict` that tests the plain `Dict` annotations throw an error. **Fixes** This commit closes #43530. ghstack-source-id: 1601d24 Pull Request resolved: #44334
**Summary** This commit detects and prohibits the case in which `typing.Dict` is used as an annotation without type arguments (i.e. `typing.Dict[K, V]`). At present, `typing.Dict` is always assumed to have two arguments, and when it is used without them, `typing.Dict.__args__` is nonempty and contains some `typing.TypeVar` instances, which have no JIT type equivalent. Consequently, trying to convert `typing.Dict` to a JIT type results in a `c10::DictType` with `nullptr` for its key and value types, which can cause a segmentation fault. This is fixed by returning a `DictType` from `jit.annotations.try_ann_to_type` only if the key and value types are converted successfully to a JIT type and returning `None` otherwise. **Test Plan** This commit adds a unit test to `TestDict` that tests the plain `Dict` annotations throw an error. **Fixes** This commit closes #43530. [ghstack-poisoned]
**Summary** This commit detects and prohibits the case in which `typing.Dict` is used as an annotation without type arguments (i.e. `typing.Dict[K, V]`). At present, `typing.Dict` is always assumed to have two arguments, and when it is used without them, `typing.Dict.__args__` is nonempty and contains some `typing.TypeVar` instances, which have no JIT type equivalent. Consequently, trying to convert `typing.Dict` to a JIT type results in a `c10::DictType` with `nullptr` for its key and value types, which can cause a segmentation fault. This is fixed by returning a `DictType` from `jit.annotations.try_ann_to_type` only if the key and value types are converted successfully to a JIT type and returning `None` otherwise. **Test Plan** This commit adds a unit test to `TestDict` that tests the plain `Dict` annotations throw an error. **Fixes** This commit closes #43530. Differential Revision: [D23610766](https://our.internmc.facebook.com/intern/diff/D23610766) [ghstack-poisoned]
|
Another type container i missed: EDIT: also Future, RRef, |
**Summary** This commit detects and prohibits the case in which `typing.Dict` is used as an annotation without type arguments (i.e. `typing.Dict[K, V]`). At present, `typing.Dict` is always assumed to have two arguments, and when it is used without them, `typing.Dict.__args__` is nonempty and contains some `typing.TypeVar` instances, which have no JIT type equivalent. Consequently, trying to convert `typing.Dict` to a JIT type results in a `c10::DictType` with `nullptr` for its key and value types, which can cause a segmentation fault. This is fixed by returning a `DictType` from `jit.annotations.try_ann_to_type` only if the key and value types are converted successfully to a JIT type and returning `None` otherwise. **Test Plan** This commit adds a unit test to `TestDict` that tests the plain `Dict` annotations throw an error. **Fixes** This commit closes #43530. Differential Revision: [D23610766](https://our.internmc.facebook.com/intern/diff/D23610766) [ghstack-poisoned]
**Summary** This commit detects and prohibits the case in which `typing.Dict` is used as an annotation without type arguments (i.e. `typing.Dict[K, V]`). At present, `typing.Dict` is always assumed to have two arguments, and when it is used without them, `typing.Dict.__args__` is nonempty and contains some `typing.TypeVar` instances, which have no JIT type equivalent. Consequently, trying to convert `typing.Dict` to a JIT type results in a `c10::DictType` with `nullptr` for its key and value types, which can cause a segmentation fault. This is fixed by returning a `DictType` from `jit.annotations.try_ann_to_type` only if the key and value types are converted successfully to a JIT type and returning `None` otherwise. **Test Plan** This commit adds a unit test to `TestDict` that tests the plain `Dict` annotations throw an error. **Fixes** This commit closes #43530. ghstack-source-id: 8fb136a Pull Request resolved: #44334
|
I'll stack them on top. I'm currently fighting some test failures due to small differences in |
**Summary** This commit detects and prohibits the case in which `typing.Dict` is used as an annotation without type arguments (i.e. `typing.Dict[K, V]`). At present, `typing.Dict` is always assumed to have two arguments, and when it is used without them, `typing.Dict.__args__` is nonempty and contains some `typing.TypeVar` instances, which have no JIT type equivalent. Consequently, trying to convert `typing.Dict` to a JIT type results in a `c10::DictType` with `nullptr` for its key and value types, which can cause a segmentation fault. This is fixed by returning a `DictType` from `jit.annotations.try_ann_to_type` only if the key and value types are converted successfully to a JIT type and returning `None` otherwise. **Test Plan** This commit adds a unit test to `TestDict` that tests the plain `Dict` annotations throw an error. **Fixes** This commit closes #43530. Differential Revision: [D23610766](https://our.internmc.facebook.com/intern/diff/D23610766) [ghstack-poisoned]
**Summary** This commit detects and prohibits the case in which `typing.Dict` is used as an annotation without type arguments (i.e. `typing.Dict[K, V]`). At present, `typing.Dict` is always assumed to have two arguments, and when it is used without them, `typing.Dict.__args__` is nonempty and contains some `typing.TypeVar` instances, which have no JIT type equivalent. Consequently, trying to convert `typing.Dict` to a JIT type results in a `c10::DictType` with `nullptr` for its key and value types, which can cause a segmentation fault. This is fixed by returning a `DictType` from `jit.annotations.try_ann_to_type` only if the key and value types are converted successfully to a JIT type and returning `None` otherwise. **Test Plan** This commit adds a unit test to `TestDict` that tests the plain `Dict` annotations throw an error. **Fixes** This commit closes #43530. ghstack-source-id: c75b7d0 Pull Request resolved: #44334
|
Re-requesting review because I had to make non-trivial changes to get |
Codecov Report
@@ Coverage Diff @@
## gh/splitinfinity/41/base #44334 +/- ##
===========================================================
Coverage ? 68.00%
===========================================================
Files ? 382
Lines ? 49403
Branches ? 0
===========================================================
Hits ? 33597
Misses ? 15806
Partials ? 0 Continue to review full report at Codecov.
|
**Summary** This commit detects and prohibits the case in which `typing.Dict` is used as an annotation without type arguments (i.e. `typing.Dict[K, V]`). At present, `typing.Dict` is always assumed to have two arguments, and when it is used without them, `typing.Dict.__args__` is nonempty and contains some `typing.TypeVar` instances, which have no JIT type equivalent. Consequently, trying to convert `typing.Dict` to a JIT type results in a `c10::DictType` with `nullptr` for its key and value types, which can cause a segmentation fault. This is fixed by returning a `DictType` from `jit.annotations.try_ann_to_type` only if the key and value types are converted successfully to a JIT type and returning `None` otherwise. **Test Plan** This commit adds a unit test to `TestDict` that tests the plain `Dict` annotations throw an error. **Fixes** This commit closes #43530. Differential Revision: [D23610766](https://our.internmc.facebook.com/intern/diff/D23610766) [ghstack-poisoned]
|
Okay, I stacked similar PRs for |
|
@SplitInfinity merged this pull request in cb3b8a3. |
|
@SplitInfinity merged this pull request in cb3b8a3. |
Summary: Pull Request resolved: #44334 **Summary** This commit detects and prohibits the case in which `typing.Dict` is used as an annotation without type arguments (i.e. `typing.Dict[K, V]`). At present, `typing.Dict` is always assumed to have two arguments, and when it is used without them, `typing.Dict.__args__` is nonempty and contains some `typing.TypeVar` instances, which have no JIT type equivalent. Consequently, trying to convert `typing.Dict` to a JIT type results in a `c10::DictType` with `nullptr` for its key and value types, which can cause a segmentation fault. This is fixed by returning a `DictType` from `jit.annotations.try_ann_to_type` only if the key and value types are converted successfully to a JIT type and returning `None` otherwise. **Test Plan** This commit adds a unit test to `TestDict` that tests the plain `Dict` annotations throw an error. **Fixes** This commit closes #43530. Test Plan: Imported from OSS Reviewed By: gmagogsfm Differential Revision: D23610766 Pulled By: SplitInfinity fbshipit-source-id: 036b10eff6e3206e0da3131cfb4997d8189c4fec
Summary: Pull Request resolved: pytorch#44334 **Summary** This commit detects and prohibits the case in which `typing.Dict` is used as an annotation without type arguments (i.e. `typing.Dict[K, V]`). At present, `typing.Dict` is always assumed to have two arguments, and when it is used without them, `typing.Dict.__args__` is nonempty and contains some `typing.TypeVar` instances, which have no JIT type equivalent. Consequently, trying to convert `typing.Dict` to a JIT type results in a `c10::DictType` with `nullptr` for its key and value types, which can cause a segmentation fault. This is fixed by returning a `DictType` from `jit.annotations.try_ann_to_type` only if the key and value types are converted successfully to a JIT type and returning `None` otherwise. **Test Plan** This commit adds a unit test to `TestDict` that tests the plain `Dict` annotations throw an error. **Fixes** This commit closes pytorch#43530. Test Plan: Imported from OSS Reviewed By: gmagogsfm Differential Revision: D23610766 Pulled By: SplitInfinity fbshipit-source-id: 036b10eff6e3206e0da3131cfb4997d8189c4fec
Stack from ghstack:
Summary
This commit detects and prohibits the case in which
typing.Dictisused as an annotation without type arguments (i.e.
typing.Dict[K, V]).At present,
typing.Dictis always assumed to have two arguments, andwhen it is used without them,
typing.Dict.__args__is nonempty andcontains some
typing.TypeVarinstances, which have no JIT type equivalent.Consequently, trying to convert
typing.Dictto a JIT type results ina
c10::DictTypewithnullptrfor its key and value types, which can causea segmentation fault.
This is fixed by returning a
DictTypefromjit.annotations.try_ann_to_typeonly if the key and value types are convertedsuccessfully to a JIT type and returning
Noneotherwise.Test Plan
This commit adds a unit test to
TestDictthat tests the plainDictannotations throw an error.
Fixes
This commit closes #43530.
Differential Revision: D23610766