| 39 | Client::~Client() = default; |
| 40 | |
| 41 | StatusOr<Literal> Client::Transfer(const GlobalData& data, |
| 42 | const Shape* shape_with_layout) { |
| 43 | TransferToClientRequest request; |
| 44 | *request.mutable_data() = data.handle(); |
| 45 | if (shape_with_layout != nullptr) { |
| 46 | *request.mutable_shape_with_layout() = shape_with_layout->ToProto(); |
| 47 | } |
| 48 | TransferToClientResponse response; |
| 49 | |
| 50 | VLOG(1) << "making transfer request"; |
| 51 | VLOG(3) << "TransferToClientRequest: {" << request.DebugString() << "}"; |
| 52 | Status s = stub_->TransferToClient(&request, &response); |
| 53 | VLOG(1) << "done with request"; |
| 54 | |
| 55 | if (!s.ok()) { |
| 56 | return s; |
| 57 | } |
| 58 | VLOG(3) << "TransferToClientResponse: {" << response.DebugString() << "}"; |
| 59 | |
| 60 | if (!response.has_literal()) { |
| 61 | return FailedPrecondition( |
| 62 | "server provided response without a literal in " |
| 63 | "TransferToClient request"); |
| 64 | } |
| 65 | return Literal::CreateFromProto(*response.mutable_literal()); |
| 66 | } |
| 67 | |
| 68 | StatusOr<std::unique_ptr<GlobalData>> Client::TransferToServer( |
| 69 | const LiteralSlice& literal, const DeviceHandle* device_handle) { |