Skip to content
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

Upgrade MLIR with new IR print option #372

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

jackalcooper
Copy link
Contributor

@jackalcooper jackalcooper commented Nov 27, 2024

Summary by CodeRabbit

  • New Features

    • Added a new option for specifying a path for tree printing in the IR printing process.
  • Bug Fixes

    • Updated version specifications for the mlir package to enhance compatibility across platforms.
  • Tests

    • Modified test cases to reflect changes in the operations for MLIR module transformations.

Copy link
Contributor

coderabbitai bot commented Nov 27, 2024

Walkthrough

This pull request updates the version specifications for the mlir package in the dev-requirements.txt file for both Linux and non-Linux platforms. Additionally, it introduces a new option for tree printing in the Beaver.MLIR.PassManager module, enhancing the enable_ir_printing function's configurability. Furthermore, modifications are made to the MemRefTest module, specifically altering the operations in a test case related to MLIR module execution.

Changes

File Change Summary
dev-requirements.txt Updated mlir version from 20.0.0.2024102001+2deb3a26 to 20.0.0.2024112701+fad5ed6e (non-Linux) and from 20.0.0.2024102001+cuda.2deb3a26 to 20.0.0.2024112701+cuda.fad5ed6e (Linux).
lib/beaver/mlir/pass_manager.ex Added {:tree_printing_path, String.t()} to print_opt type and updated enable_ir_printing/2 to handle the new option.
test/memref_test.exs Modified test case in MemRefTest by removing finalizing-bufferize from operations in Beaver.Composer.nested.

Possibly related PRs

  • Upgrade MLIR and kinda to latest #356: Upgrade MLIR and kinda to latest - This PR updates the version specifications for the mlir package in dev-requirements.txt, which is directly related to the version changes made in the main PR.
  • Fix for IR printing argument updates introduced in upstream #357: Fix for IR printing argument updates introduced in upstream - This PR also updates the version specifications for the mlir package in dev-requirements.txt, aligning with the changes in the main PR regarding the mlir package version updates.

🐇 In the code we hop and play,
New paths for printing come our way.
With MLIR's version now so bright,
Our tests will run with pure delight!
A tree to print, a path to find,
In this code, joy's intertwined! 🌳✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d298c34 and fabf9a2.

📒 Files selected for processing (3)
  • dev-requirements.txt (1 hunks)
  • lib/beaver/mlir/pass_manager.ex (2 hunks)
  • test/memref_test.exs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • dev-requirements.txt
🔇 Additional comments (2)
lib/beaver/mlir/pass_manager.ex (1)

25-26: Consider adding validation and documentation for tree_printing_path.

While the implementation is functional, consider these improvements:

  1. Add validation for the path value
  2. Document the expected path format and behavior
  3. Consider handling path existence/permissions

Here's a suggested improvement:

  def enable_ir_printing(%MLIR.PassManager{} = pm, opts \\ []) do
+   tree_path = Keyword.get(opts, :tree_printing_path, "")
+   # Validate path if provided
+   unless tree_path == "" do
+     unless File.dir?(Path.dirname(tree_path)) do
+       raise ArgumentError, "Directory for tree_printing_path does not exist: #{tree_path}"
+     end
+   end
    MLIR.CAPI.mlirPassManagerEnableIRPrinting(
      pm,
      !!Keyword.get(opts, :before_all, false),
      !!Keyword.get(opts, :after_all, true),
      !!Keyword.get(opts, :module_scope, false),
      !!Keyword.get(opts, :after_only_on_change, false),
      !!Keyword.get(opts, :after_only_on_failure, false),
-     MLIR.StringRef.create(Keyword.get(opts, :tree_printing_path, ""))
+     MLIR.StringRef.create(tree_path)
    )
  end

Let's verify the MLIR API usage:

test/memref_test.exs (1)

42-42: Verify the removal of 'finalizing-bufferize' operation

The removal of 'finalizing-bufferize' from the operation list might impact the memory management pipeline. While the test passes, we should verify this change is intentional and aligns with the MLIR upgrade.

Let's check the codebase for similar patterns and MLIR documentation:

✅ Verification successful

Removal of 'finalizing-bufferize' is consistent with codebase patterns

The codebase search reveals that 'finalizing-bufferize' is not used anywhere else, while the current pattern follows established MLIR operation sequences:

  • 'one-shot-bufferize' is used in both memref and tosa tests
  • 'buffer-deallocation' is consistently used with 'convert-linalg-to-loops'
  • The change aligns with modern MLIR patterns where 'one-shot-bufferize' replaces older bufferization passes
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for other uses of these operations to understand the pattern
# and verify if this change is consistent across the codebase

# Check for other uses of finalizing-bufferize
echo "Searching for other uses of finalizing-bufferize..."
rg "finalizing-bufferize" -B 2 -A 2

# Check for patterns of buffer-deallocation and convert-linalg-to-loops
echo "Searching for similar operation patterns..."
rg "buffer-deallocation.*convert-linalg-to-loops|convert-linalg-to-loops.*buffer-deallocation" -B 2 -A 2

# Check if there are any relevant comments or documentation
echo "Searching for related documentation..."
fd -e md -e txt . -x rg -l "finalizing.?bufferize|buffer.?deallocation"

Length of output: 763


Script:

#!/bin/bash
# Let's try a broader search to understand the context and changes

# Check git history for the specific line changes in this file
echo "Checking git history for the specific file..."
git log -L 42,42:test/memref_test.exs

# Search for any MLIR-related configuration or version files
echo "Searching for MLIR configuration files..."
fd -e ex -e exs -e conf . -x rg -l "mlir.*version|MLIR.*VERSION"

# Look for any test files or documentation containing MLIR operation patterns
echo "Searching for MLIR operation patterns in tests..."
fd -e ex -e exs . -x rg "Beaver\.Composer\.nested.*\~w\{.*\}"

# Search for any comments or documentation about buffer operations
echo "Searching for buffer operation documentation..."
rg -g "*.{ex,exs,md}" "(?i)(bufferize|buffer.?deallocation)"

Length of output: 989

lib/beaver/mlir/pass_manager.ex Show resolved Hide resolved
@jackalcooper jackalcooper merged commit 98f4295 into main Nov 27, 2024
9 checks passed
@jackalcooper jackalcooper deleted the upgrade-mlir-with-new-ir-print-opt branch November 27, 2024 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant