Skip to content

Refactor sparse unary ops tests - #49158

Closed
vfdev-5 wants to merge 29 commits into
pytorch:masterfrom
Quansight:vfdev-5/refactor-sparse-unaryops-tests
Closed

vfdev-5 wants to merge 29 commits into
pytorch:masterfrom
Quansight:vfdev-5/refactor-sparse-unaryops-tests

Conversation

@vfdev-5

@vfdev-5 vfdev-5 commented Dec 10, 2020 •

Copy link
Copy Markdown
Contributor

Description:

  • Added TestSparseUnaryUfuncs test case to test_sparse.py
  • Removed old test code for neg, asin, log1p ops on sparse data
  • Added sparse unary ops testing helpers in OpInfo, e.g. sample_sparse_inputs
  • Added abs, sign UnaryUfuncInfo to op_db

cc @mruberry

@dr-ci

dr-ci Bot commented Dec 10, 2020 •

Copy link
Copy Markdown

🔗 Helpful links

💊 CI failures summary and remediations

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


Commit d352e0e was recently pushed. Waiting for builds...


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.

Comment thread test/test_sparse.py Resolved
@H-Huang H-Huang added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Dec 10, 2020
@codecov

codecov Bot commented Dec 11, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #49158 (50d741e) into master (2d8795c) will increase coverage by 3.28%.
The diff coverage is 94.28%.

❗ Current head 50d741e differs from pull request most recent head d352e0e. Consider uploading reports for the commit d352e0e to get more accurate results

@@            Coverage Diff             @@
##           master   #49158      +/-   ##
==========================================
+ Coverage   77.47%   80.75%   +3.28%     
==========================================
  Files        1889     1975      +86     
  Lines      184759   216871   +32112     
==========================================
+ Hits       143140   175137   +31997     
- Misses      41619    41734     +115     

@vfdev-5
vfdev-5 force-pushed the vfdev-5/refactor-sparse-unaryops-tests branch from 2414b6c to 523155a Compare December 24, 2020 12:15
@vfdev-5
vfdev-5 requested a review from mruberry December 24, 2020 18:20
@mruberry

Copy link
Copy Markdown
Collaborator

Failures are all in the base, sorry about that @vfdev-5. We can ignore them and I've reverted the PR causing them.

@vfdev-5
vfdev-5 requested a review from mruberry February 22, 2021 22:38
@vfdev-5
vfdev-5 force-pushed the vfdev-5/refactor-sparse-unaryops-tests branch from 3f35fe0 to 4adbfca Compare February 23, 2021 00:56
Comment thread test/test_sparse.py Resolved
Comment thread test/test_sparse.py
def _get_dense_and_sparse_samples(self, device, dtype, op):
test_backward = op.test_complex_grad or not dtype.is_complex
samples = op.sample_inputs(device, dtype, requires_grad=test_backward)
sparse_samples = op.sparse_sample_inputs(device, dtype, requires_grad=test_backward)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

So in this model sparse_sample_inputs() are ADDITIONAL sparse-specific inputs?

Comment thread test/test_sparse.py Resolved
Comment thread test/test_sparse.py Resolved
Comment thread test/test_sparse.py Resolved
Comment thread test/test_sparse.py Resolved
dtype = kwargs.get('dtype', torch.double)
device = kwargs.get('device', 'cpu')
singular = kwargs.get("singular", False)
values_domain = kwargs.get("domain", None)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In the future we should also add tests to test_testing to ensure that random_sparse_matrix() (and make_tensor()) work as expected

Comment thread torch/testing/_internal/common_utils.py Resolved
Comment thread torch/testing/_internal/common_utils.py Resolved
dtype = kwargs.get('dtype', torch.double)
device = kwargs.get('device', 'cpu')
singular = kwargs.get("singular", False)
values_domain = kwargs.get("domain", None)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is this function **kwargs?

We don't need to fix random_sparse_matric() in this PR but that seems odd, and it makes documenting its supported kwargs tricky.

A = torch.sparse_coo_tensor(
indices_tensor, values, (rows, columns), device=device, requires_grad=requires_grad
)
if not uncoalesced:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In the future I'd like to better consider how to generate sparse tensors, especially how to handle coalescing (or not) and the density target

@mruberry mruberry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hey @vfdev-5!

Overall this looks pretty good. I made some inline comments/questions, mostly requesting more comments in the code to explain the choices/assumptions we're making. In the future we probably want to look more closely at generating sparse tensors, too.

@vfdev-5
vfdev-5 requested a review from mruberry February 24, 2021 10:34

@mruberry mruberry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice step forward for sparse testing, @vfdev-5!

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@github-actions github-actions Bot closed this May 12, 2022
@vfdev-5
vfdev-5 deleted the vfdev-5/refactor-sparse-unaryops-tests branch May 12, 2022 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed open source Stale triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants