Skip to content

Commit 70dc728

Browse files
authored
[Paddle Inference] clean unused code (PaddlePaddle#48392)
1 parent b4db264 commit 70dc728

22 files changed

+33
-194
lines changed

paddle/fluid/framework/naive_executor.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,5 +195,6 @@ void NaiveExecutor::ResetTrtOps(int num) {
195195
}
196196
#endif
197197
}
198+
198199
} // namespace framework
199200
} // namespace paddle

paddle/fluid/inference/analysis/analyzer.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ void Analyzer::RunAnalysis(Argument *argument) {
3838
if (!disable_logs) {
3939
string::PrettyLogH1("--- Running analysis [%s]", pass);
4040
}
41-
if (!argument->enable_analysis_optim() && pass == "ir_analysis_pass")
42-
continue;
41+
if (!argument->enable_ir_optim() && pass == "ir_analysis_pass") continue;
4342

4443
auto *ptr = PassRegistry::Global().Retreive(pass);
4544
PADDLE_ENFORCE_NOT_NULL(ptr,

paddle/fluid/inference/analysis/analyzer_tester.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ TEST(Analyzer, analysis_without_tensorrt) {
3131
Argument argument;
3232
argument.SetDisableLogs(false);
3333
argument.SetModelDir(FLAGS_inference_model_dir);
34-
argument.SetEnableAnalysisOptim(false);
34+
argument.SetEnableIrOptim(false);
3535
argument.SetUseGPU(false);
3636
argument.SetAnalysisPasses({"ir_graph_build_pass",
3737
"ir_analysis_pass",
@@ -44,7 +44,7 @@ TEST(Analyzer, analysis_without_tensorrt) {
4444
TEST(Analyzer, analysis_with_tensorrt) {
4545
Argument argument;
4646
argument.SetDisableLogs(false);
47-
argument.SetEnableAnalysisOptim(false);
47+
argument.SetEnableIrOptim(false);
4848
argument.SetTensorRtMaxBatchSize(3);
4949
argument.SetTensorRtWorkspaceSize(1 << 20);
5050
argument.SetModelDir(FLAGS_inference_model_dir);

paddle/fluid/inference/analysis/argument.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ namespace paddle {
4242
namespace inference {
4343
namespace analysis {
4444

45-
using framework::ir::Graph;
46-
4745
#ifdef PADDLE_WITH_MKLDNN
4846
using VarQuantScale =
4947
std::unordered_map<std::string, std::pair<bool, phi::DenseTensor>>;
@@ -148,7 +146,7 @@ struct Argument {
148146
DECL_ARGUMENT_FIELD(model_params_path, ModelParamsPath, std::string);
149147
DECL_ARGUMENT_FIELD(model_from_memory, ModelFromMemory, bool);
150148
DECL_ARGUMENT_FIELD(optim_cache_dir, OptimCacheDir, std::string);
151-
DECL_ARGUMENT_FIELD(enable_analysis_optim, EnableAnalysisOptim, bool);
149+
DECL_ARGUMENT_FIELD(enable_ir_optim, EnableIrOptim, bool);
152150

153151
// For JITLayer
154152
DECL_ARGUMENT_FIELD(skip_load_params, SkipLoadParams, bool);

paddle/fluid/inference/analysis/helper.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -153,25 +153,6 @@ T &GetFromScope(const framework::Scope &scope, const std::string &name) {
153153
return *var->GetMutable<T>();
154154
}
155155

156-
static framework::proto::ProgramDesc LoadProgramDesc(
157-
const std::string &model_path) {
158-
std::ifstream fin(model_path, std::ios::in | std::ios::binary);
159-
PADDLE_ENFORCE_EQ(
160-
fin.is_open(),
161-
true,
162-
platform::errors::NotFound(
163-
"Cannot open file %s, please confirm whether the file exists",
164-
model_path));
165-
fin.seekg(0, std::ios::end);
166-
std::string buffer(fin.tellg(), ' ');
167-
fin.seekg(0, std::ios::beg);
168-
fin.read(&buffer[0], buffer.size());
169-
fin.close();
170-
framework::proto::ProgramDesc program_desc;
171-
program_desc.ParseFromString(buffer);
172-
return program_desc;
173-
}
174-
175156
static bool FileExists(const std::string &filepath) {
176157
std::ifstream file(filepath);
177158
bool exists = file.is_open();

paddle/fluid/inference/analysis/ir_pass_manager.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ using string::PrettyLogEndl;
3636
using string::Style;
3737

3838
IRPassManager::IRPassManager(Argument *argument) {
39-
ARGUMENT_CHECK_FIELD(argument, main_program);
40-
graph_ = std::unique_ptr<Graph>(new Graph(argument->main_program()));
41-
if (argument->Has("scope")) {
42-
auto *scope_ptr = argument->scope_ptr();
43-
PADDLE_ENFORCE_NOT_NULL(scope_ptr,
44-
platform::errors::PreconditionNotMet(
45-
"The scope ptr should not be nullptr."));
46-
graph_->SetNotOwned(framework::ir::kParamScopeAttr, scope_ptr);
47-
}
4839
disable_logs_ = argument->disable_logs();
4940

5041
ARGUMENT_CHECK_FIELD(argument, ir_analysis_passes);

paddle/fluid/inference/analysis/passes/CMakeLists.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@ cc_library(
3030
inference_op_replace_pass
3131
SRCS inference_op_replace_pass.cc
3232
DEPS analysis_pass graph_to_program_pass)
33-
if(WITH_TESTING)
34-
cc_library(
35-
ir_graph_clean_pass
36-
SRCS ir_graph_clean_pass.cc
37-
DEPS analysis_pass gtest)
38-
else()
39-
cc_library(
40-
ir_graph_clean_pass
41-
SRCS ir_graph_clean_pass.cc
42-
DEPS analysis_pass)
43-
endif()
4433

4534
cc_library(
4635
analysis_passes
@@ -52,8 +41,7 @@ cc_library(
5241
memory_optim_pass
5342
convert_to_mixed_precision
5443
inference_op_replace_pass
55-
ir_graph_to_program_pass
56-
ir_graph_clean_pass)
44+
ir_graph_to_program_pass)
5745

5846
set(analysis_deps
5947
${analysis_deps} analysis_passes subgraph_detector

paddle/fluid/inference/analysis/passes/convert_to_mixed_precision.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
#include "paddle/fluid/framework/program_desc.h"
3333
#include "paddle/fluid/framework/scope.h"
3434
#include "paddle/fluid/framework/var_desc.h"
35-
#include "paddle/fluid/inference/analysis/argument.h"
36-
#include "paddle/fluid/inference/analysis/passes/ir_graph_clean_pass.h"
3735
#include "paddle/fluid/inference/io.h"
3836
#include "paddle/phi/common/bfloat16.h"
3937
#include "paddle/phi/common/data_type.h"
@@ -358,12 +356,6 @@ void ConvertToMixedPrecisionPass::LoadAndPrepare() {
358356
}
359357
}
360358

361-
// Remove all control var
362-
IrInferCleanGraphPass pass;
363-
Argument arg;
364-
arg.SetMainGraphNotOwned(main_graph_.get());
365-
pass.Run(&arg);
366-
367359
ProcessCircleCases();
368360
}
369361

paddle/fluid/inference/analysis/passes/inference_op_replace_pass.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void InferenceOpReplacePass::RunImpl(Argument* argument) {
4040
}
4141

4242
std::string InferenceOpReplacePass::repr() const {
43-
return "inference-op-replace-pass";
43+
return "inference_op_replace_pass";
4444
}
4545

4646
} // namespace analysis

paddle/fluid/inference/analysis/passes/ir_analysis_pass.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void IrAnalysisPass::CollectFusionStatis(Argument* argument) {
5858
framework::ir::kFuseStatisAttr));
5959
}
6060

61-
std::string IrAnalysisPass::repr() const { return "ir-analysis-pass"; }
61+
std::string IrAnalysisPass::repr() const { return "ir_analysis_pass"; }
6262

6363
} // namespace analysis
6464
} // namespace inference

0 commit comments

Comments
 (0)