-
Notifications
You must be signed in to change notification settings - Fork 19
[WIP] feat(codegen): Integrate PTOAS into PTO backend compilation pipeline #162
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?
Conversation
Summary of ChangesHello @zhangqi-chen, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the PyPTO compilation workflow by incorporating the PTOAS tool. This integration streamlines the process of generating C++ code from PTO MLIR, improving the overall backend compilation pipeline. The changes also include necessary updates to existing MLIR reference files to align with new type definitions and location specifications. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request integrates the ptoas tool into the compilation pipeline, which automatically compiles .pto MLIR files into C++ code. The changes look good, adding a _run_ptoas helper to handle the external process call and updating the compile function. The reference MLIR files have also been updated. I have one suggestion to improve the error handling when calling the external ptoas tool to make it more robust and provide more informative warnings on failure.
python/pypto/ir/compile.py
Outdated
| try: | ||
| result = subprocess.run(cmd, capture_output=True, text=True, check=False) | ||
| if result.returncode != 0: | ||
| warnings.warn(f"ptoas compilation failed: {result.stderr.strip()}", stacklevel=2) | ||
| except (OSError, FileNotFoundError): | ||
| warnings.warn("Failed to execute ptoas.", stacklevel=2) |
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.
The error handling for the subprocess.run call can be improved to be more idiomatic and provide more specific feedback upon failure. Using check=True will raise a subprocess.CalledProcessError for non-zero exit codes, which can be caught separately from FileNotFoundError or other OSError exceptions. This allows for more granular and informative error reporting, which is helpful for debugging issues with the external ptoas tool.
| try: | |
| result = subprocess.run(cmd, capture_output=True, text=True, check=False) | |
| if result.returncode != 0: | |
| warnings.warn(f"ptoas compilation failed: {result.stderr.strip()}", stacklevel=2) | |
| except (OSError, FileNotFoundError): | |
| warnings.warn("Failed to execute ptoas.", stacklevel=2) | |
| try: | |
| subprocess.run(cmd, capture_output=True, text=True, check=True) | |
| except FileNotFoundError: | |
| warnings.warn(f"ptoas binary not found at '{resolved_bin}'.", stacklevel=2) | |
| except subprocess.CalledProcessError as e: | |
| warnings.warn(f"ptoas compilation failed: {e.stderr.strip()}", stacklevel=2) | |
| except OSError as e: | |
| warnings.warn(f"Failed to execute ptoas: {e}", stacklevel=2) |
|
如果找不到ptoas会报怎样的错 |
…ipeline Add ptoas as a project dependency and invoke it automatically to compile .pto MLIR files to C++ when using the PTO backend. Update 3 pto mlir.
Integrate the PTOAS (PTO Assembler & Optimizer) tool to automatically compile .pto MLIR files to C++ code when using the PTO backend. Update 3 pto mlir.