| 3085 | namespace { |
| 3086 | |
| 3087 | Maybe<Tensor> LocalTensorTo(const std::shared_ptr<Tensor>& x, Symbol<Device> device, |
| 3088 | const Symbol<DType>& dtype, const bool& copy) { |
| 3089 | std::shared_ptr<Tensor> tensor = x; |
| 3090 | if (device != JUST(x->device())) { tensor = JUST(Copy(tensor, device, /*pin_memory=*/false)); } |
| 3091 | if (dtype != x->dtype()) { tensor = JUST(Cast(tensor, dtype, /*pin_memory=*/false)); } |
| 3092 | if (copy && tensor == x) { tensor = JUST(Copy(tensor, device, /*pin_memory=*/false)); } |
| 3093 | return tensor; |
| 3094 | } |
| 3095 | |
| 3096 | Maybe<Tensor> GlobalTensorTo(const std::shared_ptr<Tensor>& x, const std::string& device_type, |
| 3097 | const Symbol<DType>& dtype, const bool& copy) { |
no test coverage detected