-
Notifications
You must be signed in to change notification settings - Fork 80
improve mlir & mlir_opt property documentation #2975
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -614,8 +614,13 @@ def _get_effective_capture_mode(self): | |
| return capture_option | ||
|
|
||
| @property | ||
| def mlir(self): | ||
| """Obtain the MLIR representation after canonicalization""" | ||
| def mlir(self) -> str | None: | ||
| """The canonicalized MLIR representation of the QJIT object after lowering, if available. | ||
|
|
||
| Returns: | ||
| str: The textual MLIR module for the QJIT object. | ||
| None: If compilation has not yet occurred. | ||
| """ | ||
| # Canonicalize the MLIR since there can be a lot of redundancy coming from JAX. | ||
| if not self.mlir_module: | ||
| return None | ||
|
|
@@ -626,8 +631,13 @@ def mlir(self): | |
| return canonicalize(stdin=stdin, options=self.compile_options) | ||
|
|
||
| @property | ||
| def mlir_opt(self): | ||
| """Obtain the MLIR representation after optimization""" | ||
| def mlir_opt(self) -> str | None: | ||
| """The MLIR representation of the QJIT object after optimization, if available. | ||
|
|
||
| Returns: | ||
| str: The textual MLIR module after applying user passes and the default pipeline. | ||
| None: If compilation has not yet occurred. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This statement is a bit tricky. Technically, accessing this property triggers the "compilation" (at least compilation in the MLIR / core Catalyst compiler sense), but what needed to have happened before is that the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! It's kind of difficult to convey all of that concisely, what about something like
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that makes sense! Maybe a slight modification, since the MLIR having been generated is the criteria, and our programs are more general than circuits:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does f145021 sound?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The condition for both properties is the same actually, because they take the jax-generated mlir (
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I was trying to get at the required success of running the requested pipeline to generate
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there is a failure in the pipeline an error should be raised. The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, added in a98893b |
||
| """ | ||
| if not self.mlir_module: | ||
| return None | ||
| using_python_compiler = self.compiler.is_using_python_compiler(self.mlir_module) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.