-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Relax]feat: Implement FRelaxInferLayout for tile operator #18593
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
- Implement InferLayoutTile function to handle layout transformation for tile operator - Use TransposeStrLike approach similar to repeat operator to correctly map repeats array - Handle both same-dimension and dimension-expansion cases - Add test case test_conv2d_tile to verify layout conversion from NCHW to NHWC - Fixes the TODO at src/relax/op/tensor/manipulate.cc:1932 The implementation correctly transforms the repeats array when the input tensor's layout changes (e.g., from NCHW to NHWC), ensuring that repeat values are mapped to the correct dimensions in the new layout.
Summary of ChangesHello @Dayuxiaoshui, 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 significantly enhances the 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. 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 implements layout inference for the tile operator, which is a great addition. The implementation correctly handles the tested case of same-dimension tiling. However, I found some issues in the implementation:
- The logic for handling
len(repeats) < input.ndimis incorrect as it padsrepeatsat the end instead of the beginning as per the documentation. - The logic for handling dimension expansion (
len(repeats) > input.ndim) is incorrect. - The implementation for same-dimension tiling is overly complex and hard to maintain.
I've provided a simplified and corrected implementation for InferLayoutTile that addresses these issues. I've also suggested adding more test cases to cover the scenarios where the current implementation would fail, ensuring the feature is robust.
- Simplify implementation by using direct mapping instead of TransposeStrLike - Fix padding logic: when len(repeats) < ndim, repeats are right-aligned (padded with 1s at beginning) - Fix dimension expansion logic: when len(repeats) > ndim, new dimensions come first, then existing dimensions are permuted - Add test cases for len(repeats) < ndim and repeat values > 9 - Remove overly complex string encoding approach that had limitations The new implementation is simpler, more maintainable, and correctly handles all edge cases.
The implementation correctly transforms the repeats array when the input tensor's layout changes (e.g., from NCHW to NHWC), ensuring that repeat values are mapped to the correct dimensions in the new layout.