| 243 | return state |
| 244 | |
| 245 | def __setstate__(self, state): |
| 246 | # for compatibility with old version not using fastcore |
| 247 | if "data" in state: |
| 248 | data = state.pop("data") |
| 249 | device = state.pop("device") |
| 250 | dtype = state.pop("dtype") |
| 251 | self._reset(Tensor(data, dtype=dtype, device=device)) |
| 252 | |
| 253 | # quantize related state for deepcopy |
| 254 | if "qdict" in state: |
| 255 | qparams = state.pop("qdict") |
| 256 | logger.warning( |
| 257 | "Tensor's 'qdict' state is depreciated. Use 'qparams' instead" |
| 258 | ) |
| 259 | elif "qparams" in state: |
| 260 | qparams = state.pop("qparams") |
| 261 | else: |
| 262 | qparams = None |
| 263 | self._qparams = qparams |
| 264 | |
| 265 | def __dlpack__(self, stream=None): |
| 266 | if stream is not None and not isinstance(stream, int): |