Skip to content

Commit

Permalink
MemrefToArith: add missing includes
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 599255451
  • Loading branch information
j2kun authored and copybara-github committed Jan 17, 2024
1 parent 3c1b6d2 commit 56b4dca
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 19 deletions.
14 changes: 11 additions & 3 deletions lib/Conversion/MemrefToArith/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ cc_library(
srcs = ["Utils.cpp"],
hdrs = ["@heir//include/Conversion/MemrefToArith:Utils.h"],
deps = [
"@llvm-project//llvm:Support",
"@llvm-project//mlir:AffineAnalysis",
"@llvm-project//mlir:AffineDialect",
"@llvm-project//mlir:AffineUtils",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Support",
],
)

Expand All @@ -22,9 +25,7 @@ cc_test(
deps = [
":Utils",
"@googletest//:gtest_main",
"@llvm-project//mlir:AffineAnalysis",
"@llvm-project//mlir:AffineDialect",
"@llvm-project//mlir:AffineUtils",
"@llvm-project//llvm:Support",
],
)

Expand All @@ -37,9 +38,12 @@ cc_library(
"@llvm-project//mlir:AffineAnalysis",
"@llvm-project//mlir:AffineDialect",
"@llvm-project//mlir:AffineUtils",
"@llvm-project//mlir:ArithDialect",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:MemRefDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:SCFDialect",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TransformUtils",
],
)
Expand All @@ -52,9 +56,12 @@ cc_library(
"@llvm-project//mlir:AffineAnalysis",
"@llvm-project//mlir:AffineDialect",
"@llvm-project//mlir:AffineUtils",
"@llvm-project//mlir:ArithDialect",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:MemRefDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:SCFDialect",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TransformUtils",
],
)
Expand Down Expand Up @@ -87,6 +94,7 @@ cc_library(
"@llvm-project//mlir:AffineAnalysis",
"@llvm-project//mlir:AffineDialect",
"@llvm-project//mlir:AffineUtils",
"@llvm-project//mlir:ArithDialect",
"@llvm-project//mlir:FuncDialect",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:MemRefDialect",
Expand Down
13 changes: 9 additions & 4 deletions lib/Conversion/MemrefToArith/ExpandCopy.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
#include <numeric>
#include <memory>
#include <utility>

#include "include/Conversion/MemrefToArith/MemrefToArith.h"
#include "mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/IR/AffineOps.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/IR/AffineValueMap.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/Utils.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Arith/IR/Arith.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/MemRef/IR/MemRef.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/SCF/IR/SCF.h" // from @llvm-project
#include "mlir/include/mlir/IR/BuiltinOps.h" // from @llvm-project
#include "mlir/include/mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/include/mlir/IR/DialectRegistry.h" // from @llvm-project
#include "mlir/include/mlir/IR/PatternMatch.h" // from @llvm-project
#include "mlir/include/mlir/Pass/Pass.h" // from @llvm-project
#include "mlir/include/mlir/Support/LLVM.h" // from @llvm-project
#include "mlir/include/mlir/Support/LogicalResult.h" // from @llvm-project
#include "mlir/include/mlir/Transforms/DialectConversion.h" // from @llvm-project
#include "mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h" // from @llvm-project

namespace mlir {
namespace heir {
Expand Down
18 changes: 14 additions & 4 deletions lib/Conversion/MemrefToArith/MemrefGlobalReplace.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
#include <numeric>
#include <cassert>
#include <memory>
#include <utility>

#include "include/Conversion/MemrefToArith/MemrefToArith.h"
#include "include/Conversion/MemrefToArith/Utils.h"
#include "mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/IR/AffineOps.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/IR/AffineValueMap.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/Utils.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Arith/IR/Arith.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/MemRef/IR/MemRef.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/SCF/IR/SCF.h" // from @llvm-project
#include "mlir/include/mlir/Pass/Pass.h" // from @llvm-project
#include "mlir/include/mlir/IR/BuiltinAttributeInterfaces.h" // from @llvm-project
#include "mlir/include/mlir/IR/BuiltinAttributes.h" // from @llvm-project
#include "mlir/include/mlir/IR/BuiltinOps.h" // from @llvm-project
#include "mlir/include/mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/include/mlir/IR/DialectRegistry.h" // from @llvm-project
#include "mlir/include/mlir/IR/PatternMatch.h" // from @llvm-project
#include "mlir/include/mlir/IR/SymbolTable.h" // from @llvm-project
#include "mlir/include/mlir/Pass/Pass.h" // from @llvm-project
#include "mlir/include/mlir/Support/LLVM.h" // from @llvm-project
#include "mlir/include/mlir/Support/LogicalResult.h" // from @llvm-project
#include "mlir/include/mlir/Transforms/DialectConversion.h" // from @llvm-project
#include "mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h" // from @llvm-project

namespace mlir {
namespace heir {
Expand Down
24 changes: 18 additions & 6 deletions lib/Conversion/MemrefToArith/UnrollAndForward.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
#include <cstddef>
#include <deque>
#include <cstdint>
#include <functional>
#include <limits>
#include <memory>
#include <optional>
#include <queue>
#include <unordered_map>
#include <utility>
#include <vector>

#include "include/Conversion/MemrefToArith/MemrefToArith.h"
#include "include/Conversion/MemrefToArith/Utils.h"
#include "llvm/include/llvm/ADT/TypeSwitch.h" // from @llvm-project
#include "llvm/include/llvm/Support/Casting.h" // from @llvm-project
#include "llvm/include/llvm/ADT/STLExtras.h" // from @llvm-project
#include "llvm/include/llvm/ADT/SmallVector.h" // from @llvm-project
#include "llvm/include/llvm/ADT/TypeSwitch.h" // from @llvm-project
#include "llvm/include/llvm/Support/Casting.h" // from @llvm-project
#include "llvm/include/llvm/Support/ErrorHandling.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/Analysis/LoopAnalysis.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/IR/AffineOps.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/IR/AffineValueMap.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/LoopUtils.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/Utils.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Arith/IR/Arith.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Func/IR/FuncOps.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/MemRef/IR/MemRef.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/SCF/IR/SCF.h" // from @llvm-project
#include "mlir/include/mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/include/mlir/IR/DialectRegistry.h" // from @llvm-project
#include "mlir/include/mlir/IR/ImplicitLocOpBuilder.h" // from @llvm-project
#include "mlir/include/mlir/IR/Location.h" // from @llvm-project
#include "mlir/include/mlir/IR/PatternMatch.h" // from @llvm-project
#include "mlir/include/mlir/IR/Types.h" // from @llvm-project
#include "mlir/include/mlir/IR/Value.h" // from @llvm-project
#include "mlir/include/mlir/IR/Visitors.h" // from @llvm-project
#include "mlir/include/mlir/Pass/Pass.h" // from @llvm-project
#include "mlir/include/mlir/Support/LLVM.h" // from @llvm-project
#include "mlir/include/mlir/Support/LogicalResult.h" // from @llvm-project
#include "mlir/include/mlir/Transforms/DialectConversion.h" // from @llvm-project
#include "mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h" // from @llvm-project

namespace mlir {
namespace heir {
Expand Down
11 changes: 10 additions & 1 deletion lib/Conversion/MemrefToArith/Utils.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#include <cstdint>
#include <optional>
#include <utility>
#include <vector>

#include "llvm/include/llvm/ADT/ArrayRef.h" // from @llvm-project
#include "llvm/include/llvm/ADT/SmallVector.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/IR/AffineOps.h" // from @llvm-project
#include "mlir/include/mlir/Dialect/Affine/IR/AffineValueMap.h" // from @llvm-project
#include "mlir/include/mlir/IR/AffineExpr.h" // from @llvm-project
#include "mlir/include/mlir/IR/BuiltinAttributeInterfaces.h" // from @llvm-project
#include "mlir/include/mlir/IR/Types.h" // from @llvm-project
#include "mlir/include/mlir/Support/LLVM.h" // from @llvm-project

namespace mlir {
namespace heir {
Expand Down Expand Up @@ -47,7 +56,7 @@ llvm::SmallVector<int64_t> unflattenIndex(int64_t index,
int64_t offset) {
llvm::SmallVector<int64_t> indices;
int64_t ndx = index - offset;
for (long stride : strides) {
for (int64_t stride : strides) {
indices.push_back(ndx / stride);
ndx = ndx % stride;
}
Expand Down
6 changes: 5 additions & 1 deletion lib/Conversion/MemrefToArith/UtilsTest.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#include <cstdint>

#include "gmock/gmock.h" // from @googletest
#include "gtest/gtest.h" // from @googletest
#include "include/Conversion/MemrefToArith/Utils.h"
#include "llvm/include/llvm/ADT/SmallVector.h" // from @llvm-project

namespace mlir {
namespace heir {

using ::llvm::SmallVector;
using ::testing::ElementsAre;
using ::testing::ElementsAreArray;

TEST(FlattenIndex, UnflattenOffsetZero) {
llvm::SmallVector<int64_t, 3> strides = {20, 5, 1};
SmallVector<int64_t, 3> strides = {20, 5, 1};
static const int64_t offset = 0;
EXPECT_THAT(unflattenIndex(33, strides, offset), ElementsAre(1, 2, 3));
}
Expand Down

0 comments on commit 56b4dca

Please sign in to comment.