-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Add remaining method and tests for dtype propagation #140057
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
Closed
+322
−44
Closed
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e2263ba
Add remaining method and tests
eellison 595f8fa
Update on "Add remaining method and tests"
eellison bb2aed3
Update on "Add remaining method and tests"
eellison a0f44bc
Update on "Add remaining method and tests"
eellison bc49558
Update on "Add remaining method and tests"
eellison 83655e4
Update on "Add remaining method and tests for dtype propagation"
eellison 685b60b
Update on "Add remaining method and tests for dtype propagation"
eellison 91ba576
Update on "Add remaining method and tests for dtype propagation"
eellison 19ad5c4
Update on "Add remaining method and tests for dtype propagation"
eellison 1d92d16
Update on "Add remaining method and tests for dtype propagation"
eellison 91f5345
Update
eellison 430439d
Update
eellison 9e5c520
Update
eellison fd40d4e
Update
eellison 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
Next
Next commit
Add remaining method and tests
[ghstack-poisoned]
- Loading branch information
commit e2263ba6ec909f6f2906bcb64a4ade15aa4a6868
There are no files selected for viewing
This file contains hidden or 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,83 @@ | ||
# Owner(s): ["module: inductor"] | ||
import importlib | ||
import os | ||
import sys | ||
|
||
import torch | ||
from torch._dynamo.utils import disable_cache_limit | ||
from torch._inductor import config | ||
from torch._inductor.test_case import TestCase as InductorTestCase | ||
from torch.testing._internal.common_device_type import instantiate_device_type_tests | ||
from torch.testing._internal.common_methods_invocations import op_db | ||
|
||
|
||
# Make the helper files in test/ importable | ||
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) | ||
sys.path.append(pytorch_test_dir) | ||
|
||
|
||
importlib.import_module("functorch") | ||
importlib.import_module("filelock") | ||
|
||
|
||
from torch._inductor.lowering import lowerings | ||
from torch.testing._internal.common_device_type import ops | ||
from torch.testing._internal.inductor_utils import HAS_GPU | ||
|
||
|
||
unique_pointwise_op_names = set() | ||
|
||
for op in lowerings: | ||
if not isinstance(op, torch._ops.OpOverload): | ||
continue | ||
|
||
if torch.Tag.pointwise not in op.tags: | ||
continue | ||
|
||
if op._schema.is_mutable: | ||
continue | ||
|
||
op_name = (op.name().split("::")[-1]).split(".")[0] | ||
unique_pointwise_op_names.add(op_name) | ||
|
||
pointwise_ops = [ | ||
op | ||
for op in op_db | ||
if op.name in unique_pointwise_op_names and "reduction" not in op.variant_test_name | ||
] | ||
|
||
|
||
class TestCase(InductorTestCase): | ||
@ops( | ||
pointwise_ops, | ||
allowed_dtypes=( | ||
torch.float32, | ||
torch.float64, | ||
torch.int32, | ||
torch.int64, | ||
torch.bool, | ||
), | ||
) | ||
# @config.patch("triton.codegen_upcast_to_fp32", False) # TODO enable | ||
@config.patch("test_configs.runtime_triton_dtype_assert", True) | ||
@disable_cache_limit() | ||
def test_op_dtype_propagation(self, op, dtype): | ||
def run(op, args, kwargs): | ||
return op(*args, **kwargs) | ||
|
||
sample_inputs_itr = op.sample_inputs("cuda", dtype, requires_grad=False) | ||
for sample_input in sample_inputs_itr: | ||
args = (sample_input.input,) + sample_input.args | ||
kwargs = sample_input.kwargs | ||
out = run(op.get_op(), args, kwargs) | ||
out_c = torch.compile(run)(op.get_op(), args, kwargs) | ||
self.assertEqual(out, out_c) | ||
|
||
|
||
instantiate_device_type_tests(TestCase, globals(), only_for=("cuda",)) | ||
|
||
if __name__ == "__main__": | ||
from torch._inductor.test_case import run_tests | ||
|
||
if HAS_GPU: | ||
run_tests(needs="filelock") |
This file contains hidden or 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 hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.