Skip to content
Draft
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
13 changes: 12 additions & 1 deletion heat/core/dndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def __init__(
comm: Communication,
balanced: bool,
):
dtype = types.canonical_heat_type(dtype)

self.__array = array
self.__gshape = gshape
self.__dtype = dtype
Expand All @@ -69,8 +71,17 @@ def __init__(
self.__partitions_dict__ = None
self.__lshape_map = None

# check for inconsistencies between torch and heat devices
# check for inconsistencies between local and global arrays
assert str(array.device) == device.torch_device
assert self.ndim == array.ndim, (
f"Local dimension {array.ndim} exceeds global dimension {self.ndim}!"
)
assert all([gshape[i] >= array.shape[i] for i in range(self.ndim)]), (
f"Local shape {array.shape} is larger than global shape {gshape}"
)
assert dtype == types.canonical_heat_type(array.dtype), (
f"Local datatype {array.dtype} is incompatible with global datatype {dtype}"
)

@property
def balanced(self) -> bool:
Expand Down
Loading