Skip to content

Commit

Permalink
better name
Browse files Browse the repository at this point in the history
  • Loading branch information
mfbalin committed Jul 19, 2024
1 parent 8749a25 commit 9b5e58a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python/dgl/graphbolt/impl/cpu_cached_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
__all__ = ["CPUCachedFeature"]


def num_cache_items(cache_capacity_in_bytes, single_item):
def bytes_to_number_of_items(cache_capacity_in_bytes, single_item):
"""Returns the number of rows to be cached."""
item_bytes = single_item.nbytes
# Round up so that we never get a size of 0, unless bytes is 0.
Expand Down Expand Up @@ -49,7 +49,7 @@ def __init__(
self.max_cache_size_in_bytes = max_cache_size_in_bytes
# Fetching the feature dimension from the underlying feature.
feat0 = fallback_feature.read(torch.tensor([0]))
cache_size = num_cache_items(max_cache_size_in_bytes, feat0)
cache_size = bytes_to_number_of_items(max_cache_size_in_bytes, feat0)
self._feature = CPUFeatureCache(
(cache_size,) + feat0.shape[1:],
feat0.dtype,
Expand Down Expand Up @@ -107,7 +107,7 @@ def update(self, value: torch.Tensor, ids: torch.Tensor = None):
feat0 = value[:1]
self._fallback_feature.update(value)
cache_size = min(
num_cache_items(self.max_cache_size_in_bytes, feat0),
bytes_to_number_of_items(self.max_cache_size_in_bytes, feat0),
value.shape[0],
)
self._feature = None # Destroy the existing cache first.
Expand Down

0 comments on commit 9b5e58a

Please sign in to comment.