Skip to content

Commit 0f67f75

Browse files
committed
Rename
1 parent 94f2813 commit 0f67f75

File tree

11 files changed

+58
-51
lines changed

11 files changed

+58
-51
lines changed

include/gc/Analysis/DataFlow/ConstantSubgraphAnalysis.h renamed to include/gc/Analysis/DataFlow/ConstantSubgraphAnalyser.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- ConstantSubgraphAnalysis.h - Constant subgraph analysis ------===//
1+
//===- ConstantSubgraphAnalyser.h - Constant subgraph analysis ------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,8 +13,8 @@
1313
//
1414
//===----------------------------------------------------------------------===//
1515

16-
#ifndef MLIR_ANALYSIS_DATAFLOW_CONSTANTSUBGRAPHANALYSIS_H
17-
#define MLIR_ANALYSIS_DATAFLOW_CONSTANTSUBGRAPHANALYSIS_H
16+
#ifndef MLIR_ANALYSIS_DATAFLOW_CONSTANTSUBGRAPHANALYSER_H
17+
#define MLIR_ANALYSIS_DATAFLOW_CONSTANTSUBGRAPHANALYSER_H
1818

1919
#include "mlir/Analysis/DataFlow/SparseAnalysis.h"
2020
#include <optional>
@@ -87,10 +87,10 @@ class InConstantSubgraph {
8787
};
8888

8989
//===----------------------------------------------------------------------===//
90-
// ConstantSubgraphAnalysis
90+
// ConstantSubgraphAnalyser
9191
//===----------------------------------------------------------------------===//
9292

93-
class ConstantSubgraphAnalysis
93+
class ConstantSubgraphAnalyser
9494
: public SparseForwardDataFlowAnalysis<Lattice<InConstantSubgraph>> {
9595
public:
9696
using SparseForwardDataFlowAnalysis::SparseForwardDataFlowAnalysis;
@@ -103,13 +103,13 @@ class ConstantSubgraphAnalysis
103103
};
104104

105105
//===----------------------------------------------------------------------===//
106-
// RunConstantSubgraphAnalysis
106+
// RunConstantSubgraphAnalyser
107107
//===----------------------------------------------------------------------===//
108108

109109
/// Runs constant subgraph analysis on the IR defined by `op`.
110-
struct RunConstantSubgraphAnalysis {
110+
struct RunConstantSubgraphAnalyser {
111111
public:
112-
RunConstantSubgraphAnalysis();
112+
RunConstantSubgraphAnalyser();
113113

114114
void run(Operation *op);
115115

@@ -124,4 +124,4 @@ struct RunConstantSubgraphAnalysis {
124124
} // end namespace dataflow
125125
} // end namespace mlir
126126

127-
#endif // MLIR_ANALYSIS_DATAFLOW_CONSTANTSUBGRAPHANALYSIS_H
127+
#endif // MLIR_ANALYSIS_DATAFLOW_CONSTANTSUBGRAPHANALYSER_H

include/gc/Transforms/Passes.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ namespace mlir {
1515
namespace gc {
1616

1717
#define GEN_PASS_DECL
18-
#define GEN_PASS_DECL_CSA
19-
#define GEN_PASS_DECL_CST
18+
#define GEN_PASS_DECL_CONSTANTSUBGRAPHANALYSIS
19+
#define GEN_PASS_DECL_CONSTANTTENSORFOLDING
2020
#include "gc/Transforms/Passes.h.inc"
2121

22-
std::unique_ptr<Pass> createCSAPass();
23-
std::unique_ptr<Pass> createCSTPass();
22+
std::unique_ptr<Pass> createConstantSubgraphAnalysisPass();
23+
std::unique_ptr<Pass> createConstantTensorFoldingPass();
2424

2525
#define GEN_PASS_REGISTRATION
2626
#include "gc/Transforms/Passes.h.inc"

include/gc/Transforms/Passes.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ def ConvertOneDNNGraphToLinalg : Pass<"convert-onednn-graph-to-linalg"> {
3131
];
3232
}
3333

34-
def CSA : Pass<"csa"> {
34+
def ConstantSubgraphAnalysis : Pass<"constant-subgraph-analysis"> {
3535
let summary = "Constant Subgraph Analysis";
3636
let description = [{
3737
This pass implements a constant subgraph analysis.
3838
}];
39-
let constructor = "mlir::gc::createCSAPass()";
39+
let constructor = "mlir::gc::createConstantSubgraphAnalysisPass()";
4040
}
4141

42-
def CST : Pass<"cst"> {
43-
let summary = "Constant Subgraph Transform";
42+
def ConstantTensorFolding : Pass<"constant-tensor-folding"> {
43+
let summary = "Constant Tensor Folding Transform";
4444
let description = [{
45-
This pass implements a constant subgraph transform.
45+
This pass implements a constant tensor folding transform.
4646
}];
47-
let constructor = "mlir::gc::createCSTPass()";
47+
let constructor = "mlir::gc::createConstantTensorFoldingPass()";
4848
let dependentDialects = [
4949
"tensor::TensorDialect",
5050
"linalg::LinalgDialect",

lib/gc/Analysis/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_mlir_library(GCAnalysis
2-
DataFlow/ConstantSubgraphAnalysis.cpp
2+
DataFlow/ConstantSubgraphAnalyser.cpp
33

44
ADDITIONAL_HEADER_DIRS
55
${PROJECT_SOURCE_DIR}/include/

lib/gc/Analysis/DataFlow/ConstantSubgraphAnalysis.cpp renamed to lib/gc/Analysis/DataFlow/ConstantSubgraphAnalyser.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
//===- ConstantSubgraphAnalysis.cpp - Constant subgraph analysis ----===//
1+
//===- ConstantSubgraphAnalyser.cpp - Constant subgraph analysis ----===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
#include "gc/Analysis/DataFlow/ConstantSubgraphAnalysis.h"
8+
#include "gc/Analysis/DataFlow/ConstantSubgraphAnalyser.h"
99
#include "mlir/Analysis/DataFlow/DeadCodeAnalysis.h"
1010
#include "mlir/Analysis/DataFlow/SparseAnalysis.h"
1111
#include "mlir/Dialect/Arith/IR/Arith.h"
@@ -46,13 +46,13 @@ void InConstantSubgraph::print(raw_ostream &os) const {
4646
}
4747

4848
//===----------------------------------------------------------------------===//
49-
// ConstantSubgraphAnalysis
49+
// ConstantSubgraphAnalyser
5050
//===----------------------------------------------------------------------===//
5151

52-
void ConstantSubgraphAnalysis::visitOperation(
52+
void ConstantSubgraphAnalyser::visitOperation(
5353
Operation *op, ArrayRef<const Lattice<InConstantSubgraph> *> operands,
5454
ArrayRef<Lattice<InConstantSubgraph> *> results) {
55-
LLVM_DEBUG(llvm::dbgs() << "ConstantSubgraphAnalysis: Visiting operation:\n"
55+
LLVM_DEBUG(llvm::dbgs() << "ConstantSubgraphAnalyser: Visiting operation:\n"
5656
<< *op << "\n");
5757

5858
bool in = true;
@@ -92,7 +92,7 @@ void ConstantSubgraphAnalysis::visitOperation(
9292
}
9393
}
9494

95-
void ConstantSubgraphAnalysis::setToEntryState(
95+
void ConstantSubgraphAnalyser::setToEntryState(
9696
Lattice<InConstantSubgraph> *lattice) {
9797
if (auto blockArg = cast<BlockArgument>(lattice->getPoint())) {
9898
auto parent_op = blockArg.getParentBlock()->getParentOp();
@@ -121,12 +121,12 @@ void ConstantSubgraphAnalysis::setToEntryState(
121121
}
122122

123123
//===----------------------------------------------------------------------===//
124-
// RunConstantSubgraphAnalysis
124+
// RunConstantSubgraphAnalyser
125125
//===----------------------------------------------------------------------===//
126126

127127
/// Get the operations whose inputs and outputs are all constant values.
128128
/// These operations will be put into a seperate subgraph.
129-
void RunConstantSubgraphAnalysis::getConstantSubgraph(DataFlowSolver &solver,
129+
void RunConstantSubgraphAnalyser::getConstantSubgraph(DataFlowSolver &solver,
130130
Operation *topFunc) {
131131
OpBuilder builder(topFunc->getContext());
132132
SmallVector<Operation *> constantOperations;
@@ -161,19 +161,19 @@ void RunConstantSubgraphAnalysis::getConstantSubgraph(DataFlowSolver &solver,
161161
}
162162
}
163163

164-
RunConstantSubgraphAnalysis::RunConstantSubgraphAnalysis() {
164+
RunConstantSubgraphAnalyser::RunConstantSubgraphAnalyser() {
165165
solver.load<DeadCodeAnalysis>();
166-
solver.load<ConstantSubgraphAnalysis>();
166+
solver.load<ConstantSubgraphAnalyser>();
167167
}
168168

169-
void RunConstantSubgraphAnalysis::run(Operation *topFunc) {
169+
void RunConstantSubgraphAnalyser::run(Operation *topFunc) {
170170
if (failed(solver.initializeAndRun(topFunc))) {
171171
return;
172172
}
173173
getConstantSubgraph(solver, topFunc);
174174
}
175175

176-
bool RunConstantSubgraphAnalysis::getInConstantSubgraph(Value val) {
176+
bool RunConstantSubgraphAnalyser::getInConstantSubgraph(Value val) {
177177
auto *lattice = solver.lookupState<Lattice<InConstantSubgraph>>(val);
178178
const InConstantSubgraph &latticeValue = lattice->getValue();
179179
return latticeValue.getInConstantSubgraph();

lib/gc/Transforms/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ gc_set_mlir_link_components(MLIR_LINK_COMPONENTS
77
add_mlir_library(GCPasses
88
OneDNNGraphToLinalg.cpp
99
TileNamed.cpp
10-
CSA.cpp
11-
CST.cpp
10+
ConstantSubgraphAnalysis.cpp
11+
ConstantTensorFolding.cpp
1212

1313
ADDITIONAL_HEADER_DIRS
1414
${PROJECT_SOURCE_DIR}/include
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//===- CSA.cpp - Constant Subgraph Analysis -----------------===//
1+
//===- ConstantSubgraphAnalysis.cpp - Constant Subgraph Analysis
2+
//-----------------===//
23
//
34
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,15 +11,15 @@
1011
// in MLIR.
1112
//
1213
//===----------------------------------------------------------------------===//
13-
#include "gc/Analysis/DataFlow/ConstantSubgraphAnalysis.h"
14+
#include "gc/Analysis/DataFlow/ConstantSubgraphAnalyser.h"
1415
#include "mlir/IR/Builders.h"
1516
#include "mlir/IR/Dialect.h"
1617
#include "mlir/Pass/Pass.h"
1718
#include "mlir/Transforms/Passes.h"
1819

1920
namespace mlir {
2021
namespace gc {
21-
#define GEN_PASS_DEF_CSA
22+
#define GEN_PASS_DEF_CONSTANTSUBGRAPHANALYSIS
2223
#include "gc/Transforms/Passes.h.inc"
2324
} // namespace gc
2425

@@ -27,11 +28,12 @@ using namespace mlir::dataflow;
2728

2829
namespace gc {
2930

30-
struct CSA : public impl::CSABase<CSA> {
31+
struct ConstantSubgraphAnalysis
32+
: public impl::ConstantSubgraphAnalysisBase<ConstantSubgraphAnalysis> {
3133
void runOnOperation() override;
3234
};
3335

34-
void CSA::runOnOperation() {
36+
void ConstantSubgraphAnalysis::runOnOperation() {
3537
Operation *op = getOperation();
3638
auto &func =
3739
op->getRegions().front().getBlocks().front().getOperations().front();
@@ -41,11 +43,13 @@ void CSA::runOnOperation() {
4143
// func.setAttr("onednn_graph.const_args",
4244
// builder.getI32ArrayAttr({1,2,3,4}));
4345

44-
RunConstantSubgraphAnalysis csa;
45-
(void)csa.run(&func);
46+
RunConstantSubgraphAnalyser runAnalyser;
47+
(void)runAnalyser.run(&func);
4648
}
4749

48-
std::unique_ptr<Pass> createCSAPass() { return std::make_unique<CSA>(); }
50+
std::unique_ptr<Pass> createConstantSubgraphAnalysisPass() {
51+
return std::make_unique<ConstantSubgraphAnalysis>();
52+
}
4953

5054
} // namespace gc
5155
} // namespace mlir

lib/gc/Transforms/CST.cpp renamed to lib/gc/Transforms/ConstantTensorFolding.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//===- CST.cpp - Constant Subgraph Transform -----------------===//
1+
//===- ConstantTensorFolding.cpp - Constant Subgraph Transform
2+
//-----------------===//
23
//
34
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,15 +35,16 @@
3435

3536
namespace mlir {
3637
namespace gc {
37-
#define GEN_PASS_DEF_CST
38+
#define GEN_PASS_DEF_CONSTANTTENSORFOLDING
3839
#include "gc/Transforms/Passes.h.inc"
3940
} // namespace gc
4041

4142
using namespace mlir;
4243

4344
namespace gc {
4445

45-
struct CST : public impl::CSTBase<CST> {
46+
struct ConstantTensorFolding
47+
: public impl::ConstantTensorFoldingBase<ConstantTensorFolding> {
4648
void runOnOperation() override;
4749
};
4850

@@ -385,7 +387,7 @@ static void addGlobalI32Array(ModuleOp &module, Location loc,
385387

386388
// Operate on tensors. Create fold() and compute() on module. The
387389
// folded weights and first-run flag is maintained by upper-level runtime.
388-
void CST::runOnOperation() {
390+
void ConstantTensorFolding::runOnOperation() {
389391
Operation *topOp = getOperation();
390392
MLIRContext *context = topOp->getContext();
391393
// A ModuleOp contains a single region, which contains a single block.
@@ -679,7 +681,9 @@ void CST::runOnOperation() {
679681
}
680682
}
681683

682-
std::unique_ptr<Pass> createCSTPass() { return std::make_unique<CST>(); }
684+
std::unique_ptr<Pass> createConstantTensorFoldingPass() {
685+
return std::make_unique<ConstantTensorFolding>();
686+
}
683687

684688
} // namespace gc
685689
} // namespace mlir

src/gc-opt/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ set(gc_opt_libs
1717
${conversion_libs}
1818
${MLIR_LINK_COMPONENTS}
1919
GCPasses
20-
GCAnalysis
21-
GCCpuRuntime)
20+
GCAnalysis)
2221

2322
if(GC_MLIR_CXX_FLAGS)
2423
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GC_MLIR_CXX_FLAGS}")

test/gc/Transforms/test_constant_weights_folding-1.mlir renamed to test/gc/Transforms/test_constant_tensor_folding-1.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: gc-opt --split-input-file -pass-pipeline="builtin.module(csa,cst)" %s | FileCheck %s
1+
// RUN: gc-opt --split-input-file -pass-pipeline="builtin.module(constant-subgraph-analysis,constant-tensor-folding)" %s | FileCheck %s
22

33
// CHECK-LABEL: func.func @entry
44
module {

0 commit comments

Comments
 (0)