Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gpuCI] Forward-merge branch-22.10 to branch-22.12 [skip gpuci] #723

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions python/cuspatial/cuspatial/core/_column/geocolumn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) 2021-2022 NVIDIA CORPORATION
from functools import cached_property
from typing import Tuple, TypeVar

import cupy as cp
Expand Down Expand Up @@ -218,3 +219,16 @@ def _from_points_xy(cls, points_xy: ColumnBase):
),
meta,
)

@cached_property
def memory_usage(self) -> int:
"""
Outputs how much memory is used by the underlying geometries.
"""
final_size = self._meta.input_types.memory_usage()
final_size = final_size + self._meta.union_offsets.memory_usage()
final_size = final_size + self.points._column.memory_usage
final_size = final_size + self.mpoints._column.memory_usage
final_size = final_size + self.lines._column.memory_usage
final_size = final_size + self.polygons._column.memory_usage
return final_size
1 change: 1 addition & 0 deletions python/cuspatial/cuspatial/core/geoseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ def to_arrow(self):
-- child 3 type: list<item: null>
[]
"""

points = self._column.points
mpoints = self._column.mpoints
lines = self._column.lines
Expand Down
10 changes: 10 additions & 0 deletions python/cuspatial/cuspatial/tests/test_geodataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,16 @@ def test_boolmask(gpdf, df_boolmask):
assert_eq_geo_df(gi[df_boolmask], cugpdf_back[df_boolmask])


def test_memory_usage(gs):
assert gs.memory_usage() == 224
host_dataframe = gpd.read_file(
gpd.datasets.get_path("naturalearth_lowres")
)
gpu_dataframe = cuspatial.from_geopandas(host_dataframe)
# The df size is 8kb of cudf rows and 217kb of the geometry column
assert gpu_dataframe.memory_usage().sum() == 225173


def test_from_dict():
p1 = Point([0, 1])
p2 = Point([2, 3])
Expand Down
14 changes: 14 additions & 0 deletions python/cuspatial/cuspatial/tests/test_geoseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,3 +580,17 @@ def test_shapefile_constructor_reversed():

reversed_gs = gpd.GeoSeries([polygon.orient(p, 1) for p in gs])
assert_eq_geo(reversed_gs, cus.to_geopandas())


def test_memory_usage_simple(gs):
cugs = cuspatial.from_geopandas(gs)
assert cugs.memory_usage() == 1616


def test_memory_usage_large():
host_dataframe = gpd.read_file(
gpd.datasets.get_path("naturalearth_lowres")
)
geometry = cuspatial.from_geopandas(host_dataframe)["geometry"]
# the geometry column from naturalearth_lowres is 217kb of coordinates
assert geometry.memory_usage() == 217021