Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make getStridesAndOffset const #145148

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Evanyl
Copy link
Contributor

@Evanyl Evanyl commented Jun 21, 2025

Make getStridesAndOffset const.

@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir mlir:ods labels Jun 21, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 21, 2025

@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-mlir

Author: Evan Liu (Evanyl)

Changes

Make getStridesAndOffset const.


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

2 Files Affected:

  • (modified) mlir/include/mlir/IR/BuiltinTypes.td (+2-2)
  • (modified) mlir/lib/IR/BuiltinTypes.cpp (+3-2)
diff --git a/mlir/include/mlir/IR/BuiltinTypes.td b/mlir/include/mlir/IR/BuiltinTypes.td
index 55d64d663f7ed..89ade79a3ac02 100644
--- a/mlir/include/mlir/IR/BuiltinTypes.td
+++ b/mlir/include/mlir/IR/BuiltinTypes.td
@@ -863,11 +863,11 @@ def Builtin_MemRef : Builtin_Type<"MemRef", "memref", [
     /// the distance in the number of elements between successive entries along
     /// a particular dimension.
     LogicalResult getStridesAndOffset(SmallVectorImpl<int64_t> &strides,
-                                      int64_t &offset);
+                                      int64_t &offset) const;
 
     /// Wrapper around getStridesAndOffset(SmallVectorImpl<int64_t>, int64_t)
     /// that will assert if the logical result is not succeeded.
-    std::pair<SmallVector<int64_t>, int64_t> getStridesAndOffset();
+    std::pair<SmallVector<int64_t>, int64_t> getStridesAndOffset() const;
 
     /// Return "true" if the layout is compatible with strided semantics.
     bool isStrided();
diff --git a/mlir/lib/IR/BuiltinTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp
index 97bab479c79bf..e3a00ac5a14b1 100644
--- a/mlir/lib/IR/BuiltinTypes.cpp
+++ b/mlir/lib/IR/BuiltinTypes.cpp
@@ -730,11 +730,12 @@ MemRefType MemRefType::canonicalizeStridedLayout() {
 }
 
 LogicalResult MemRefType::getStridesAndOffset(SmallVectorImpl<int64_t> &strides,
-                                              int64_t &offset) {
+                                              int64_t &offset) const {
   return getLayout().getStridesAndOffset(getShape(), strides, offset);
 }
 
-std::pair<SmallVector<int64_t>, int64_t> MemRefType::getStridesAndOffset() {
+std::pair<SmallVector<int64_t>, int64_t>
+MemRefType::getStridesAndOffset() const {
   SmallVector<int64_t> strides;
   int64_t offset;
   LogicalResult status = getStridesAndOffset(strides, offset);

@Evanyl
Copy link
Contributor Author

Evanyl commented Jun 21, 2025

cc @matthias-springer who moved this to a member function, thank you!

@Evanyl
Copy link
Contributor Author

Evanyl commented Jun 21, 2025

@matthias-springer would you also mind merging this in when you can? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir:ods mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants