Skip to content

Commit 18442a6

Browse files
committed
rename pass.h/.cc to analysis_pass
1 parent 9df2d8b commit 18442a6

18 files changed

+45
-122
lines changed

paddle/fluid/inference/analysis/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ cc_library(analysis SRCS pass_manager.cc node.cc data_flow_graph.cc graph_traits
66
analyzer.cc
77
helper.cc
88
# passes
9+
analysis_pass.cc
910
fluid_to_data_flow_graph_pass.cc
1011
data_flow_graph_to_fluid_pass.cc
1112
dfg_graphviz_draw_pass.cc

paddle/fluid/inference/analysis/pass.cc renamed to paddle/fluid/inference/analysis/analysis_pass.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "paddle/fluid/inference/analysis/pass.h"
15+
#include "paddle/fluid/inference/analysis/analysis_pass.h"

paddle/fluid/inference/analysis/pass.h renamed to paddle/fluid/inference/analysis/analysis_pass.h

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ namespace paddle {
2828
namespace inference {
2929
namespace analysis {
3030

31-
class Pass {
31+
class AnalysisPass {
3232
public:
33-
Pass() = default;
34-
virtual ~Pass() = default;
33+
AnalysisPass() = default;
34+
virtual ~AnalysisPass() = default;
3535
// Mutable Pass.
3636
virtual bool Initialize(Argument *argument) { return false; }
3737
// Readonly Pass.
@@ -42,53 +42,25 @@ class Pass {
4242
virtual bool Finalize() { return false; }
4343

4444
// Get a Pass appropriate to print the Node this pass operates on.
45-
virtual Pass *CreatePrinterPass(std::ostream &os,
46-
const std::string &banner) const {
45+
virtual AnalysisPass *CreatePrinterPass(std::ostream &os,
46+
const std::string &banner) const {
4747
return nullptr;
4848
}
4949

5050
// Create a debugger Pass that draw the DFG by graphviz toolkit.
51-
virtual Pass *CreateGraphvizDebugerPass() const { return nullptr; }
51+
virtual AnalysisPass *CreateGraphvizDebugerPass() const { return nullptr; }
5252

53-
virtual void Run() { LOG(FATAL) << "not valid"; }
54-
// Run on a single Node.
55-
virtual void Run(Node *x) { LOG(FATAL) << "not valid"; }
56-
// Run on a single Function.
57-
virtual void Run(Function *x) { LOG(FATAL) << "not valid"; }
58-
// Run on a single FunctionBlock.
59-
virtual void Run(FunctionBlock *x) { LOG(FATAL) << "not valid"; }
6053
// Run on a single DataFlowGraph.
61-
virtual void Run(DataFlowGraph *x) { LOG(FATAL) << "not valid"; }
54+
virtual void Run(DataFlowGraph *x) = 0;
6255

6356
// Human-readable short representation.
6457
virtual std::string repr() const = 0;
6558
// Human-readable long description.
6659
virtual std::string description() const { return "No DOC"; }
6760
};
6861

69-
// NodePass process on any Node types.
70-
class NodePass : public Pass {
71-
public:
72-
virtual void Run(Node *node) = 0;
73-
};
74-
75-
// NodePass process on any Function node types.
76-
class FunctionPass : public Pass {
77-
public:
78-
virtual void Run(Function *node) = 0;
79-
};
80-
81-
// NodePass process on any FunctionBlock node types.
82-
class FunctionBlockPass : public Pass {
83-
public:
84-
virtual void Run(FunctionBlock *node) = 0;
85-
};
86-
8762
// GraphPass processes on any GraphType.
88-
class DataFlowGraphPass : public Pass {
89-
public:
90-
virtual void Run(DataFlowGraph *graph) = 0;
91-
};
63+
class DataFlowGraphPass : public AnalysisPass {};
9264

9365
} // namespace analysis
9466
} // namespace inference

paddle/fluid/inference/analysis/analyzer.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "paddle/fluid/inference/analysis/analyzer.h"
1616
#include <string>
1717
#include <vector>
18+
1819
#include "paddle/fluid/inference/analysis/data_flow_graph_to_fluid_pass.h"
1920
#include "paddle/fluid/inference/analysis/dfg_graphviz_draw_pass.h"
2021
#include "paddle/fluid/inference/analysis/fluid_to_data_flow_graph_pass.h"
@@ -58,7 +59,7 @@ class DfgPassManagerImpl final : public DfgPassManager {
5859
std::string description() const override { return "DFG pass manager."; }
5960

6061
private:
61-
void AddPass(const std::string& name, Pass* pass) {
62+
void AddPass(const std::string& name, AnalysisPass* pass) {
6263
VLOG(3) << "Adding pass " << name;
6364
Register(name, pass);
6465
AddGraphvizDebugerPass(pass);
@@ -87,7 +88,7 @@ class DfgPassManagerImpl final : public DfgPassManager {
8788
}
8889

8990
// Add the graphviz debuger pass if the parent pass has one.
90-
void AddGraphvizDebugerPass(Pass* pass) {
91+
void AddGraphvizDebugerPass(AnalysisPass* pass) {
9192
auto* debuger_pass = pass->CreateGraphvizDebugerPass();
9293
if (debuger_pass) {
9394
Register(debuger_pass->repr(), debuger_pass);

paddle/fluid/inference/analysis/analyzer.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ limitations under the License. */
3636
*/
3737

3838
#include <gflags/gflags.h>
39+
#include <string>
40+
#include <vector>
41+
42+
#include "paddle/fluid/inference/analysis/analysis_pass.h"
3943
#include "paddle/fluid/inference/analysis/flags.h"
40-
#include "paddle/fluid/inference/analysis/pass.h"
4144
#include "paddle/fluid/inference/analysis/pass_manager.h"
4245

4346
namespace paddle {

paddle/fluid/inference/analysis/data_flow_graph_to_fluid_pass.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ class DFG_DebuggerPass : public DFG_GraphvizDrawPass {
263263
};
264264
} // namespace
265265

266-
Pass *DataFlowGraphToFluidPass::CreateGraphvizDebugerPass() const {
266+
AnalysisPass *DataFlowGraphToFluidPass::CreateGraphvizDebugerPass() const {
267267
return new DFG_DebuggerPass(DFG_GraphvizDrawPass::Config(
268268
FLAGS_IA_graphviz_log_root,
269269
"data_flow_graph_to_fluid_graphviz_debugger"));

paddle/fluid/inference/analysis/data_flow_graph_to_fluid_pass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
#include <string>
2323
#include "paddle/fluid/framework/program_desc.h"
24+
#include "paddle/fluid/inference/analysis/analysis_pass.h"
2425
#include "paddle/fluid/inference/analysis/data_flow_graph.h"
25-
#include "paddle/fluid/inference/analysis/pass.h"
2626

2727
namespace paddle {
2828
namespace inference {
@@ -42,7 +42,7 @@ class DataFlowGraphToFluidPass final : public DataFlowGraphPass {
4242
return "Transform a DFG to a Fluid ProgramDesc";
4343
}
4444

45-
Pass *CreateGraphvizDebugerPass() const override;
45+
AnalysisPass *CreateGraphvizDebugerPass() const override;
4646

4747
protected:
4848
// Add a Fluid Op into the ProgramDesc.

paddle/fluid/inference/analysis/dfg_graphviz_draw_pass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ limitations under the License. */
2121

2222
#include <fstream>
2323
#include <string>
24+
#include "paddle/fluid/inference/analysis/analysis_pass.h"
2425
#include "paddle/fluid/inference/analysis/dot.h"
25-
#include "paddle/fluid/inference/analysis/pass.h"
2626

2727
namespace paddle {
2828
namespace inference {

paddle/fluid/inference/analysis/fluid_to_data_flow_graph_pass.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class DFG_DebuggerPass : public DFG_GraphvizDrawPass {
6666
};
6767
}
6868

69-
Pass *FluidToDataFlowGraphPass::CreateGraphvizDebugerPass() const {
69+
AnalysisPass *FluidToDataFlowGraphPass::CreateGraphvizDebugerPass() const {
7070
return new DFG_DebuggerPass(DFG_GraphvizDrawPass::Config(
7171
FLAGS_IA_graphviz_log_root, "fluid-to-dfg-debuger"));
7272
}

paddle/fluid/inference/analysis/fluid_to_data_flow_graph_pass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#include <string>
2323

2424
#include "paddle/fluid/framework/program_desc.h"
25+
#include "paddle/fluid/inference/analysis/analysis_pass.h"
2526
#include "paddle/fluid/inference/analysis/data_flow_graph.h"
26-
#include "paddle/fluid/inference/analysis/pass.h"
2727

2828
namespace paddle {
2929
namespace inference {
@@ -46,7 +46,7 @@ class FluidToDataFlowGraphPass final : public DataFlowGraphPass {
4646
return "transform a fluid ProgramDesc to a data flow graph.";
4747
}
4848

49-
Pass *CreateGraphvizDebugerPass() const override;
49+
AnalysisPass *CreateGraphvizDebugerPass() const override;
5050

5151
private:
5252
framework::proto::ProgramDesc const *desc_;

0 commit comments

Comments
 (0)