Skip to content

Commit ad6c014

Browse files
committed
clean up codes
1 parent 268e9dc commit ad6c014

File tree

11 files changed

+12
-128
lines changed

11 files changed

+12
-128
lines changed

paddle/fluid/framework/details/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ cc_library(op_handle_base SRCS op_handle_base.cc DEPS var_handle device_context
33
cc_library(scale_loss_grad_op_handle SRCS scale_loss_grad_op_handle.cc DEPS op_handle_base scope lod_tensor ddim memory)
44
cc_library(fetch_op_handle SRCS fetch_op_handle.cc DEPS op_handle_base scope lod_tensor ddim memory)
55
cc_library(computation_op_handle SRCS computation_op_handle.cc DEPS framework_proto scope place operator op_registry)
6-
cc_library(send_op_handle SRCS send_op_handle.cc DEPS framework_proto scope place operator op_registry)
76
cc_library(rpc_op_handle SRCS rpc_op_handle.cc DEPS framework_proto scope place operator op_registry)
87

98
cc_library(ssa_graph SRCS ssa_graph.cc DEPS var_handle op_handle_base)
@@ -27,7 +26,7 @@ endif()
2726
cc_library(gather_op_handle SRCS gather_op_handle.cc DEPS op_handle_base scope ddim memory variable_visitor)
2827

2928
cc_library(multi_devices_graph_builder SRCS multi_devices_graph_builder.cc DEPS ssa_graph_builder computation_op_handle
30-
scale_loss_grad_op_handle send_op_handle rpc_op_handle ${multi_devices_graph_builder_deps} reduce_op_handle broadcast_op_handle)
29+
scale_loss_grad_op_handle rpc_op_handle ${multi_devices_graph_builder_deps} reduce_op_handle broadcast_op_handle)
3130

3231
cc_library(ssa_graph_executor SRCS ssa_graph_executor.cc DEPS ssa_graph framework_proto)
3332
cc_library(threaded_ssa_graph_executor SRCS threaded_ssa_graph_executor.cc DEPS fetch_op_handle ssa_graph_executor scope

paddle/fluid/framework/details/multi_devices_graph_builder.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "paddle/fluid/framework/details/reduce_op_handle.h"
2020
#include "paddle/fluid/framework/details/rpc_op_handle.h"
2121
#include "paddle/fluid/framework/details/scale_loss_grad_op_handle.h"
22-
#include "paddle/fluid/framework/details/send_op_handle.h"
2322
#include "paddle/fluid/framework/op_info.h"
2423
#include "paddle/fluid/framework/scope.h"
2524

@@ -141,7 +140,6 @@ bool MultiDevSSAGraphBuilder::IsDistTrainOp(
141140

142141
return checker(op.OutputArgumentNames(), send_vars) ||
143142
checker(op.InputArgumentNames(), recv_vars);
144-
return false;
145143
}
146144

147145
bool MultiDevSSAGraphBuilder::IsRPCOp(const OpDesc &op) const {
@@ -471,17 +469,16 @@ void MultiDevSSAGraphBuilder::CreateRPCOp(SSAGraph *result,
471469
ConnectOp(result, result->ops_.back().get(), "send_barrier");
472470
} else if (op.Type() == "fetch_barrier") {
473471
ConnectOp(result, result->ops_.back().get(), "recv");
474-
} else if (op.Type() == "send" || op.Type() == "send_vars") {
472+
} else if (op.Type() == "send_vars") {
475473
// do nothing
476474
} else {
477475
PADDLE_THROW(
478-
"rpc op should be in [send,"
476+
"rpc op should be in ["
479477
"send_vars, send_barrier. recv, fetch_barrier]");
480478
}
481479

482-
// FIXME(wuyi): send op always copy from GPU 0
483-
// Create inputs for output on original place and no ssa output
484-
// is created for send op.
480+
// TODO(Yancey1989): schedule rpc op on different place may
481+
// increate throughput
485482
CreateOpHandleIOs(result, op, 0);
486483
}
487484

paddle/fluid/framework/details/rpc_op_handle.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void RPCOpHandle::RunImpl() {
3131
// Wait input done
3232
for (auto *in : inputs_) {
3333
auto &p = static_cast<VarHandle *>(in)->place_;
34+
// FIXME(Yancey1989): need a better solution instead of use DebugString()
3435
if (in->DebugString() == "dummy") { // HACK
3536
continue;
3637
}

paddle/fluid/framework/details/send_op_handle.cc

Lines changed: 0 additions & 49 deletions
This file was deleted.

paddle/fluid/framework/details/send_op_handle.h

Lines changed: 0 additions & 51 deletions
This file was deleted.

paddle/fluid/framework/variable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class Variable {
3939

4040
template <typename T>
4141
T* GetMutable() {
42+
// TODO(Yancey1989): need to make Variable completely thread-safe.
4243
std::unique_lock<std::mutex> lock(mutex_);
4344
if (!IsType<T>()) {
4445
holder_.reset(new PlaceholderImpl<T>(new T()));

paddle/fluid/inference/analysis/device.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ See the License for the specific language governing permissions and
1313
limitations under the License. */
1414
#pragma once
1515

16-
#pragma once
17-
1816
namespace paddle {
1917
namespace inference {
2018
namespace analysis {

paddle/fluid/operators/detail/grpc_client.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ bool RPCClient::Proceed() {
249249
return true;
250250
}
251251
std::shared_ptr<grpc::Channel> RPCClient::GetChannel(const std::string& ep) {
252+
// TODO(Yancey1989): make grpc client completely thread-safe
252253
std::unique_lock<std::mutex> lock(mutex_);
253254
auto it = channels_.find(ep);
254255
if (it != channels_.end()) {

paddle/fluid/operators/recv_op.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class RecvOp : public framework::OperatorBase {
3838
auto outs = Outputs("Out");
3939
std::vector<std::string> epmap = Attr<std::vector<std::string>>("epmap");
4040
auto client_var_name = Output("RPCClient");
41-
int sync_recv = Attr<int>("sync_recv");
41+
int sync_mode = Attr<int>("sync_mode");
4242

4343
platform::DeviceContextPool& pool = platform::DeviceContextPool::Instance();
4444
auto& ctx = *pool.Get(place);
@@ -55,7 +55,7 @@ class RecvOp : public framework::OperatorBase {
5555
VLOG(3) << "getting " << outs[i] << " from " << epmap[i];
5656
rpc_client->AsyncGetVariable(epmap[i], ctx, scope, outs[i]);
5757
}
58-
if (sync_recv) {
58+
if (sync_mode) {
5959
PADDLE_ENFORCE(rpc_client->Wait());
6060
}
6161
}
@@ -78,7 +78,7 @@ This operator can get variables from server side.
7878
"Server endpoints in the order of input "
7979
"variables for mapping")
8080
.SetDefault({});
81-
AddAttr<int>("sync_recv",
81+
AddAttr<int>("sync_mode",
8282
"(int, default 0)"
8383
"sync recv or async recv.")
8484
.SetDefault(0);

python/paddle/fluid/transpiler/distribute_transpiler.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -360,19 +360,6 @@ def transpile(self,
360360
ps_dispatcher.reset()
361361
eplist = ps_dispatcher.dispatch(recv_vars)
362362

363-
#program.global_block().append_op(
364-
# type="recv",
365-
# inputs={},
366-
# outputs={"Out": recv_vars,
367-
# "RPCClient": rpc_client_var},
368-
# attrs={"epmap": eplist})
369-
370-
#program.global_block().append_op(
371-
# type="fetch_barrier",
372-
# inputs={},
373-
# outputs={"RPCClient": rpc_client_var},
374-
# attrs={"endpoints": pserver_endpoints})
375-
376363
for i, ep in enumerate(eplist):
377364
self.param_grad_ep_mapping[ep]["params"].append(recv_vars[i])
378365
self.param_grad_ep_mapping[ep]["grads"].append(send_vars[i])

0 commit comments

Comments
 (0)