-
Notifications
You must be signed in to change notification settings - Fork 57
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
Implement rand* ops | feat(torchilb) #1035
Merged
+372
−32
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b120613
Rand ops (#1033)
justinchuby 3c71dc3
Merge branch 'main' into justinchu/rand-ops
justinchuby 2130301
Snap
justinchuby 6ee3f24
Tests
justinchuby 47b65f5
Tests
justinchuby 9b69176
Fix all tests
justinchuby 286b7ec
unused
justinchuby f7c1159
del
justinchuby 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -516,6 +516,109 @@ | |
yield opinfo_core.SampleInput(make_arg(case), p=p, train=training) | ||
|
||
|
||
def sample_inputs_rand(op_info, device, dtype, requires_grad, **kwargs): | ||
def op_info # Unused | ||
|
||
|
||
make_arg = functools.partial( | ||
torch_testing.make_tensor, device=device, dtype=dtype, requires_grad=requires_grad | ||
) | ||
shapes = ( | ||
(M,), | ||
(S, S), | ||
(S, S, S), | ||
) | ||
|
||
for shape in shapes: | ||
yield opinfo_core.SampleInput(make_arg(shape), kwargs=dict(dtype=dtype)) | ||
|
||
|
||
def sample_inputs_rand_like(op_info, device, dtype, requires_grad, **kwargs): | ||
Check warning Code scanning / lintrunner PYLINT/W0613 Warning test
Unused argument 'kwargs' (unused-argument)
See unused-argument. To disable, use # pylint: disable=unused-argument |
||
def op_info # Unused | ||
|
||
make_arg = functools.partial( | ||
torch_testing.make_tensor, device=device, dtype=dtype, requires_grad=requires_grad | ||
) | ||
shapes = ( | ||
(M,), | ||
(S, S), | ||
(S, S, S), | ||
) | ||
|
||
for shape in shapes: | ||
yield opinfo_core.SampleInput(make_arg(shape)) | ||
|
||
|
||
def sample_inputs_rand_like_dtype(op_info, device, dtype, requires_grad, **kwargs): | ||
Check warning Code scanning / lintrunner PYLINT/W0613 Warning test
Unused argument 'kwargs' (unused-argument)
See unused-argument. To disable, use # pylint: disable=unused-argument |
||
def op_info # Unused | ||
|
||
make_arg = functools.partial( | ||
torch_testing.make_tensor, device=device, dtype=torch.float32, requires_grad=requires_grad | ||
) | ||
shapes = ( | ||
(M,), | ||
(S, S), | ||
(S, S, S), | ||
) | ||
|
||
for shape in shapes: | ||
yield opinfo_core.SampleInput(make_arg(shape), kwargs=dict(dtype=dtype)) | ||
|
||
|
||
def sample_inputs_like_fns(self, device, dtype, requires_grad, **kwargs): | ||
inputs = [ | ||
((), {}), | ||
((S, S), {}), | ||
((0, S, 0), {}), | ||
((S,), {'dtype': dtype}), | ||
# Hard-code some dtypes/devices. We want to test cases where the | ||
# (dtype, device) is different from the input's (dtype, device) | ||
((S,), {'dtype': torch.double}), | ||
((S,), ), | ||
|
||
] | ||
for shape, kwargs in inputs: | ||
t = torch_testing.make_tensor(shape, dtype=dtype, device=device, | ||
low=None, high=None, | ||
requires_grad=requires_grad) | ||
yield opinfo_core.SampleInput(t, **kwargs) | ||
|
||
|
||
def sample_inputs_randint(self, device, dtype, requires_grad, **kwargs): | ||
high = 10 | ||
|
||
for sample in sample_inputs_like_fns(self, device, dtype, requires_grad, **kwargs): | ||
# With high | ||
yield opinfo_core.SampleInput(high, sample.input.shape, *sample.args, **sample.kwargs) | ||
|
||
def sample_inputs_randint_low(self, device, dtype, requires_grad, **kwargs): | ||
low = 2 | ||
high = 10 | ||
|
||
for sample in sample_inputs_like_fns(self, device, dtype, requires_grad, **kwargs): | ||
# With low and high | ||
yield opinfo_core.SampleInput(low, high, sample.input.shape, *sample.args, **sample.kwargs) | ||
|
||
|
||
def sample_inputs_randint_like(self, device, dtype, requires_grad, **kwargs): | ||
low = 2 | ||
high = 10 | ||
|
||
for sample in sample_inputs_like_fns(self, device, dtype, requires_grad, **kwargs): | ||
# With high | ||
yield SampleInput( | ||
sample.input, | ||
high, | ||
*sample.args, | ||
**sample.kwargs) | ||
# With low and high | ||
yield SampleInput( | ||
get_independent_tensor(sample.input), | ||
low, | ||
high, | ||
*sample.args, | ||
**sample.kwargs) | ||
|
||
|
||
def sample_inputs_stft(op_info, device, dtype, requires_grad, **kwargs): | ||
del op_info | ||
del kwargs | ||
|
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
Oops, something went wrong.
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.
Check warning
Code scanning / lintrunner
PYLINT/W0613 Warning test