提交 6b104c90 编写于 作者: T tensor-tang

fix profile

上级 4d774953
......@@ -178,6 +178,7 @@ void TestLACPrediction(const std::string &model_path,
cfg.device = 0;
cfg.specify_input_name = true;
cfg.enable_ir_optim = true;
cfg.ir_passes.push_back("fc_gru_fuse_pass");
predictor =
CreatePaddlePredictor<AnalysisConfig, PaddleEngineKind::kAnalysis>(cfg);
} else {
......@@ -208,13 +209,6 @@ void TestLACPrediction(const std::string &model_path,
PrintTime(timer.toc(), batch_size, repeat);
// check result
if (use_analysis) {
// run once for comparion as reference
auto ref_predictor =
CreatePaddlePredictor<NativeConfig, PaddleEngineKind::kNative>(config);
ref_predictor->Run(input_slots, &ref_outputs_slots);
}
EXPECT_EQ(outputs_slots.size(), 1UL);
auto &out = outputs_slots[0];
size_t size = std::accumulate(out.shape.begin(), out.shape.end(), 1,
......@@ -228,6 +222,10 @@ void TestLACPrediction(const std::string &model_path,
}
if (use_analysis) {
// run once for comparion as reference
auto ref_predictor =
CreatePaddlePredictor<NativeConfig, PaddleEngineKind::kNative>(config);
ref_predictor->Run(input_slots, &ref_outputs_slots);
EXPECT_EQ(ref_outputs_slots.size(), outputs_slots.size());
auto &ref_out = ref_outputs_slots[0];
size_t ref_size =
......@@ -256,12 +254,9 @@ void TestLACPrediction(const std::string &model_path,
}
LOG(INFO) << "has num ops: " << num_ops;
ASSERT_TRUE(fuse_statis.count("fc_fuse"));
ASSERT_TRUE(fuse_statis.count("fc_gru_fuse"));
LOG(INFO) << "fc fuse num:" << fuse_statis.at("fc_fuse");
LOG(INFO) << "fc gru fuse num:" << fuse_statis.at("fc_gru_fuse");
// ASSERT_TRUE(fuse_statis.count("fc_gru_fuse"));
// LOG(INFO) << fuse_statis.at("fc_gru_fuse");
LOG(INFO) << "fc fuse num:" << fuse_statis.at("fc_fuse");
// LOG(INFO) << "fc gru fuse num:" << fuse_statis.at("fc_gru_fuse");
}
}
......
......@@ -22,12 +22,25 @@
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#include "paddle/fluid/inference/api/paddle_inference_pass.h"
#include "paddle/fluid/inference/utils/singleton.h"
#include "paddle/fluid/platform/profiler.h"
DECLARE_bool(profile);
namespace paddle {
bool AnalysisPredictor::Init(
const std::shared_ptr<framework::Scope>& parent_scope) {
VLOG(3) << "Predictor::init()";
#if !defined(_WIN32)
if (FLAGS_profile) {
LOG(WARNING) << "Profiler is actived, might affect the performance";
LOG(INFO) << "You can turn off by set gflags '-profile false'";
auto tracking_device = config_.use_gpu ? platform::ProfilerState::kAll
: platform::ProfilerState::kCPU;
platform::EnableProfiler(tracking_device);
}
#endif
if (config_.use_gpu) {
place_ = paddle::platform::CUDAPlace(config_.device);
LOG(WARNING) << "ir optimize only supports CPU currently";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册