Skip to content

Commit

Permalink
add PADDLE_WITH_DNNL
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanglirong1999 committed Nov 14, 2023
1 parent 59de8ef commit c67af90
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions paddle/fluid/distributed/fleet_executor/fleet_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,12 @@ void FleetExecutor::Init(
0,
platform::errors::InvalidArgument(
"Fleet executor is inited with empty task node"));
#ifdef PADDLE_WITH_DNNL
if (!platform::is_cpu_place(place)) {
FLAGS_use_mkldnn = false;
}
#endif

// Set the unused var after running while op
std::set<TaskNode*> sub_block_tasks;
std::vector<std::string> while_block_vars;
Expand Down
2 changes: 2 additions & 0 deletions paddle/fluid/framework/executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ ExecutorPrepareContext::~ExecutorPrepareContext() {
}

Executor::Executor(const platform::Place& place) : place_(place) {
#ifdef PADDLE_WITH_DNNL
if (!platform::is_cpu_place(place_)) {
FLAGS_use_mkldnn = false;
}
#endif
}

Executor::~Executor() {
Expand Down
2 changes: 2 additions & 0 deletions paddle/fluid/framework/naive_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ PHI_DECLARE_bool(use_mkldnn);
namespace paddle {
namespace framework {
NaiveExecutor::NaiveExecutor(const platform::Place &place) : place_(place) {
#ifdef PADDLE_WITH_DNNL
if (!platform::is_cpu_place(place_)) {
FLAGS_use_mkldnn = false;
}
#endif
}
void NaiveExecutor::Prepare(Scope *scope,
const ProgramDesc &program_desc,
Expand Down
3 changes: 3 additions & 0 deletions paddle/fluid/framework/new_executor/standalone_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ StandaloneExecutor::StandaloneExecutor(const platform::Place& place,
const interpreter::Plan& plan,
Scope* scope)
: place_(place), plan_(plan), scope_(scope) {
#ifdef PADDLE_WITH_DNNL
if (!platform::is_cpu_place(place_)) {
FLAGS_use_mkldnn = false;
}
#endif

int64_t micro_batch_num = plan_.MicroBatchNum();
vec_force_events_to_wait_.resize(micro_batch_num);
for (int64_t i = 0; i < micro_batch_num; ++i) {
Expand Down
4 changes: 3 additions & 1 deletion paddle/fluid/framework/parallel_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ void InitP2P(const std::vector<platform::Place> &places) {
VLOG(1) << "init p2p";
});
#endif
}
} // namespace framework

ParallelExecutor::ParallelExecutor(const std::vector<platform::Place> &places,
const std::vector<std::string> &bcast_vars,
Expand All @@ -676,6 +676,7 @@ ParallelExecutor::ParallelExecutor(const std::vector<platform::Place> &places,
const BuildStrategy &build_strategy,
ir::Graph *graph)
: member_(new ParallelExecutorPrivate(places, scope)) {
#ifdef PADDLE_WITH_DNNL
for (size_t i = 0; i < places.size(); i++) {
if (!platform::is_cpu_place(places[i])) {
FLAGS_use_mkldnn = false;
Expand All @@ -687,6 +688,7 @@ ParallelExecutor::ParallelExecutor(const std::vector<platform::Place> &places,
}
}
}
#endif
PADDLE_ENFORCE_EQ(!places.empty(),
true,
platform::errors::Unavailable(
Expand Down

0 comments on commit c67af90

Please sign in to comment.