Skip to content

[mlir][tosa] Fix indexing in TosaToTensor #140903

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

Closed
wants to merge 0 commits into from

Conversation

shay-kl
Copy link
Contributor

@shay-kl shay-kl commented May 21, 2025

Changed the indexing used in the extractOp from one that is intended for 0d tensors to one that is intended for 1d tensors.

@llvmbot
Copy link
Member

llvmbot commented May 21, 2025

@llvm/pr-subscribers-mlir-tosa

Author: Shay Kleiman (shay-kl)

Changes

Changed the indexing used in the extractOp from one that is intended for 0d tensors to one that is intended for 1d tensors.


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

1 Files Affected:

  • (modified) mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp (+1-1)
diff --git a/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp b/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
index 5f23a33049f87..6c68a7fc25103 100644
--- a/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
+++ b/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
@@ -362,7 +362,7 @@ class PadConverter : public OpConversionPattern<tosa::PadOp> {
     // Setup the default constantAttr.
 
     Value padConstant = rewriter.createOrFold<tensor::ExtractOp>(
-        loc, padOp.getPadConst(), ValueRange({}));
+      loc, padOp.getPadConst(), ValueRange({rewriter.create<arith::ConstantIndexOp>(loc, 0)}));
 
     if (!padConstant) {
       return rewriter.notifyMatchFailure(

@llvmbot
Copy link
Member

llvmbot commented May 21, 2025

@llvm/pr-subscribers-mlir

Author: Shay Kleiman (shay-kl)

Changes

Changed the indexing used in the extractOp from one that is intended for 0d tensors to one that is intended for 1d tensors.


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

1 Files Affected:

  • (modified) mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp (+1-1)
diff --git a/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp b/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
index 5f23a33049f87..6c68a7fc25103 100644
--- a/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
+++ b/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
@@ -362,7 +362,7 @@ class PadConverter : public OpConversionPattern<tosa::PadOp> {
     // Setup the default constantAttr.
 
     Value padConstant = rewriter.createOrFold<tensor::ExtractOp>(
-        loc, padOp.getPadConst(), ValueRange({}));
+      loc, padOp.getPadConst(), ValueRange({rewriter.create<arith::ConstantIndexOp>(loc, 0)}));
 
     if (!padConstant) {
       return rewriter.notifyMatchFailure(

Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
View the diff from clang-format here.
diff --git a/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp b/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
index 6c68a7fc2..615c7ca1c 100644
--- a/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
+++ b/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
@@ -362,7 +362,8 @@ public:
     // Setup the default constantAttr.
 
     Value padConstant = rewriter.createOrFold<tensor::ExtractOp>(
-      loc, padOp.getPadConst(), ValueRange({rewriter.create<arith::ConstantIndexOp>(loc, 0)}));
+        loc, padOp.getPadConst(),
+        ValueRange({rewriter.create<arith::ConstantIndexOp>(loc, 0)}));
 
     if (!padConstant) {
       return rewriter.notifyMatchFailure(

@shay-kl shay-kl closed this May 21, 2025
@shay-kl shay-kl force-pushed the shay-kl/fix-tensor-padop-indexing branch from 1f5cd5d to 8818728 Compare May 21, 2025 14:19
@shay-kl shay-kl deleted the shay-kl/fix-tensor-padop-indexing branch May 21, 2025 14:19
@shay-kl shay-kl restored the shay-kl/fix-tensor-padop-indexing branch May 21, 2025 14:20
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.

2 participants