Skip to content

[MLIR][NFC] Expose computeProduct function. #135192

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

Merged
merged 1 commit into from
Apr 10, 2025
Merged

Conversation

lialan
Copy link
Member

@lialan lialan commented Apr 10, 2025

Make it non-static, as its functionality is quite generic.

Make it non-static, as its functionality is quite generic.
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

mlir/lib/Dialect/Affine/IR/AffineOps.cpp:5084

  • Since computeProduct is now exposed for broader use, please ensure that test cases cover scenarios for both nullptr checks and dynamic non-constant term handling to maintain robust behavior.
OpFoldResult computeProduct(Location loc, OpBuilder &builder,

@llvmbot
Copy link
Member

llvmbot commented Apr 10, 2025

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-affine

Author: Alan Li (lialan)

Changes

Make it non-static, as its functionality is quite generic.


Full diff: https://github.com/llvm/llvm-project/pull/135192.diff

2 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Affine/IR/AffineOps.h (+5)
  • (modified) mlir/lib/Dialect/Affine/IR/AffineOps.cpp (+2-4)
diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
index bbf38f2293448..6fdb72c370e6d 100644
--- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
+++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
@@ -53,6 +53,11 @@ Region *getAffineScope(Operation *op);
 /// analysis scope.
 Region *getAffineAnalysisScope(Operation *op);
 
+/// Return the product of `terms`, creating an `affine.apply` if any of them are
+/// non-constant values. If any of `terms` is `nullptr`, return `nullptr`.
+OpFoldResult computeProduct(Location loc, OpBuilder &builder,
+                            ArrayRef<OpFoldResult> terms);
+
 /// AffineDmaStartOp starts a non-blocking DMA operation that transfers data
 /// from a source memref to a destination memref. The source and destination
 /// memref need not be of the same dimensionality, but need to have the same
diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index 9c5b9e82cd5e0..aa49c49062c76 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -5081,10 +5081,8 @@ struct DropLinearizeUnitComponentsIfDisjointOrZero final
   }
 };
 
-/// Return the product of `terms`, creating an `affine.apply` if any of them are
-/// non-constant values. If any of `terms` is `nullptr`, return `nullptr`.
-static OpFoldResult computeProduct(Location loc, OpBuilder &builder,
-                                   ArrayRef<OpFoldResult> terms) {
+OpFoldResult computeProduct(Location loc, OpBuilder &builder,
+                            ArrayRef<OpFoldResult> terms) {
   int64_t nDynamic = 0;
   SmallVector<Value> dynamicPart;
   AffineExpr result = builder.getAffineConstantExpr(1);

Copy link
Contributor

@krzysz00 krzysz00 left a comment

Choose a reason for hiding this comment

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

Lgtm

@lialan lialan merged commit 959b8aa into llvm:main Apr 10, 2025
12 of 13 checks passed
@lialan lialan deleted the lialan/affine branch April 10, 2025 15:29
var-const pushed a commit to ldionne/llvm-project that referenced this pull request Apr 17, 2025
Make it non-static, as its functionality is quite generic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants