(self, indent)
| 300 | |
| 301 | |
| 302 | def _tensor_str(self, indent): |
| 303 | if self.numel() == 0: |
| 304 | return "[]" |
| 305 | |
| 306 | if self.has_names(): |
| 307 | # There are two main codepaths (possibly more) that tensor printing goes through: |
| 308 | # - tensor data can fit comfortably on screen |
| 309 | # - tensor data needs to be summarized |
| 310 | # Some of the codepaths don't fully support named tensors, so we send in |
| 311 | # an unnamed tensor to the formatting code as a workaround. |
| 312 | self = self.rename(None) |
| 313 | |
| 314 | summarize = self.numel() > PRINT_OPTS.threshold |
| 315 | |
| 316 | if self._is_zerotensor(): |
| 317 | self = self.clone() |
| 318 | |
| 319 | # handle the negative bit |
| 320 | if self.is_neg(): |
| 321 | self = self.resolve_neg() |
| 322 | |
| 323 | if self.dtype in [ |
| 324 | torch.float16, |
| 325 | torch.bfloat16, |
| 326 | torch.float8_e5m2, |
| 327 | torch.float8_e5m2fnuz, |
| 328 | torch.float8_e4m3fn, |
| 329 | torch.float8_e4m3fnuz, |
| 330 | ]: |
| 331 | self = self.float() |
| 332 | |
| 333 | if self.dtype is torch.complex32: |
| 334 | self = self.cfloat() |
| 335 | |
| 336 | if self.dtype.is_complex: |
| 337 | # handle the conjugate bit |
| 338 | self = self.resolve_conj() |
| 339 | real_formatter = _Formatter( |
| 340 | get_summarized_data(self.real) if summarize else self.real |
| 341 | ) |
| 342 | imag_formatter = _Formatter( |
| 343 | get_summarized_data(self.imag) if summarize else self.imag |
| 344 | ) |
| 345 | return _tensor_str_with_formatter( |
| 346 | self, indent, summarize, real_formatter, imag_formatter |
| 347 | ) |
| 348 | else: |
| 349 | formatter = _Formatter(get_summarized_data(self) if summarize else self) |
| 350 | return _tensor_str_with_formatter(self, indent, summarize, formatter) |
| 351 | |
| 352 | |
| 353 | def _add_suffixes(tensor_str, suffixes, indent, force_newline): |
no test coverage detected
searching dependent graphs…