-
Notifications
You must be signed in to change notification settings - Fork 3.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
[Diagnostics][Relay][InferType] Refactor InferType to work on whole module, and use new diagnostics. #6274
Conversation
May be out of the scope of this PR, but shall we also consider make type inference non-recursive some time? |
72ed73f
to
d0deb8f
Compare
d9bcbe6
to
d3b0c22
Compare
eacb4a7
to
da61680
Compare
8cbc61d
to
495606d
Compare
|
||
def _add(self, var, val, update=False): | ||
def _add(self, var, val, update=True): |
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.
Remove update/add in future PR.
@@ -213,13 +213,15 @@ def optimize(self): | |||
""" | |||
seq = tvm.transform.Sequential( | |||
[ | |||
# tvm.parser.AnnotateSpans(), |
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.
Should we provide a flag for spans here?
@@ -1512,3 +1552,6 @@ def load_prelude(self): | |||
]: | |||
tensor_array_ops = TensorArrayOps(self, dtype) | |||
tensor_array_ops.register() | |||
|
|||
# Renamer doesn't properly deal with constructors, etc |
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.
I don't think this is true anymore.
c0094fd
to
c2f368b
Compare
Thank you @jroesch @mbrookhart @rkimball the PR has been merged. |
…odule, and use new diagnostics. (apache#6274) * Refactor the type checker to use diagnostics Although this patch is very large and seemingly disjoint the fixes are required to get it working for the entire stack. I started with first changing InferType to use the diagnostics, these weren't yet in the pass manager so this required changes to module and module pass. InferType wasn't actually written correctly as a pass requring refactoring there, then in order to add spans to AST it required turning on AnnotateSpans which in term required changes to the parser, and module to make it possible to use the errors. These changes to parse and module required changes to diagnostics and InferType. Althought seemingly disconnected there are hidden cycles between the components which require simultaneous change in order to remove the old error reporting. A huge change due to this patch is that the module no longer implicitly type checks functions which are added. * Apply suggestions from code review Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> * Apply suggestions from code review Co-authored-by: Tristan Konolige <[email protected]> * Clean up parser * CR feedback * Apply Bobs suggestions * Fix up Python interface for diagnostics * Fix test_ir_parser and formatting * Fix cpplint * Fix lint * Fix format * More lint * Fix format * Kill dead doc comment * Fix documentation comment * Rebase fixups * Add docs for type.h * Fix parser.cc * Fix unittests * Fix black * Skip previously typechecked functions * fix ACL * Fix numerous issues * Add repr method * Fix issue with Pytest, I am ready to cry * Fix the rest of tests * Kill dead code * Fix dignostic tests * Fix more tests * fix more tests (neo-ai#11) * Fix diagnostic.py deinit bug * Fix deinit issue * Format * Tweak disabling of override * Format * Fix BYOC * Fix TensorArray stuff * Fix PyTorch * Format * Format Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> Co-authored-by: Tristan Konolige <[email protected]> Co-authored-by: Cody Yu <[email protected]> Co-authored-by: Zhi <[email protected]>
…odule, and use new diagnostics. (apache#6274) * Refactor the type checker to use diagnostics Although this patch is very large and seemingly disjoint the fixes are required to get it working for the entire stack. I started with first changing InferType to use the diagnostics, these weren't yet in the pass manager so this required changes to module and module pass. InferType wasn't actually written correctly as a pass requring refactoring there, then in order to add spans to AST it required turning on AnnotateSpans which in term required changes to the parser, and module to make it possible to use the errors. These changes to parse and module required changes to diagnostics and InferType. Althought seemingly disconnected there are hidden cycles between the components which require simultaneous change in order to remove the old error reporting. A huge change due to this patch is that the module no longer implicitly type checks functions which are added. * Apply suggestions from code review Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> * Apply suggestions from code review Co-authored-by: Tristan Konolige <[email protected]> * Clean up parser * CR feedback * Apply Bobs suggestions * Fix up Python interface for diagnostics * Fix test_ir_parser and formatting * Fix cpplint * Fix lint * Fix format * More lint * Fix format * Kill dead doc comment * Fix documentation comment * Rebase fixups * Add docs for type.h * Fix parser.cc * Fix unittests * Fix black * Skip previously typechecked functions * fix ACL * Fix numerous issues * Add repr method * Fix issue with Pytest, I am ready to cry * Fix the rest of tests * Kill dead code * Fix dignostic tests * Fix more tests * fix more tests (neo-ai#11) * Fix diagnostic.py deinit bug * Fix deinit issue * Format * Tweak disabling of override * Format * Fix BYOC * Fix TensorArray stuff * Fix PyTorch * Format * Format Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> Co-authored-by: Tristan Konolige <[email protected]> Co-authored-by: Cody Yu <[email protected]> Co-authored-by: Zhi <[email protected]>
…odule, and use new diagnostics. (apache#6274) * Refactor the type checker to use diagnostics Although this patch is very large and seemingly disjoint the fixes are required to get it working for the entire stack. I started with first changing InferType to use the diagnostics, these weren't yet in the pass manager so this required changes to module and module pass. InferType wasn't actually written correctly as a pass requring refactoring there, then in order to add spans to AST it required turning on AnnotateSpans which in term required changes to the parser, and module to make it possible to use the errors. These changes to parse and module required changes to diagnostics and InferType. Althought seemingly disconnected there are hidden cycles between the components which require simultaneous change in order to remove the old error reporting. A huge change due to this patch is that the module no longer implicitly type checks functions which are added. * Apply suggestions from code review Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> * Apply suggestions from code review Co-authored-by: Tristan Konolige <[email protected]> * Clean up parser * CR feedback * Apply Bobs suggestions * Fix up Python interface for diagnostics * Fix test_ir_parser and formatting * Fix cpplint * Fix lint * Fix format * More lint * Fix format * Kill dead doc comment * Fix documentation comment * Rebase fixups * Add docs for type.h * Fix parser.cc * Fix unittests * Fix black * Skip previously typechecked functions * fix ACL * Fix numerous issues * Add repr method * Fix issue with Pytest, I am ready to cry * Fix the rest of tests * Kill dead code * Fix dignostic tests * Fix more tests * fix more tests (neo-ai#11) * Fix diagnostic.py deinit bug * Fix deinit issue * Format * Tweak disabling of override * Format * Fix BYOC * Fix TensorArray stuff * Fix PyTorch * Format * Format Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> Co-authored-by: Tristan Konolige <[email protected]> Co-authored-by: Cody Yu <[email protected]> Co-authored-by: Zhi <[email protected]>
…odule, and use new diagnostics. (apache#6274) * Refactor the type checker to use diagnostics Although this patch is very large and seemingly disjoint the fixes are required to get it working for the entire stack. I started with first changing InferType to use the diagnostics, these weren't yet in the pass manager so this required changes to module and module pass. InferType wasn't actually written correctly as a pass requring refactoring there, then in order to add spans to AST it required turning on AnnotateSpans which in term required changes to the parser, and module to make it possible to use the errors. These changes to parse and module required changes to diagnostics and InferType. Althought seemingly disconnected there are hidden cycles between the components which require simultaneous change in order to remove the old error reporting. A huge change due to this patch is that the module no longer implicitly type checks functions which are added. * Apply suggestions from code review Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> * Apply suggestions from code review Co-authored-by: Tristan Konolige <[email protected]> * Clean up parser * CR feedback * Apply Bobs suggestions * Fix up Python interface for diagnostics * Fix test_ir_parser and formatting * Fix cpplint * Fix lint * Fix format * More lint * Fix format * Kill dead doc comment * Fix documentation comment * Rebase fixups * Add docs for type.h * Fix parser.cc * Fix unittests * Fix black * Skip previously typechecked functions * fix ACL * Fix numerous issues * Add repr method * Fix issue with Pytest, I am ready to cry * Fix the rest of tests * Kill dead code * Fix dignostic tests * Fix more tests * fix more tests (neo-ai#11) * Fix diagnostic.py deinit bug * Fix deinit issue * Format * Tweak disabling of override * Format * Fix BYOC * Fix TensorArray stuff * Fix PyTorch * Format * Format Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> Co-authored-by: Tristan Konolige <[email protected]> Co-authored-by: Cody Yu <[email protected]> Co-authored-by: Zhi <[email protected]>
…odule, and use new diagnostics. (apache#6274) * Refactor the type checker to use diagnostics Although this patch is very large and seemingly disjoint the fixes are required to get it working for the entire stack. I started with first changing InferType to use the diagnostics, these weren't yet in the pass manager so this required changes to module and module pass. InferType wasn't actually written correctly as a pass requring refactoring there, then in order to add spans to AST it required turning on AnnotateSpans which in term required changes to the parser, and module to make it possible to use the errors. These changes to parse and module required changes to diagnostics and InferType. Althought seemingly disconnected there are hidden cycles between the components which require simultaneous change in order to remove the old error reporting. A huge change due to this patch is that the module no longer implicitly type checks functions which are added. * Apply suggestions from code review Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> * Apply suggestions from code review Co-authored-by: Tristan Konolige <[email protected]> * Clean up parser * CR feedback * Apply Bobs suggestions * Fix up Python interface for diagnostics * Fix test_ir_parser and formatting * Fix cpplint * Fix lint * Fix format * More lint * Fix format * Kill dead doc comment * Fix documentation comment * Rebase fixups * Add docs for type.h * Fix parser.cc * Fix unittests * Fix black * Skip previously typechecked functions * fix ACL * Fix numerous issues * Add repr method * Fix issue with Pytest, I am ready to cry * Fix the rest of tests * Kill dead code * Fix dignostic tests * Fix more tests * fix more tests (neo-ai#11) * Fix diagnostic.py deinit bug * Fix deinit issue * Format * Tweak disabling of override * Format * Fix BYOC * Fix TensorArray stuff * Fix PyTorch * Format * Format Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> Co-authored-by: Tristan Konolige <[email protected]> Co-authored-by: Cody Yu <[email protected]> Co-authored-by: Zhi <[email protected]>
…odule, and use new diagnostics. (apache#6274) * Refactor the type checker to use diagnostics Although this patch is very large and seemingly disjoint the fixes are required to get it working for the entire stack. I started with first changing InferType to use the diagnostics, these weren't yet in the pass manager so this required changes to module and module pass. InferType wasn't actually written correctly as a pass requring refactoring there, then in order to add spans to AST it required turning on AnnotateSpans which in term required changes to the parser, and module to make it possible to use the errors. These changes to parse and module required changes to diagnostics and InferType. Althought seemingly disconnected there are hidden cycles between the components which require simultaneous change in order to remove the old error reporting. A huge change due to this patch is that the module no longer implicitly type checks functions which are added. * Apply suggestions from code review Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> * Apply suggestions from code review Co-authored-by: Tristan Konolige <[email protected]> * Clean up parser * CR feedback * Apply Bobs suggestions * Fix up Python interface for diagnostics * Fix test_ir_parser and formatting * Fix cpplint * Fix lint * Fix format * More lint * Fix format * Kill dead doc comment * Fix documentation comment * Rebase fixups * Add docs for type.h * Fix parser.cc * Fix unittests * Fix black * Skip previously typechecked functions * fix ACL * Fix numerous issues * Add repr method * Fix issue with Pytest, I am ready to cry * Fix the rest of tests * Kill dead code * Fix dignostic tests * Fix more tests * fix more tests (neo-ai#11) * Fix diagnostic.py deinit bug * Fix deinit issue * Format * Tweak disabling of override * Format * Fix BYOC * Fix TensorArray stuff * Fix PyTorch * Format * Format Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> Co-authored-by: Tristan Konolige <[email protected]> Co-authored-by: Cody Yu <[email protected]> Co-authored-by: Zhi <[email protected]>
…odule, and use new diagnostics. (apache#6274) * Refactor the type checker to use diagnostics Although this patch is very large and seemingly disjoint the fixes are required to get it working for the entire stack. I started with first changing InferType to use the diagnostics, these weren't yet in the pass manager so this required changes to module and module pass. InferType wasn't actually written correctly as a pass requring refactoring there, then in order to add spans to AST it required turning on AnnotateSpans which in term required changes to the parser, and module to make it possible to use the errors. These changes to parse and module required changes to diagnostics and InferType. Althought seemingly disconnected there are hidden cycles between the components which require simultaneous change in order to remove the old error reporting. A huge change due to this patch is that the module no longer implicitly type checks functions which are added. * Apply suggestions from code review Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> * Apply suggestions from code review Co-authored-by: Tristan Konolige <[email protected]> * Clean up parser * CR feedback * Apply Bobs suggestions * Fix up Python interface for diagnostics * Fix test_ir_parser and formatting * Fix cpplint * Fix lint * Fix format * More lint * Fix format * Kill dead doc comment * Fix documentation comment * Rebase fixups * Add docs for type.h * Fix parser.cc * Fix unittests * Fix black * Skip previously typechecked functions * fix ACL * Fix numerous issues * Add repr method * Fix issue with Pytest, I am ready to cry * Fix the rest of tests * Kill dead code * Fix dignostic tests * Fix more tests * fix more tests (#11) * Fix diagnostic.py deinit bug * Fix deinit issue * Format * Tweak disabling of override * Format * Fix BYOC * Fix TensorArray stuff * Fix PyTorch * Format * Format Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> Co-authored-by: Tristan Konolige <[email protected]> Co-authored-by: Cody Yu <[email protected]> Co-authored-by: Zhi <[email protected]>
…odule, and use new diagnostics. (apache#6274) * Refactor the type checker to use diagnostics Although this patch is very large and seemingly disjoint the fixes are required to get it working for the entire stack. I started with first changing InferType to use the diagnostics, these weren't yet in the pass manager so this required changes to module and module pass. InferType wasn't actually written correctly as a pass requring refactoring there, then in order to add spans to AST it required turning on AnnotateSpans which in term required changes to the parser, and module to make it possible to use the errors. These changes to parse and module required changes to diagnostics and InferType. Althought seemingly disconnected there are hidden cycles between the components which require simultaneous change in order to remove the old error reporting. A huge change due to this patch is that the module no longer implicitly type checks functions which are added. * Apply suggestions from code review Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> * Apply suggestions from code review Co-authored-by: Tristan Konolige <[email protected]> * Clean up parser * CR feedback * Apply Bobs suggestions * Fix up Python interface for diagnostics * Fix test_ir_parser and formatting * Fix cpplint * Fix lint * Fix format * More lint * Fix format * Kill dead doc comment * Fix documentation comment * Rebase fixups * Add docs for type.h * Fix parser.cc * Fix unittests * Fix black * Skip previously typechecked functions * fix ACL * Fix numerous issues * Add repr method * Fix issue with Pytest, I am ready to cry * Fix the rest of tests * Kill dead code * Fix dignostic tests * Fix more tests * fix more tests (#11) * Fix diagnostic.py deinit bug * Fix deinit issue * Format * Tweak disabling of override * Format * Fix BYOC * Fix TensorArray stuff * Fix PyTorch * Format * Format Co-authored-by: Robert Kimball <[email protected]> Co-authored-by: Junru Shao <[email protected]> Co-authored-by: Tristan Konolige <[email protected]> Co-authored-by: Cody Yu <[email protected]> Co-authored-by: Zhi <[email protected]>
This is now ready for full review. This has become a huge PR where I split the coupling between the type checker and the module enabling more flexible use of the module and type checker. Unfortunately people have heavily relied on implicit type checking occurring each time we add a function. This functionality is not longer supported and examples of fixing it can be found all over the test cases.