[Mlir-commits] [mlir] 497b7b8 - [mlir][linalg] Delete unused vars if there are shaped-only operands.
Hanhan Wang
llvmlistbot at llvm.org
Wed Mar 3 09:36:31 PST 2021
Author: Hanhan Wang
Date: 2021-03-03T09:36:08-08:00
New Revision: 497b7b8c00fce1a009df0e59407f468012efdc29
URL: https://github.com/llvm/llvm-project/commit/497b7b8c00fce1a009df0e59407f468012efdc29
DIFF: https://github.com/llvm/llvm-project/commit/497b7b8c00fce1a009df0e59407f468012efdc29.diff
LOG: [mlir][linalg] Delete unused vars if there are shaped-only operands.
Reviewed By: stella.stamenova
Differential Revision: https://reviews.llvm.org/D97851
Added:
Modified:
mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
Removed:
################################################################################
diff --git a/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc b/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc
index fd847e79437b..45d16f9041df 100644
--- a/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc
+++ b/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc
@@ -194,6 +194,8 @@ def test8(A: f32(M, K), B: f32(K)) -> (C: f32(M))
// IMPL: auto map0 = AffineMap::get(2, 2, {d0, d1}, context);
// IMPL: auto map1 = AffineMap::get(2, 2, {d1}, context);
// IMPL: auto map2 = AffineMap::get(2, 2, {d0}, context);
+// IMPL-LABEL: void Test9Op::regionBuilder(Block &block, ValueRange captures) {
+// IMPL: Value [[a:.*]](args[0]), [[c:.*]](args[2]);
ods_def<Test9Op>:
def test9(A: f32(M, K), B: f32(K)) -> (C: f32(M))
{
diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
index aac72cc05f8d..0f655f08a86f 100644
--- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
+++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
@@ -35,6 +35,7 @@
#include "llvm/Support/ToolOutputFile.h"
#include <map>
+#include <set>
#define DEBUG_TYPE "linalg-ods-gen"
@@ -2341,14 +2342,14 @@ void TCParser::printRegionBuilder(llvm::raw_ostream &os, StringRef cppOpName,
(linalg_yield(ValueRange{ {3} }));
})FMT";
- unsigned idx = 0;
std::string valueHandleStr;
llvm::raw_string_ostream valueHandleStringStream(valueHandleStr);
- llvm::interleaveComma(
- llvm::seq<int>(0, state.numArgs), valueHandleStringStream, [&](auto) {
- valueHandleStringStream << "_" << idx << "(args[" << idx << "])";
- idx++;
- });
+ std::set<unsigned> usedTensorId;
+ for (const auto &iter : state.orderedTensorArgs)
+ usedTensorId.insert(iter.second);
+ llvm::interleaveComma(usedTensorId, valueHandleStringStream, [&](auto idx) {
+ valueHandleStringStream << "_" << idx << "(args[" << idx << "])";
+ });
std::string expressionsStr;
llvm::raw_string_ostream expressionStringStream(expressionsStr);
More information about the Mlir-commits
mailing list