| 272 | } |
| 273 | |
| 274 | Maybe<Tensor> MakeTensorFromOtherTensor(const std::shared_ptr<Tensor>& other, |
| 275 | const bool pin_memory) { |
| 276 | if (other->is_local()) { |
| 277 | const Symbol<Device>& device = JUST(other->device()); |
| 278 | return functional::Copy(other, device->type(), device->device_id(), pin_memory); |
| 279 | } else { |
| 280 | const Symbol<NdSbp>& nd_sbp = JUST(other->nd_sbp()); |
| 281 | const std::vector<Symbol<SbpParallel>>& sbp_tuple = *JUST(GetSbpList(nd_sbp)); |
| 282 | std::vector<Symbol<SbpParallel>> grad_sbp_tuple; |
| 283 | // TODO:(zhaoluyang) global case support pin_memory |
| 284 | return functional::ToGlobal(other, JUST(other->parallel_desc()), sbp_tuple, grad_sbp_tuple, |
| 285 | /* check_meta */ false, /*copy=*/false); |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | Maybe<Tensor> MakeTensorFromOtherTensor(const std::shared_ptr<Tensor>& other, |
| 290 | const Optional<Symbol<DType>>& dtype, |
no test coverage detected