Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions paddle/fluid/framework/details/build_strategy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class ParallelExecutorPassBuilder : public ir::PassBuilder {
#ifdef PADDLE_WITH_DNNL
if (FLAGS_use_mkldnn) {
AppendPass(pass_name);
} else if (!strategy_.mkldnn_enabled_op_types_.empty()) {
} else if (!strategy_.onednn_enabled_op_types_.empty()) {
VLOG(1) << "mkldnn_enabled_op_types specify the operator type list to "
"use MKLDNN acceleration. It is null in default, means "
"that all the operators supported by MKLDNN will be "
Expand Down Expand Up @@ -320,7 +320,7 @@ ir::Graph *BuildStrategy::Apply(ir::Graph *graph,
}
} else if (pass->Type() == "onednn_placement_pass") {
pass->Set("mkldnn_enabled_op_types",
new std::unordered_set<std::string>(mkldnn_enabled_op_types_));
new std::unordered_set<std::string>(onednn_enabled_op_types_));
}
VLOG(1) << "Start Apply Pass " << pass->Type();
if (FLAGS_convert_all_blocks) {
Expand Down
10 changes: 5 additions & 5 deletions paddle/fluid/framework/details/build_strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct BuildStrategy {
// that all the operators supported by OneDNN will be
// accelerated. And it should not be set when
// FLAGS_use_mkldnn=false
std::unordered_set<std::string> mkldnn_enabled_op_types_;
std::unordered_set<std::string> onednn_enabled_op_types_;

// By default, memory_optimize would be opened if gc is disabled, and
// be closed if gc is enabled.
Expand All @@ -147,9 +147,9 @@ struct BuildStrategy {
bool enable_inference_pass_{false}; // switch for infernce pass
bool delete_dropout_{true}; // delete dropout op
#ifdef PADDLE_WITH_DNNL
bool use_onednn_{true}; // use mkdnn to do inference
bool use_onednn_{true}; // use onednn to do inference
#else
bool use_onednn_{false}; // use mkdnn to do inference
bool use_onednn_{false}; // use onednn to do inference
#endif

// FIXME(zcd): is_distribution_ is a temporary field, because in pserver mode,
Expand Down Expand Up @@ -250,8 +250,8 @@ inline std::ostream &operator<<(std::ostream &os,
os << "fused_attention_: " << strategy.fused_attention_ << std::endl;
os << "fused_feedforward_: " << strategy.fused_feedforward_ << std::endl;
os << "sequential_run_: " << strategy.sequential_run_ << std::endl;
os << "mkldnn_enabled_op_types_: ";
for (auto str : strategy.mkldnn_enabled_op_types_) {
os << "onednn_enabled_op_types_: ";
for (auto str : strategy.onednn_enabled_op_types_) {
os << str << ", ";
}
os << std::endl;
Expand Down
32 changes: 16 additions & 16 deletions paddle/fluid/inference/api/analysis_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,8 @@ AnalysisConfig::AnalysisConfig(const AnalysisConfig &other) {
CP_MEMBER(trt_exclude_var_names_);
// OneDNN related.
CP_MEMBER(use_onednn_);
CP_MEMBER(mkldnn_enabled_op_types_);
CP_MEMBER(mkldnn_cache_capacity_);
CP_MEMBER(onednn_enabled_op_types_);
CP_MEMBER(onednn_cache_capacity_);
// Bfloat16 related.
CP_MEMBER(use_onednn_bfloat16_);
CP_MEMBER(bfloat16_enabled_op_types_);
Expand Down Expand Up @@ -676,17 +676,17 @@ void AnalysisConfig::EnableONEDNN() {
Update();
}

void AnalysisConfig::DisableMKLDNN() {
void AnalysisConfig::DisableONEDNN() {
use_onednn_ = false;
Update();
}

void AnalysisConfig::SetMkldnnCacheCapacity(int capacity) {
void AnalysisConfig::SetOnednnCacheCapacity(int capacity) {
#ifdef PADDLE_WITH_DNNL
mkldnn_cache_capacity_ = capacity;
onednn_cache_capacity_ = capacity;
#else
LOG(ERROR) << "Please compile with MKLDNN first to set MKLDNN Thread Id";
mkldnn_cache_capacity_ = 0;
onednn_cache_capacity_ = 0;
#endif
}

Expand All @@ -711,12 +711,12 @@ void AnalysisConfig::EnableMkldnnBfloat16() {
Update();
}

void AnalysisConfig::DisableMkldnnFcPasses() {
void AnalysisConfig::DisableOnednnFcPasses() {
#ifdef PADDLE_WITH_DNNL
disable_mkldnn_fc_passes_ = true;
disable_onednn_fc_passes_ = true;
#else
LOG(ERROR) << "Please compile with MKLDNN first to use DisableMkldnnFcPasses";
disable_mkldnn_fc_passes_ = false;
LOG(ERROR) << "Please compile with MKLDNN first to use DisableOnednnFcPasses";
disable_onednn_fc_passes_ = false;
#endif
Update();
}
Expand Down Expand Up @@ -982,7 +982,7 @@ void AnalysisConfig::Update() {
!phi::backends::cpu::MayIUse(phi::backends::cpu::cpu_isa_t::avx2))) {
// User manually disable onednn or disable when not support AVX2
use_onednn_ = false;
pass_builder()->DisableMKLDNN();
pass_builder()->DisableONEDNN();
}
#endif
#ifdef PADDLE_WITH_OPENVINO
Expand Down Expand Up @@ -1058,9 +1058,9 @@ void AnalysisConfig::Update() {
#endif
}

if (disable_mkldnn_fc_passes_) {
if (disable_onednn_fc_passes_) {
#ifdef PADDLE_WITH_DNNL
pass_builder()->DisableMkldnnFcPasses();
pass_builder()->DisableOnednnFcPasses();
#endif
}

Expand Down Expand Up @@ -1141,8 +1141,8 @@ std::string AnalysisConfig::SerializeInfoCache() {
ss << trt_engine_memory_sharing_;

ss << use_onednn_;
ss << mkldnn_cache_capacity_;
for (auto &item : mkldnn_enabled_op_types_) ss << item;
ss << onednn_cache_capacity_;
for (auto &item : onednn_enabled_op_types_) ss << item;
ss << ";";

ss << use_onednn_bfloat16_;
Expand Down Expand Up @@ -1313,7 +1313,7 @@ std::string AnalysisConfig::Summary() {
{"cpu_math_thread", std::to_string(cpu_math_library_num_threads_)});
os.InsertRow({"enable_mkldnn", use_onednn_ ? "true" : "false"});
os.InsertRow(
{"mkldnn_cache_capacity", std::to_string(mkldnn_cache_capacity_)});
{"mkldnn_cache_capacity", std::to_string(onednn_cache_capacity_)});
#ifdef PADDLE_WITH_OPENVINO
os.InsertRow({"use_openvino", use_openvino_ ? "true" : "false"});
os.InsertRow({"openvino_inference_precision",
Expand Down
12 changes: 6 additions & 6 deletions paddle/fluid/inference/api/analysis_predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ void AnalysisPredictor::MkldnnPreSet(
VLOG(2) << "AnalysisPredictor::ZeroCopyRun get_cur_mkldnn_session_id="
<< phi::OneDNNContext::tls().get_cur_mkldnn_session_id();
// In cache clearing mode.
if (config_.mkldnn_cache_capacity_ > 0) {
if (config_.onednn_cache_capacity_ > 0) {
VLOG(2) << "In mkldnn cache clear mode.";
phi::OneDNNContext::tls().set_cur_mkldnn_session_id(
phi::OneDNNContextThreadLocals::kMKLDNNSessionID_CacheClearing);
Expand All @@ -1602,15 +1602,15 @@ void AnalysisPredictor::MkldnnPreSet(
phi::OneDNNContext::tls().set_cur_input_shape_str(ss.str());
}
phi::OneDNNContext::tls().set_cur_input_shape_cache_capacity(
config_.mkldnn_cache_capacity_);
config_.onednn_cache_capacity_);

#endif
}

void AnalysisPredictor::MkldnnPostReset() {
#ifdef PADDLE_WITH_DNNL
// In cache clearing mode.
if (config_.mkldnn_cache_capacity_ > 0 &&
if (config_.onednn_cache_capacity_ > 0 &&
static_cast<phi::OneDNNContext *>(
(&phi::DeviceContextPool::Instance())->Get(phi::CPUPlace()))
->GetCachedObjectsNumber() > 0) {
Expand All @@ -1620,10 +1620,10 @@ void AnalysisPredictor::MkldnnPostReset() {
(&phi::DeviceContextPool::Instance())->Get(phi::CPUPlace()))
->GetShapeBlobSize();
PADDLE_ENFORCE_LE(shape_blob_size,
static_cast<size_t>(config_.mkldnn_cache_capacity_),
static_cast<size_t>(config_.onednn_cache_capacity_),
common::errors::InvalidArgument(
"Required shape_blob_size should be less than or "
"equal to config_.mkldnn_cache_capacity_. "));
"equal to config_.onednn_cache_capacity_. "));
}
// We cannot reset to the default cache settings
// as there maybe CopyToCPU method used and oneDNN
Expand Down Expand Up @@ -2102,7 +2102,7 @@ void AnalysisPredictor::PrepareArgument() {

if (config_.mkldnn_enabled() && !config_.use_gpu()) {
LOG(INFO) << "MKLDNN is enabled";
argument_->SetMKLDNNEnabledOpTypes(config_.mkldnn_enabled_op_types_);
argument_->SetMKLDNNEnabledOpTypes(config_.onednn_enabled_op_types_);
}

if (config_.cinn_enabled()) {
Expand Down
18 changes: 9 additions & 9 deletions paddle/fluid/inference/api/paddle_analysis_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ struct PD_INFER_DECL AnalysisConfig {
/// \brief Turn down OneDNN.
///
///
void DisableMKLDNN();
void DisableONEDNN();

///
/// \brief Set the cache capacity of different input shapes for OneDNN.
Expand All @@ -885,7 +885,7 @@ struct PD_INFER_DECL AnalysisConfig {
///
/// \param capacity The cache capacity.
///
void SetMkldnnCacheCapacity(int capacity);
void SetOnednnCacheCapacity(int capacity);
///
/// \brief A boolean state telling whether to use the OneDNN.
///
Expand Down Expand Up @@ -921,8 +921,8 @@ struct PD_INFER_DECL AnalysisConfig {
///
/// \param op_list The operator type list.
///
void SetMKLDNNOp(std::unordered_set<std::string> op_list) {
mkldnn_enabled_op_types_ = op_list;
void SetONEDNNOp(std::unordered_set<std::string> op_list) {
onednn_enabled_op_types_ = op_list;
}

///
Expand All @@ -948,14 +948,14 @@ struct PD_INFER_DECL AnalysisConfig {
///
/// \brief Turn off OneDNN fc passes.
///
void DisableMkldnnFcPasses();
void DisableOnednnFcPasses();

///
/// \brief A boolean state telling whether to disable the OneDNN Fc passes.
///
/// \return bool Whether to disable the OneDNN Fc passes.
///
bool mkldnn_fc_passes_disabled() const { return disable_mkldnn_fc_passes_; }
bool mkldnn_fc_passes_disabled() const { return disable_onednn_fc_passes_; }

///
/// \brief A boolean state telling whether to use the OneDNN Bfloat16.
Expand Down Expand Up @@ -1255,7 +1255,7 @@ struct PD_INFER_DECL AnalysisConfig {
#else
bool use_onednn_{false};
#endif
std::unordered_set<std::string> mkldnn_enabled_op_types_;
std::unordered_set<std::string> onednn_enabled_op_types_;

bool model_from_memory_{false};

Expand Down Expand Up @@ -1287,14 +1287,14 @@ struct PD_INFER_DECL AnalysisConfig {
XpuConfig xpu_config_;

// onednn related.
int mkldnn_cache_capacity_{10};
int onednn_cache_capacity_{10};
bool use_onednn_bfloat16_{false};
std::unordered_set<std::string> bfloat16_enabled_op_types_;
bool use_onednn_int8_{false};
std::unordered_set<int> quantize_excluded_op_ids_{};
std::unordered_set<std::string> quantize_enabled_op_types_{};

bool disable_mkldnn_fc_passes_{false};
bool disable_onednn_fc_passes_{false};

// ipu related.
bool use_ipu_{false};
Expand Down
12 changes: 6 additions & 6 deletions paddle/fluid/inference/api/paddle_pass_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void GpuPassStrategy::EnableMkldnnInt8() {
LOG(ERROR) << "GPU not support MKL-DNN int8";
}

void GpuPassStrategy::DisableMkldnnFcPasses() {
void GpuPassStrategy::DisableOnednnFcPasses() {
LOG(ERROR) << "GPU not support MKL-DNN fc";
}

Expand Down Expand Up @@ -389,7 +389,7 @@ void CpuPassStrategy::EnableONEDNN() {
#endif
}

void CpuPassStrategy::DisableMKLDNN() {
void CpuPassStrategy::DisableONEDNN() {
ClearPasses();
passes_.assign(CpuBasicPasses.begin(), CpuBasicPasses.end());
}
Expand Down Expand Up @@ -475,14 +475,14 @@ void CpuPassStrategy::EnableMkldnnInt8() {
#endif
}

void CpuPassStrategy::DisableMkldnnFcPasses() {
void CpuPassStrategy::DisableOnednnFcPasses() {
#ifdef PADDLE_WITH_DNNL
if (!disable_mkldnn_fc_passes_) {
if (!disable_onednn_fc_passes_) {
EraseFcMkldnnPasses();
}
disable_mkldnn_fc_passes_ = true;
disable_onednn_fc_passes_ = true;
#else
disable_mkldnn_fc_passes_ = false;
disable_onednn_fc_passes_ = false;
#endif
}

Expand Down
14 changes: 7 additions & 7 deletions paddle/fluid/inference/api/paddle_pass_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class PD_INFER_DECL PassStrategy : public PaddlePassBuilder {
virtual void EnableONEDNN() {}

/// \brief Disable the use of OneDNN.
virtual void DisableMKLDNN() {}
virtual void DisableONEDNN() {}

/// \brief Enable OneDNN bfloat16.
virtual void EnableMkldnnBfloat16() {}
Expand All @@ -154,7 +154,7 @@ class PD_INFER_DECL PassStrategy : public PaddlePassBuilder {
virtual void EnableMkldnnInt8() {}

/// \brief Disable OneDNN fc passes.
virtual void DisableMkldnnFcPasses() {}
virtual void DisableOnednnFcPasses() {}

/// \brief Check if we are using gpu.
/// \return A bool variable implying whether we are in gpu mode.
Expand Down Expand Up @@ -201,7 +201,7 @@ class PD_INFER_DECL CpuPassStrategy : public PassStrategy {
use_onednn_ = other.use_onednn_;
use_onednn_bfloat16_ = other.use_onednn_bfloat16_;
use_onednn_int8_ = other.use_onednn_int8_;
disable_mkldnn_fc_passes_ = other.disable_mkldnn_fc_passes_;
disable_onednn_fc_passes_ = other.disable_onednn_fc_passes_;
deleted_passes_ = other.deleted_passes_;
}
/// \brief Default destructor.
Expand All @@ -214,7 +214,7 @@ class PD_INFER_DECL CpuPassStrategy : public PassStrategy {
void EnableONEDNN() override;

/// \brief Disable the use of OneDNN.
void DisableMKLDNN() override;
void DisableONEDNN() override;

/// \brief Enable OneDNN bfloat16.
void EnableMkldnnBfloat16() override;
Expand All @@ -223,7 +223,7 @@ class PD_INFER_DECL CpuPassStrategy : public PassStrategy {
void EnableMkldnnInt8() override;

/// \brief Disable OneDNN fc passes.
void DisableMkldnnFcPasses() override;
void DisableOnednnFcPasses() override;

protected:
/// \brief Erase OneDNN fc passes.
Expand All @@ -232,7 +232,7 @@ class PD_INFER_DECL CpuPassStrategy : public PassStrategy {
/// \cond Protected
bool use_onednn_bfloat16_{false};
bool use_onednn_int8_{false};
bool disable_mkldnn_fc_passes_{false};
bool disable_onednn_fc_passes_{false};
/// \endcond
};

Expand Down Expand Up @@ -266,7 +266,7 @@ class PD_INFER_DECL GpuPassStrategy : public PassStrategy {
void EnableMkldnnInt8() override;

/// \brief Disable OneDNN fc passes.
void DisableMkldnnFcPasses() override;
void DisableOnednnFcPasses() override;

/// \brief Default destructor.
virtual ~GpuPassStrategy() = default;
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/inference/capi/paddle_c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ PADDLE_CAPI_EXPORT extern void PD_SwitchIrDebug(PD_AnalysisConfig* config,

PADDLE_CAPI_EXPORT extern void PD_EnableONEDNN(PD_AnalysisConfig* config);

PADDLE_CAPI_EXPORT extern void PD_SetMkldnnCacheCapacity(
PADDLE_CAPI_EXPORT extern void PD_SetOnednnCacheCapacity(
PD_AnalysisConfig* config, int capacity);

PADDLE_CAPI_EXPORT extern bool PD_MkldnnEnabled(
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/inference/capi/pd_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,12 @@ void PD_EnableONEDNN(PD_AnalysisConfig* config) {
config->config.EnableONEDNN();
}

void PD_SetMkldnnCacheCapacity(PD_AnalysisConfig* config, int capacity) {
void PD_SetOnednnCacheCapacity(PD_AnalysisConfig* config, int capacity) {
PADDLE_ENFORCE_NOT_NULL(
config,
common::errors::InvalidArgument(
"The pointer of analysis configuration shouldn't be nullptr"));
config->config.SetMkldnnCacheCapacity(capacity);
config->config.SetOnednnCacheCapacity(capacity);
}

bool PD_MkldnnEnabled(const PD_AnalysisConfig* config) {
Expand Down
Loading
Loading