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

Remove stack() call and warnings for external users in DNDarray.larray #811

Merged
merged 5 commits into from
Jun 18, 2021
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Example on 2 processes:
- [#785](https://github.com/helmholtz-analytics/heat/pull/785) added allowance for 1 dimensional non-contiguous local tensors in `communication. MPICommunication.mpi_type_and_elements_of()`
- [#787](https://github.com/helmholtz-analytics/heat/pull/787) Fixed an issue where Heat cannot be imported when some optional dependencies are not available.
- [#790](https://github.com/helmholtz-analytics/heat/pull/790) catch incorrect device after `bcast` in `DNDarray.__getitem__`
- [#811](https://github.com/helmholtz-analytics/heat/pull/811) Fixed memory leak in `DNDarray.larray`

### Linear Algebra
- [#718](https://github.com/helmholtz-analytics/heat/pull/718) New feature: `trace()`
- [#768](https://github.com/helmholtz-analytics/heat/pull/768) New feature: unary positive and negative operations
Expand Down
14 changes: 2 additions & 12 deletions heat/core/dndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class DNDarray:

def __init__(
self,
array: DNDarray,
array: torch.Tensor,
gshape: Tuple[int, ...],
dtype: datatype,
split: int,
Expand Down Expand Up @@ -162,16 +162,6 @@ def larray(self, array: torch.Tensor):
split = self.split
if split is not None and array.shape[split] != self.lshape[split]:
self.__balanced = None
# raise warning if function was called by user/not out of 'heat/core/*'
caller = stack()[1]
abs_heat_path = Path("heat", "core").resolve()
abs_path_caller = Path(caller.filename).resolve()

if not (abs_heat_path < abs_path_caller):
warnings.warn(
"!!! WARNING !!! Manipulating the local contents of a DNDarray needs to be done with care and "
"might corrupt/invalidate the metadata in a DNDarray instance"
)
self.__array = array

@property
Expand Down Expand Up @@ -552,7 +542,7 @@ def __complex__(self) -> DNDarray:
"""
return self.__cast(complex)

def counts_displs(self) -> Tuple(torch.Tensor, torch.Tensor):
def counts_displs(self) -> Tuple[torch.Tensor, torch.Tensor]:
"""
Returns actual counts (number of items per process) and displacements (offsets) of the DNDarray.
Does not assume load balance.
Expand Down