Copies tensor to dest device.
(self, ctx=None, device_name=None)
| 1011 | return new_tensor |
| 1012 | |
| 1013 | def _copy(self, ctx=None, device_name=None): |
| 1014 | """Copies tensor to dest device.""" |
| 1015 | new_tensor = self._copy_nograd(ctx, device_name) |
| 1016 | # Record the copy on tape and define backprop copy as well. |
| 1017 | if context.executing_eagerly(): |
| 1018 | self_device = self.device |
| 1019 | |
| 1020 | def grad_fun(dresult): |
| 1021 | return [ |
| 1022 | dresult._copy(device_name=self_device) |
| 1023 | if hasattr(dresult, "_copy") else dresult |
| 1024 | ] |
| 1025 | |
| 1026 | tape.record_operation("_copy", [new_tensor], [self], grad_fun) |
| 1027 | return new_tensor |
| 1028 | # pylint: enable=protected-access |
| 1029 | |
| 1030 | @property |
| 1031 | def shape(self): |