| 1138 | } |
| 1139 | |
| 1140 | void RdmaTensorResponse::Clone(const Tensor& in, const TensorProto& proto, |
| 1141 | bool is_dead) { |
| 1142 | // Clone the data to be sent later. For simplicity, we clone the tensor's |
| 1143 | // data even if it is already a copy. Performance is less of a concern here |
| 1144 | // since the meta-data hardly ever changes. The reason we create a copy, is |
| 1145 | // that some tensors share their buffer between different step-ids, so the |
| 1146 | // tensor content may change before re-request was completed. |
| 1147 | bool can_memcpy = DataTypeCanUseMemcpy(in.dtype()); |
| 1148 | if (can_memcpy && (in.TotalBytes() > 0)) { |
| 1149 | AllocatorAttributes host_alloc_attrs; |
| 1150 | host_alloc_attrs.set_nic_compatible(true); |
| 1151 | host_alloc_attrs.set_on_host(true); |
| 1152 | Allocator* allocator = src_dev_->GetAllocator(host_alloc_attrs); |
| 1153 | tensor_ = new Tensor(allocator, in.dtype(), in.shape()); |
| 1154 | memcpy(DMAHelper::base(tensor_), DMAHelper::base(&in), in.TotalBytes()); |
| 1155 | } else { |
| 1156 | tensor_ = new Tensor(in.dtype(), in.shape()); |
| 1157 | } |
| 1158 | if (!can_memcpy) { |
| 1159 | proto_ = new TensorProto(proto); |
| 1160 | } |
| 1161 | is_dead_ = is_dead; |
| 1162 | } |
| 1163 | |
| 1164 | void RdmaTensorResponse::SendMetaData(const Tensor& in, |
| 1165 | const TensorProto& proto, bool is_dead) { |
nothing calls this directly
no test coverage detected