Skip to content

Commit

Permalink
Calls tensor.untyped_storage instead of tesnor.storage (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangkuiyi authored Jul 25, 2024
1 parent 212e595 commit cf92544
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pytorch_memlab/mem_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_tensor_stat(tensor: torch.Tensor) -> List[Tuple[str, int, int, int]]:

numel = tensor.numel()
element_size = tensor.element_size()
fact_numel = tensor.storage().size()
fact_numel = tensor.untyped_storage().size()
fact_memory_size = fact_numel * element_size
# since pytorch allocate at least 512 Bytes for any tensor, round
# up to a multiple of 512
Expand All @@ -101,7 +101,7 @@ def get_tensor_stat(tensor: torch.Tensor) -> List[Tuple[str, int, int, int]]:

# tensor.storage should be the actual object related to memory
# allocation
data_ptr = tensor.storage().data_ptr()
data_ptr = tensor.untyped_storage().data_ptr()
if data_ptr in visited_data:
name = '{}(->{})'.format(
name,
Expand Down

0 comments on commit cf92544

Please sign in to comment.