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

threshold: port to structured #57810

Closed
wants to merge 2 commits into from

Conversation

qingyunqu
Copy link

@qingyunqu qingyunqu commented May 7, 2021

Related #55070
Port threshold and threshold_backward to structure

@qingyunqu qingyunqu requested a review from ezyang as a code owner May 7, 2021 07:29
@facebook-github-bot facebook-github-bot added oncall: jit Add this issue/PR to JIT oncall triage queue cla signed labels May 7, 2021
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented May 7, 2021

💊 CI failures summary and remediations

As of commit 016b065 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@codecov
Copy link

codecov bot commented May 7, 2021

Codecov Report

Merging #57810 (016b065) into master (c3d40fd) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #57810      +/-   ##
==========================================
- Coverage   76.84%   76.83%   -0.01%     
==========================================
  Files        1986     1986              
  Lines      197889   197890       +1     
==========================================
- Hits       152068   152058      -10     
- Misses      45821    45832      +11     

namespace at {
namespace meta {
TORCH_META_FUNC(threshold)(const Tensor& self, const Scalar& threshold, const Scalar& value) {
set_output(0, self.sizes(), {}, self.options().memory_format(self.suggest_memory_format()), self.names());
Copy link
Contributor

Choose a reason for hiding this comment

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

This will twing named tensor warnings so you should do self.has_names() ? self.names() : at::ArrayRef<Dimname>{} instead. Sorry it's dumb and we should fix this.

cc @zou3519

@ezyang
Copy link
Contributor

ezyang commented May 7, 2021

You should do this one a little differently. This is a TensorIterator op, so you should use the TensorIteratorBase recipe from https://github.com/pytorch/rfcs/blob/rfc-0005/RFC-0005-structured-kernel-definitions.md#handling-tensoriterator and build the tensor iterator inside the meta function itself. This will prevent you from having to manually define the set_output (which is almost assuredly wrong; you're not handling output type promotion correctly).

@ezyang
Copy link
Contributor

ezyang commented May 7, 2021

That will also let you deduplicate the TensorIterator construction calls in threshold_out_cuda and threshold_out

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

more refactorrr

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@ezyang merged this pull request in 85d6464.

krshrimali pushed a commit to krshrimali/pytorch that referenced this pull request May 19, 2021
Summary:
Related pytorch#55070
Port threshold and threshold_backward to structure

Pull Request resolved: pytorch#57810

Reviewed By: agolynski

Differential Revision: D28382716

Pulled By: ezyang

fbshipit-source-id: 8d0702ad074b52e8512524d9807c93bfe04c51d6
@bdhirsh bdhirsh changed the title Port threshold to structure threshold: port to structured May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Merged oncall: jit Add this issue/PR to JIT oncall triage queue open source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants