Skip to content

Commit 011c909

Browse files
committed
rename tensorparser
1 parent 0d36059 commit 011c909

File tree

9 files changed

+30
-28
lines changed

9 files changed

+30
-28
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
if(WITH_DISTRIBUTE)
22
grpc_library(sendrecvop_grpc SRCS bytebuffer_stream.cc sendrecvop_utils.cc grpc_client.cc
3-
grpc_server.cc tensor_parser.cc PROTO send_recv.proto DEPS lod_tensor selected_rows)
3+
grpc_server.cc variable_response.cc PROTO send_recv.proto DEPS lod_tensor selected_rows)
44
set(DISTRIBUTE_COMPILE_FLAGS "-Wno-non-virtual-dtor -Wno-error=non-virtual-dtor -Wno-error=delete-non-virtual-dtor")
55
set_source_files_properties(test_serde.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
6-
cc_test(serde_test SRCS test_serde.cc tensor_parser.cc DEPS grpc++_unsecure grpc_unsecure gpr
6+
cc_test(serde_test SRCS test_serde.cc variable_response.cc DEPS grpc++_unsecure grpc_unsecure gpr
77
cares zlib protobuf sendrecvop_grpc)
88
endif()

paddle/fluid/operators/detail/grpc_server.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class RequestSend final : public RequestBase {
5757
framework::Scope* scope, ReceivedQueue* queue,
5858
const platform::DeviceContext* dev_ctx)
5959
: RequestBase(service, cq, dev_ctx), queue_(queue), responder_(&ctx_) {
60-
request_.reset(new TensorResponse(scope, dev_ctx_));
60+
request_.reset(new VariableResponse(scope, dev_ctx_));
6161
int method_id = static_cast<int>(detail::GrpcMethod::kSendVariable);
6262
service_->RequestAsyncUnary(method_id, &ctx_, request_.get(), &responder_,
6363
cq_, cq_, this);
@@ -76,7 +76,7 @@ class RequestSend final : public RequestBase {
7676
}
7777

7878
protected:
79-
std::shared_ptr<TensorResponse> request_;
79+
std::shared_ptr<VariableResponse> request_;
8080
ReceivedQueue* queue_;
8181
ServerAsyncResponseWriter<sendrecv::VoidMessage> responder_;
8282
};

paddle/fluid/operators/detail/grpc_server.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ namespace paddle {
3535
namespace operators {
3636
namespace detail {
3737

38-
typedef std::pair<std::string, std::shared_ptr<TensorResponse>> ReceivedMessage;
38+
typedef std::pair<std::string, std::shared_ptr<VariableResponse>>
39+
ReceivedMessage;
3940
typedef SimpleBlockQueue<ReceivedMessage> ReceivedQueue;
4041

4142
typedef std::pair<std::string, sendrecv::VariableMessage> MessageWithName;

paddle/fluid/operators/detail/grpc_service.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <grpc++/impl/codegen/stub_options.h>
2424
#include <grpc++/impl/codegen/sync_stream.h>
2525
#include <grpc++/support/byte_buffer.h>
26-
#include "paddle/fluid/operators/detail/tensor_parser.h"
26+
#include "paddle/fluid/operators/detail/variable_response.h"
2727

2828
// NOTE: This method was originally created by tensorflow
2929
// (https://github.com/tensorflow/tensorflow/) we borrow this
@@ -37,18 +37,19 @@ class RpcService;
3737
class ServerCompletionQueue;
3838
class ServerContext;
3939

40-
// Support parsing/unparsing of tensorflow::TensorResponse.
41-
// Wire-format is identical to RecvTensorResponse.
40+
// Support parsing/unparsing of tensorflow::VariableResponse.
41+
// Wire-format is identical to RecvVariableResponse.
4242
template <>
43-
class SerializationTraits<paddle::operators::detail::TensorResponse> {
43+
class SerializationTraits<paddle::operators::detail::VariableResponse> {
4444
public:
45-
static Status Serialize(const paddle::operators::detail::TensorResponse& msg,
46-
grpc_byte_buffer** bp, bool* own_buffer) {
45+
static Status Serialize(
46+
const paddle::operators::detail::VariableResponse& msg,
47+
grpc_byte_buffer** bp, bool* own_buffer) {
4748
PADDLE_ENFORCE(false, "SerializationTraits::Serialize not implemented!");
4849
return Status();
4950
}
5051
static Status Deserialize(grpc_byte_buffer* buffer,
51-
paddle::operators::detail::TensorResponse* msg,
52+
paddle::operators::detail::VariableResponse* msg,
5253
int max_message_size = INT_MAX) {
5354
if (buffer == nullptr) {
5455
return Status(StatusCode::INTERNAL, "No payload");
@@ -59,7 +60,7 @@ class SerializationTraits<paddle::operators::detail::TensorResponse> {
5960
paddle::operators::detail::GrpcByteSource source(buffer);
6061
int ret = msg->Parse(&source);
6162
if (ret != 0) {
62-
result = Status(StatusCode::INTERNAL, "TensorResponse parse error");
63+
result = Status(StatusCode::INTERNAL, "VariableResponse parse error");
6364
}
6465
}
6566
g_core_codegen_interface->grpc_byte_buffer_destroy(buffer);

paddle/fluid/operators/detail/send_recv.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum VarType {
3434

3535
// NOTICE(gongwb):don't modify this proto if you are not
3636
// not familar with how we serialize in sendrecvop_utils.h
37-
// and deserilize it in tensor_parser.h.
37+
// and deserilize it in variable_response.h.
3838
message VariableMessage {
3939
enum Type {
4040
// Pod Types

paddle/fluid/operators/detail/sendrecvop_utils.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License. */
2020
#include "paddle/fluid/framework/data_type.h"
2121
#include "paddle/fluid/operators/detail/bytebuffer_stream.h"
2222
#include "paddle/fluid/operators/detail/proto_encoder_helper.h"
23-
#include "paddle/fluid/operators/detail/tensor_parser.h"
23+
#include "paddle/fluid/operators/detail/variable_response.h"
2424

2525
namespace paddle {
2626
namespace operators {
@@ -181,7 +181,7 @@ void DeserializeFromByteBuffer(const ::grpc::ByteBuffer& msg,
181181
const platform::DeviceContext& ctx,
182182
const framework::Scope* scope,
183183
framework::Variable*& var) {
184-
operators::detail::TensorResponse resp(scope, &ctx);
184+
operators::detail::VariableResponse resp(scope, &ctx);
185185
PADDLE_ENFORCE(resp.Parse(msg) == 0, "parse bytebuffer to tensor error!");
186186
var = resp.GetVar();
187187
}

paddle/fluid/operators/detail/test_serde.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ limitations under the License. */
2222
#include "paddle/fluid/framework/tensor_util.h"
2323
#include "paddle/fluid/framework/variable.h"
2424
#include "paddle/fluid/operators/detail/sendrecvop_utils.h"
25-
#include "paddle/fluid/operators/detail/tensor_parser.h"
25+
#include "paddle/fluid/operators/detail/variable_response.h"
2626
#include "paddle/fluid/operators/math/math_function.h"
2727
#include "paddle/fluid/platform/place.h"
2828
#include "paddle/fluid/string/printf.h"

paddle/fluid/operators/detail/tensor_parser.cc renamed to paddle/fluid/operators/detail/variable_response.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "tensor_parser.h"
15+
#include "paddle/fluid/operators/detail/variable_response.h"
1616
#include <string.h>
1717
#include "paddle/fluid/operators/detail/send_recv.pb.h"
18-
#include "sendrecvop_utils.h"
18+
#include "paddle/fluid/operators/detail/sendrecvop_utils.h"
1919

2020
namespace paddle {
2121
namespace operators {
@@ -94,7 +94,7 @@ bool ReadRaw(::google::protobuf::io::CodedInputStream* input,
9494
return true;
9595
}
9696

97-
bool TensorResponse::CopyLodTensorData(
97+
bool VariableResponse::CopyLodTensorData(
9898
::google::protobuf::io::CodedInputStream* input,
9999
const platform::DeviceContext& ctx, framework::DDim& dims, int length) {
100100
auto var = scope_->FindVar(meta_.varname());
@@ -130,7 +130,7 @@ inline framework::DDim GetDims(
130130
return framework::make_ddim(vecdims);
131131
}
132132

133-
bool TensorResponse::CopySelectRowsTensorData(
133+
bool VariableResponse::CopySelectRowsTensorData(
134134
::google::protobuf::io::CodedInputStream* input,
135135
const platform::DeviceContext& ctx, framework::DDim& dims, int length) {
136136
auto var = scope_->FindVar(meta_.varname());
@@ -148,7 +148,7 @@ bool TensorResponse::CopySelectRowsTensorData(
148148
return true;
149149
}
150150

151-
bool TensorResponse::CopySelectRowsData(
151+
bool VariableResponse::CopySelectRowsData(
152152
::google::protobuf::io::CodedInputStream* input,
153153
const platform::DeviceContext& ctx, int length) {
154154
auto var = scope_->FindVar(meta_.varname());
@@ -211,15 +211,15 @@ bool ParseLodData(::google::protobuf::io::CodedInputStream* input,
211211
return true;
212212
}
213213

214-
int TensorResponse::Parse(const ::grpc::ByteBuffer& byte_buffer) {
214+
int VariableResponse::Parse(const ::grpc::ByteBuffer& byte_buffer) {
215215
GrpcByteBufferSource source;
216216
source.Init(byte_buffer);
217217
GrpcByteBufferSourceWrapper r(&source);
218218

219219
return Parse(&r);
220220
}
221221

222-
int TensorResponse::Parse(Source* source) {
222+
int VariableResponse::Parse(Source* source) {
223223
::google::protobuf::io::ZeroCopyInputStream* input_stream =
224224
source->contents();
225225
::google::protobuf::io::CodedInputStream input(input_stream);

paddle/fluid/operators/detail/tensor_parser.h renamed to paddle/fluid/operators/detail/variable_response.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ namespace paddle {
3232
namespace operators {
3333
namespace detail {
3434

35-
class TensorResponse {
35+
class VariableResponse {
3636
public:
37-
TensorResponse(const framework::Scope* scope,
38-
const platform::DeviceContext* dev_ctx)
37+
VariableResponse(const framework::Scope* scope,
38+
const platform::DeviceContext* dev_ctx)
3939
: scope_(scope), dev_ctx_(dev_ctx){};
4040

41-
virtual ~TensorResponse(){};
41+
virtual ~VariableResponse(){};
4242

4343
// return:
4444
// 0:ok.

0 commit comments

Comments
 (0)