Skip to content

Migrate le/gt/ge/eq/ne from the TH to Aten. Added support of type promotion.#26981

Closed
ifedan wants to merge 9 commits intopytorch:masterfrom
ifedan:comparison_ops
Closed

Migrate le/gt/ge/eq/ne from the TH to Aten. Added support of type promotion.#26981
ifedan wants to merge 9 commits intopytorch:masterfrom
ifedan:comparison_ops

Conversation

@ifedan
Copy link
Contributor

@ifedan ifedan commented Sep 27, 2019

#24606 Migrate ne and ne_ from the TH to Aten (CUDA)
#24740 Migrate ne and ne_ from the TH to Aten (CPU)
#24573 Migrate gt and gt_ from the TH to Aten (CUDA)
#24709 Migrate gt and gt_ from the TH to Aten (CPU)
#24556 Migrate eq and eq_ from the TH to Aten (CUDA)
#24696 Migrate eq and eq_ from the TH to Aten (CPU)
#24568 Migrate ge and ge_ from the TH to Aten (CUDA)
#24703 Migrate ge and ge_ from the TH to Aten (CPU)
#24582 Migrate le and le_ from the TH to Aten (CUDA)
#24719 Migrate le and le_ from the TH to Aten (CPU)

Performance characteristics are similar to #25998

This PR migrates comparison ops from TH to ATen and adds type promotion in the same way as in #25998

@pytorchbot pytorchbot added module: build Build system issues module: cpu CPU specific problem (e.g., perf, algorithm) module: cuda Related to torch.cuda, and CUDA support in general module: internals Related to internal abstractions in c10 and ATen module: nn Related to torch.nn module: operators labels Sep 27, 2019
@ifedan ifedan marked this pull request as ready for review September 27, 2019 18:25
@ifedan ifedan added this to the 1.3 milestone Sep 27, 2019
@zou3519
Copy link
Contributor

zou3519 commented Sep 27, 2019

You should note in the commit message that this adds some type promotion behavior

@zou3519
Copy link
Contributor

zou3519 commented Sep 27, 2019

"All the comparison operation will follow type promotion described" this makes it vague about if we've added type promotion or not. It would be good to be explicit and say "This PR migrates comparison ops from TH to ATen and adds type promotion in the same way as in #25998". Would also be good to update the PR title to say something about type promotion.

@ifedan ifedan changed the title Migrate le/gt/ge/eq/ne from the TH to Aten Migrate le/gt/ge/eq/ne from the TH to Aten. Added support of type promotion. Sep 27, 2019
};

