MCPcopy Create free account
hub / github.com/pytorch/pytorch / tensor

Method tensor

torch/_dynamo/debug_utils.py:668–692  ·  view source on GitHub ↗
(self, name, t)

Source from the content-addressed store, hash-verified

666 return v
667
668 def tensor(self, name, t) -> None:
669 storage = self.storage(
670 t.untyped_storage(), dtype_hint=t.dtype, device_hint=t.device
671 )
672 args = []
673 # NB: this is positional, must come first
674 if _stride_or_default(None, shape=t.shape) != t.stride():
675 args.append(str(tuple(t.stride())))
676 if _dtype_or_default(None) != t.dtype:
677 args.append(f"dtype={t.dtype!r}")
678 if _storage_offset_or_default(None) != t.storage_offset():
679 args.append(f"storage_offset={t.storage_offset()!r}")
680 tensor_metadata = torch._utils.get_tensor_metadata(t)
681 if tensor_metadata:
682 args.extend(f"{k}={v!r}" for k, v in tensor_metadata.items())
683 if _requires_grad_or_default(None) != t.requires_grad:
684 args.append(f"requires_grad={t.requires_grad!r}")
685 is_leaf = torch._subclasses.meta_utils.safe_is_leaf(t)
686 if _is_leaf_or_default(None) != is_leaf:
687 args.append(f"is_leaf={is_leaf!r}")
688 self._lines.append(
689 "reader.tensor("
690 + ", ".join([storage, str(tuple(t.shape)), *args])
691 + f") # {name}"
692 )
693
694 # TODO: this doesn't actually symint atm
695 def symint(self, name, val) -> None:

Callers 3

testMethod · 0.95

Calls 8

storageMethod · 0.95
_stride_or_defaultFunction · 0.85
storage_offsetMethod · 0.80
strideMethod · 0.45
appendMethod · 0.45
extendMethod · 0.45
itemsMethod · 0.45
joinMethod · 0.45

Tested by 1

testMethod · 0.76