Skip to content

Commit

Permalink
added check to avoid div 0 errors in cache report (pytorch#1645)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#1645

as in title

Differential Revision: D44096435

fbshipit-source-id: c5937aa78b3b16fbd86b2383fe51b93845505135
  • Loading branch information
Xiao Sun authored and facebook-github-bot committed Mar 17, 2023
1 parent c7cddec commit 2407be6
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions fbgemm_gpu/fbgemm_gpu/split_table_batched_embeddings_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,10 +979,11 @@ def print_uvm_cache_stats(self) -> None:
f"N_conflict_unique_misses: {uvm_cache_stats[4]}\n"
f"N_conflict_misses: {uvm_cache_stats[5]}\n"
)
logging.info(
f"unique indices / requested indices: {uvm_cache_stats[2]/uvm_cache_stats[1]}\n"
f"unique misses / requested indices: {uvm_cache_stats[3]/uvm_cache_stats[1]}\n"
)
if uvm_cache_stats[1]:
logging.info(
f"unique indices / requested indices: {uvm_cache_stats[2]/uvm_cache_stats[1]}\n"
f"unique misses / requested indices: {uvm_cache_stats[3]/uvm_cache_stats[1]}\n"
)

def prefetch(self, indices: Tensor, offsets: Tensor) -> None:
self.timestep += 1
Expand Down Expand Up @@ -2347,10 +2348,11 @@ def print_uvm_cache_stats(self) -> None:
f"N_conflict_unique_misses: {uvm_cache_stats[4]}\n"
f"N_conflict_misses: {uvm_cache_stats[5]}\n"
)
logging.info(
f"unique indices / requested indices: {uvm_cache_stats[2]/uvm_cache_stats[1]}\n"
f"unique misses / requested indices: {uvm_cache_stats[3]/uvm_cache_stats[1]}\n"
)
if uvm_cache_stats[1]:
logging.info(
f"unique indices / requested indices: {uvm_cache_stats[2]/uvm_cache_stats[1]}\n"
f"unique misses / requested indices: {uvm_cache_stats[3]/uvm_cache_stats[1]}\n"
)

@torch.jit.export
def prefetch(self, indices: Tensor, offsets: Tensor) -> None:
Expand Down

0 comments on commit 2407be6

Please sign in to comment.