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

Features/807 roll #829

Merged
merged 14 commits into from
Aug 2, 2021
Merged

Features/807 roll #829

merged 14 commits into from
Aug 2, 2021

Conversation

mtar
Copy link
Collaborator

@mtar mtar commented Jul 5, 2021

Description

This PR adds roll function to Heat. It uses PyTorch if the roll is not along the split axis. It improves on it that it is now possible to use a single shift on multiple axes (int/tuple) similar to NumPy.

NOTE
Requires PyTorch 1.9 Simple check for 1.7. and 1.8. added promoting the type. Can be removed when the support is dropped.

Issue/s resolved: #807

Changes proposed:

  • add roll

Type of change

  • New feature

Due Diligence

  • All split configurations tested
  • Multiple dtypes tested in relevant functions
  • Documentation updated (if needed)
  • Updated changelog.md under the title "Pending Additions"

Does this change modify the behaviour of other functions? If so, which?

no

@mtar mtar added the API Anything relating the API label Jul 5, 2021
@codecov
Copy link

codecov bot commented Jul 5, 2021

Codecov Report

Merging #829 (b215c59) into master (3b31102) will increase coverage by 0.02%.
The diff coverage is 98.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #829      +/-   ##
==========================================
+ Coverage   95.32%   95.35%   +0.02%     
==========================================
  Files          64       64              
  Lines        9056     9125      +69     
==========================================
+ Hits         8633     8701      +68     
- Misses        423      424       +1     
Flag Coverage Δ
gpu 94.49% <98.55%> (+0.03%) ⬆️
unit 91.00% <98.55%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
heat/core/manipulations.py 99.04% <98.55%> (-0.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b31102...b215c59. Read the comment docs.

@mtar
Copy link
Collaborator Author

mtar commented Jul 7, 2021

test fails on pytorch 1.8.1: RuntimeError: repeats has to be Long tensor

@ClaudiaComito ClaudiaComito added this to the 1.2.x milestone Jul 13, 2021
@coquelin77
Copy link
Member

rerun tests

@coquelin77
Copy link
Member

test fails on pytorch 1.8.1: RuntimeError: repeats has to be Long tensor

also fails on torch 1.7 with the same error on the 8 GPU tests


lshape_map = x.create_lshape_map()[:, x.split] # local elements along axis
cumsum_map = torch.cumsum(lshape_map, dim=0) # cumulate along axis
indices = torch.arange(size)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

device

Comment on lines 1948 to 1958
# use pytorch if it's not the split axis
rolled = torch.roll(x.larray, shift, axis)
return DNDarray(
rolled,
gshape=x.shape,
dtype=x.dtype,
split=x.split,
device=x.device,
comm=x.comm,
balanced=x.balanced,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would wonderful if these loops could be switched slightly so they are not so nested. That being said, i understand why you did it this way. I am not against keeping this way, its just odd to read in the moment

@mtar mtar requested a review from coquelin77 July 20, 2021 07:13
Copy link
Member

@coquelin77 coquelin77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great, can you add 1 more test? 3d

heat/core/manipulations.py Outdated Show resolved Hide resolved
@coquelin77
Copy link
Member

looks great, can you add 1 more test? 3d

sorry, i just put it in myself. i thought that upon refresh this would be deleted

@coquelin77 coquelin77 merged commit f0afedf into master Aug 2, 2021
@coquelin77 coquelin77 deleted the features/807-roll branch August 2, 2021 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Anything relating the API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement roll
3 participants