[TensorPipe/RPC] Serialize and deserialize message (#36197)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/36197

Create APIs to convert between rpc::message and tensorpipe::message
1. tensorpipeSerialize() - converts rpc::message to tensorpipe::message without memory copy (tensors).
2. tensorpipeAllocateMessage - allocates rpc::message based on received tensorpipe descriptor to prepare memory-copy-free receiving.

Test Plan: buck test caffe2/test/cpp/rpc:test_tensorpipe_serialization

Reviewed By: lw

Differential Revision: D20084125

fbshipit-source-id: ffbc310f93443e50261aed752be0fe176610dd2a
This commit is contained in:
Hongyi Jia
2020-05-05 05:43:25 -07:00
committed by Facebook GitHub Bot
parent 7fa897eac0
commit 3411ec6e32
4 changed files with 271 additions and 1 deletions

View File

@ -2,10 +2,14 @@ set(TORCH_RPC_TEST_DIR "${TORCH_ROOT}/test/cpp/rpc")
set(TORCH_RPC_TEST_SOURCES
${TORCH_ROOT}/test/cpp/common/main.cpp
${TORCH_RPC_TEST_DIR}/test_wire_serialization.cpp
${TORCH_RPC_TEST_DIR}/test_tensorpipe_serialization.cpp
)
add_executable(test_cpp_rpc ${TORCH_RPC_TEST_SOURCES})
target_include_directories(test_cpp_rpc PRIVATE ${ATen_CPU_INCLUDE})
target_include_directories(
test_cpp_rpc PRIVATE
${ATen_CPU_INCLUDE}
${TORCH_ROOT}/third_party/tensorpipe)
target_link_libraries(test_cpp_rpc PRIVATE torch gtest)
if(USE_CUDA)