Copy array to target Parameters ---------- target : Tensor The target array to be copied, must have same shape as this array. mem_scope : Optional[str] The memory scope of the array.
(self, target, mem_scope=None)
| 227 | return np_arr |
| 228 | |
| 229 | def copyto(self, target, mem_scope=None): |
| 230 | """Copy array to target |
| 231 | |
| 232 | Parameters |
| 233 | ---------- |
| 234 | target : Tensor |
| 235 | The target array to be copied, must have same shape as this array. |
| 236 | |
| 237 | mem_scope : Optional[str] |
| 238 | The memory scope of the array. |
| 239 | """ |
| 240 | if isinstance(target, Tensor): |
| 241 | return self._copyto(target) |
| 242 | if isinstance(target, tvm_ffi.core.Device): |
| 243 | res = empty(self.shape, self.dtype, target, mem_scope) |
| 244 | return self._copyto(res) |
| 245 | raise ValueError(f"Unsupported target type {type(target)}") |
| 246 | |
| 247 | def _copyto(self, target_nd): |
| 248 | """Internal function that implements copy to target ndarray.""" |