template<typename ScalarTypeOut, typename ScalarType, typename TensorTypeOut, typename TensorType, class Op>
void THC_logicalValue(THCState *state,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we still need this. However, let's worry about that in the future and not in this PR.

def test_inplace_comparison_ops_require_inputs_have_same_dtype(self):
with self.assertRaisesRegex(RuntimeError, 'Expected object of scalar type'):
torch.tensor([1], dtype=torch.int).lt_(torch.tensor([2], dtype=torch.long))
torch.tensor([1], dtype=torch.int).le_(torch.tensor([2], dtype=torch.long))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please clean up these tests by not repeating yourself. If we make this a for loop, it only needs to be 3 lines instead of 6

Copy link
Contributor

@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

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

We can repeat ourselves less in the tests but otherwise lgtm. Good work in deleting all those lines of code!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ifedan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ifedan
Copy link
Contributor Author

ifedan commented Sep 27, 2019

We can repeat ourselves less in the tests but otherwise lgtm. Good work in deleting all those lines of code!

Test changed based on comment

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ifedan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Sep 28, 2019
…motion. (#26981)

Summary:
pytorch/pytorch#24606 Migrate ne and ne_ from the TH to Aten (CUDA)
pytorch/pytorch#24740 Migrate ne and ne_ from the TH to Aten (CPU)
pytorch/pytorch#24573 Migrate gt and gt_ from the TH to Aten (CUDA)
pytorch/pytorch#24709 Migrate gt and gt_ from the TH to Aten (CPU)
pytorch/pytorch#24556 Migrate eq and eq_ from the TH to Aten (CUDA)
pytorch/pytorch#24696 Migrate eq and eq_ from the TH to Aten (CPU)
pytorch/pytorch#24568 Migrate ge and ge_ from the TH to Aten (CUDA)
pytorch/pytorch#24703 Migrate ge and ge_ from the TH to Aten (CPU)
pytorch/pytorch#24582 Migrate le and le_ from the TH to Aten (CUDA)
pytorch/pytorch#24719 Migrate le and le_ from the TH to Aten (CPU)

Performance characteristics are similar to pytorch/pytorch#25998

This PR migrates comparison ops from TH to ATen and adds type promotion in the same way as in pytorch/pytorch#25998
Pull Request resolved: pytorch/pytorch#26981

Differential Revision: D17635651

Pulled By: ifedan

fbshipit-source-id: 6ec7615207f5c248a6dd85fc54c25bd5e6d328e6
@facebook-github-bot
Copy link
Contributor

@ifedan merged this pull request in 541de7e.

@mruberry
Copy link
Collaborator

mruberry commented Sep 28, 2019

This PR looks super cool but I think it was breaking cuDNN test builds. I had to unland it. I think you just need to modify test_overwrite_module_params_on_conversion_cpu_cuda.

Edit/Update: The revert fixed the cuDNN builds. Looks like this PR did break the cuDNN test builds.

@mruberry mruberry reopened this Sep 28, 2019
@ifedan ifedan closed this Sep 28, 2019
facebook-github-bot pushed a commit that referenced this pull request Sep 28, 2019
…motion. (#27017)

Summary:
#26981
Pull Request resolved: #27017

Differential Revision: D17651454

Pulled By: ifedan

fbshipit-source-id: c6313caa11598a0ef160e1c6d2f3c33d03ce80c5
zdevito pushed a commit to zdevito/ATen that referenced this pull request Sep 28, 2019
…motion. (#27017)

Summary:
pytorch/pytorch#26981
Pull Request resolved: pytorch/pytorch#27017

Differential Revision: D17651454

Pulled By: ifedan

fbshipit-source-id: c6313caa11598a0ef160e1c6d2f3c33d03ce80c5
pdlive215 pushed a commit to pdlive215/pytorch that referenced this pull request Nov 27, 2019
…motion. (pytorch#26981)

Summary:
pytorch#24606 Migrate ne and ne_ from the TH to Aten (CUDA)
pytorch#24740 Migrate ne and ne_ from the TH to Aten (CPU)
pytorch#24573 Migrate gt and gt_ from the TH to Aten (CUDA)
pytorch#24709 Migrate gt and gt_ from the TH to Aten (CPU)
pytorch#24556 Migrate eq and eq_ from the TH to Aten (CUDA)
pytorch#24696 Migrate eq and eq_ from the TH to Aten (CPU)
pytorch#24568 Migrate ge and ge_ from the TH to Aten (CUDA)
pytorch#24703 Migrate ge and ge_ from the TH to Aten (CPU)
pytorch#24582 Migrate le and le_ from the TH to Aten (CUDA)
pytorch#24719 Migrate le and le_ from the TH to Aten (CPU)

Performance characteristics are similar to pytorch#25998

This PR migrates comparison ops from TH to ATen and adds type promotion in the same way as in pytorch#25998
Pull Request resolved: pytorch#26981

Differential Revision: D17635651

Pulled By: ifedan

fbshipit-source-id: 6ec7615207f5c248a6dd85fc54c25bd5e6d328e6
pdlive215 pushed a commit to pdlive215/pytorch that referenced this pull request Nov 27, 2019
…motion. (pytorch#27017)

Summary:
pytorch#26981
Pull Request resolved: pytorch#27017

Differential Revision: D17651454

Pulled By: ifedan

fbshipit-source-id: c6313caa11598a0ef160e1c6d2f3c33d03ce80c5
thiagocrepaldi pushed a commit to thiagocrepaldi/pytorch that referenced this pull request Feb 4, 2020
…motion. (pytorch#27017)

Summary:
pytorch#26981
Pull Request resolved: pytorch#27017

Differential Revision: D17651454

Pulled By: ifedan

fbshipit-source-id: c6313caa11598a0ef160e1c6d2f3c33d03ce80c5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: build Build system issues module: cpu CPU specific problem (e.g., perf, algorithm) module: cuda Related to torch.cuda, and CUDA support in general module: internals Related to internal abstractions in c10 and ATen module: nn Related to torch.nn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants