| 123 | } |
| 124 | |
| 125 | static StorageView copy_variable(const StorageView& variable, |
| 126 | const Device device, const int device_index) { |
| 127 | if (variable.is_scalar() || (variable.device() == Device::CPU && device == Device::CPU)) |
| 128 | return variable; |
| 129 | |
| 130 | StorageView copy; |
| 131 | |
| 132 | if (variable.device() != Device::CPU) { |
| 133 | ScopedDeviceSetter scoped_device_setter(variable.device(), variable.device_index()); |
| 134 | copy = variable.to(Device::CPU); |
| 135 | } |
| 136 | |
| 137 | if (device != Device::CPU) { |
| 138 | ScopedDeviceSetter scoped_device_setter(device, device_index); |
| 139 | if (copy) |
| 140 | copy = copy.to(device); |
| 141 | else |
| 142 | copy = variable.to(device); |
| 143 | } |
| 144 | |
| 145 | return copy; |
| 146 | } |
| 147 | |
| 148 | |
| 149 | std::unique_ptr<SequenceToSequenceReplica> Model::as_sequence_to_sequence() const { |
no test coverage detected