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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion paddle/fluid/distributed/fleet_executor/carrier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ USE_INTERCEPTOR(Compute);

void Carrier::Init(
const std::unordered_map<int64_t, TaskNode*>& interceptor_id_to_node,
framework::Scope* minibatch_scope,
framework::Scope* root_scope, framework::Scope* minibatch_scope,
const std::vector<framework::Scope*>& microbatch_scopes,
const platform::Place& place) {
PADDLE_ENFORCE_EQ(is_init_, false, platform::errors::AlreadyExists(
Expand All @@ -35,6 +35,8 @@ void Carrier::Init(
minibatch_scope_ = minibatch_scope;
microbatch_scopes_ = microbatch_scopes;
place_ = place;
root_scope_ = root_scope;
dev_ctx_ = platform::DeviceContextPool::Instance().Get(place_);
CreateInterceptors();
is_init_ = true;
}
Expand Down Expand Up @@ -105,6 +107,7 @@ void Carrier::Start() {
}
std::unique_lock<std::mutex> lock(running_mutex_);
cond_var_.wait(lock);
dev_ctx_->Wait();
}

std::condition_variable& Carrier::GetCondVar() { return cond_var_; }
Expand Down Expand Up @@ -164,6 +167,10 @@ void Carrier::CreateInterceptors() {
// TODO(wangxi): use node_type to select different Interceptor
auto interceptor =
std::make_unique<Interceptor>(interceptor_id, task_node);
interceptor->SetPlace(place_);
interceptor->SetMiniBatchScope(minibatch_scope_);
interceptor->SetMicroBatchScope(microbatch_scopes_);
interceptor->SetRootScope(root_scope_);
SetInterceptor(interceptor_id, std::move(interceptor));
VLOG(3) << "Create Interceptor with interceptor id: " << interceptor_id
<< ".";
Expand Down
5 changes: 4 additions & 1 deletion paddle/fluid/distributed/fleet_executor/carrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "paddle/fluid/distributed/fleet_executor/interceptor.h"
#include "paddle/fluid/distributed/fleet_executor/interceptor_message.pb.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/errors.h"
#include "paddle/fluid/platform/macros.h"
Expand All @@ -48,7 +49,7 @@ class Carrier final {

void Init(
const std::unordered_map<int64_t, TaskNode*>& interceptor_id_to_node,
framework::Scope* minibatch_scope,
framework::Scope* root_scope, framework::Scope* minibatch_scope,
const std::vector<framework::Scope*>& microbatch_scopes,
const platform::Place& place);

Expand Down Expand Up @@ -98,8 +99,10 @@ class Carrier final {
std::mutex running_mutex_;
std::condition_variable cond_var_;
std::vector<framework::Scope*> microbatch_scopes_;
framework::Scope* root_scope_;
framework::Scope* minibatch_scope_;
paddle::platform::Place place_;
paddle::platform::DeviceContext* dev_ctx_ = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{nullptr}

};

} // namespace distributed
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/distributed/fleet_executor/fleet_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void FleetExecutor::Init(const framework::ProgramDesc& program_desc,
void FleetExecutor::InitCarrier() {
Carrier& carrier_instance = Carrier::Instance();
if (!carrier_instance.IsInit()) {
carrier_instance.Init(runtime_graph_->intercepter_id_to_node(),
carrier_instance.Init(runtime_graph_->intercepter_id_to_node(), root_scope_,
minibatch_scope_, microbatch_scopes_, place_);
}
}
Expand Down