-
Notifications
You must be signed in to change notification settings - Fork 1
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
State reduce #3
Open
Linux-cpp-lisp
wants to merge
8
commits into
main
Choose a base branch
from
state-reduce
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+182
−22
Open
State reduce #3
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e3d626b
add padding util
Linux-cpp-lisp 3f30caf
get/set state
Linux-cpp-lisp 0e23af5
add accumulate_state
Linux-cpp-lisp 518cf16
lint
Linux-cpp-lisp 9501c36
bump
Linux-cpp-lisp 34751e8
set device in _runstats accumulate state
JonathanSchmidt1 ac333ef
change device before padding in case
Linux-cpp-lisp 6ea64e7
Merge branch 'main' into state-reduce
Linux-cpp-lisp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pytest | ||
import random | ||
|
||
import torch | ||
|
||
from torch_runstats._util import _pad_dim0 | ||
|
||
|
||
@pytest.mark.parametrize("ndim", [1, 2, 4]) | ||
def test_pad_dim0(ndim): | ||
orig_shape = tuple(random.randint(1, 5) for _ in range(ndim)) | ||
x = torch.ones(orig_shape) | ||
to_add = 3 | ||
padded = _pad_dim0(x, to_add) | ||
assert padded.shape[1:] == orig_shape[1:] | ||
assert padded.shape[0] == orig_shape[0] + to_add | ||
assert torch.equal(x, padded[:-to_add]) | ||
assert padded[-to_add:].abs().max() == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import torch | ||
|
||
|
||
def _pad_dim0(x: torch.Tensor, n: int) -> torch.Tensor: | ||
if n == 0: | ||
return | ||
elif n < 0: | ||
raise ValueError | ||
return torch.nn.functional.pad(x, (0,) * ((x.ndim - 1) * 2) + (0, n)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.2.0" | ||
__version__ = "0.2.1" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost the same as
accumulate_batch
. So is it for the horovod interface?