Set ndarray value
(self, in_slice, value)
| 76 | """ |
| 77 | |
| 78 | def __setitem__(self, in_slice, value): |
| 79 | """Set ndarray value""" |
| 80 | if ( |
| 81 | not isinstance(in_slice, slice) |
| 82 | or in_slice.start is not None |
| 83 | or in_slice.stop is not None |
| 84 | ): |
| 85 | raise ValueError("Array only support set from numpy array") |
| 86 | if isinstance(value, Tensor): |
| 87 | if not value.same_as(self): |
| 88 | value.copyto(self) |
| 89 | elif isinstance(value, np.ndarray | np.generic): |
| 90 | self.copyfrom(value) |
| 91 | else: |
| 92 | raise TypeError(f"type {type(value)} not supported") |
| 93 | |
| 94 | def copyfrom(self, source_array): |
| 95 | """Perform a synchronous copy from the array. |