add DisableGlogInfo() to AnalysisConfig, test=develop (#20581)

revert-20712-fix_depthwise_conv
Pei Yang 5 years ago committed by GitHub
parent 2ff18e537f
commit 443f604c3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -93,8 +93,7 @@ void GraphPatternDetector::operator()(Graph *graph,
ValidateByNodeRole(&subgraphs);
if (subgraphs.empty()) return;
PrettyLogEndl(Style::detail(), "--- detected %d subgraphs",
subgraphs.size());
LOG(INFO) << "--- detected " << subgraphs.size() << " subgraphs";
int id = 0;
for (auto &g : subgraphs) {
VLOG(3) << "optimizing #" << id++ << " subgraph";

@ -131,6 +131,9 @@ AnalysisConfig::AnalysisConfig(const AnalysisConfig &other) {
// profile related.
CP_MEMBER(with_profile_);
// glog related.
CP_MEMBER(with_glog_info_);
// Ir related.
CP_MEMBER(enable_ir_optim_);
CP_MEMBER(use_feed_fetch_ops_);
@ -382,6 +385,8 @@ std::string AnalysisConfig::SerializeInfoCache() {
ss << with_profile_;
ss << with_glog_info_;
ss << enable_ir_optim_;
ss << use_feed_fetch_ops_;
ss << ir_debug_;
@ -458,6 +463,11 @@ void AnalysisConfig::EnableProfile() {
Update();
}
void AnalysisConfig::DisableGlogInfo() {
with_glog_info_ = false;
Update();
}
void AnalysisConfig::EnableAnakinEngine(
int max_batch_size, std::map<std::string, std::vector<int>> max_input_shape,
int min_subgraph_size, AnalysisConfig::Precision precision_mode,

@ -506,6 +506,12 @@ std::unique_ptr<PaddlePredictor> CreatePaddlePredictor<
framework::InitGflags(flags);
}
}
if (config.glog_info_disabled()) {
google::InitGoogleLogging("Init");
FLAGS_logtostderr = 1;
FLAGS_minloglevel = google::WARNING;
LOG(WARNING) << " - GLOG's LOG(INFO) is disabled.";
}
std::unique_ptr<PaddlePredictor> predictor(new AnalysisPredictor(config));
// Each config can only be used for one predictor.

@ -257,6 +257,15 @@ struct AnalysisConfig {
*/
bool profile_enabled() const { return with_profile_; }
/** \brief Disable GLOG information output for security.
*
* If called, no LOG(INFO) logs will be generated.
*/
void DisableGlogInfo();
/** A boolean state telling whether the GLOG info is disabled.
*/
bool glog_info_disabled() const { return !with_glog_info_; }
void SetInValid() const { is_valid_ = false; }
bool is_valid() const { return is_valid_; }
@ -325,6 +334,8 @@ struct AnalysisConfig {
bool with_profile_{false};
bool with_glog_info_{true};
// A runtime cache, shouldn't be transferred to others.
std::string serialized_info_cache_;

@ -35,6 +35,7 @@ TEST(ZeroCopyTensor, uint8) {
config.SetModel(model_dir);
config.SwitchUseFeedFetchOps(false);
config.EnableProfile();
config.DisableGlogInfo();
std::vector<std::vector<PaddleTensor>> inputs_all;
auto predictor = CreatePaddlePredictor(config);

@ -338,6 +338,7 @@ void BindAnalysisConfig(py::module *m) {
.def("ir_optim", &AnalysisConfig::ir_optim)
.def("enable_memory_optim", &AnalysisConfig::EnableMemoryOptim)
.def("enable_profile", &AnalysisConfig::EnableProfile)
.def("disable_glog_info", &AnalysisConfig::DisableGlogInfo)
.def("set_optim_cache_dir", &AnalysisConfig::SetOptimCacheDir)
.def("switch_use_feed_fetch_ops", &AnalysisConfig::SwitchUseFeedFetchOps,
py::arg("x") = true)

Loading…
Cancel
Save