Repository navigation
Conversation
|
Hi @pearu! Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours needs attention. You currently have a record in our system, but we do not have a signature on file. In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Codecov Report
@@ Coverage Diff @@
## master #45695 +/- ##
==========================================
- Coverage 60.81% 60.80% -0.01%
==========================================
Files 2748 2748
Lines 254039 254129 +90
==========================================
+ Hits 154497 154531 +34
- Misses 99542 99598 +56 |
|
@mruberry, please review. |
|
@pearu let's give this a moment while we hash out the fundamental design issues. One of the things we talked about (briefly) was not exposing coalescing to users. I don't think that's likely to change but no need to rush this, right? |
|
@mruberry, no hurry, we can revisit this PR once the fundamental design discussions are settled down. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
|
@pearu - do we still want to pursue this? |
This PR implements no new functionality but introduces a few API changes in order to
Both make sense to me to improve exposing sparse tensors support to end-users but there appears to be no consensus on the importance nor acceptance of these items. |
|
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
This PR is a follow-up to the discussion in #45400 (comment):
indices(coalesce=True)- return the indices of coalesced tensor,indices(False)is identical to_indices().values(coalesce=True)- return the values of coalesced tensor,values(False)is identical to_values().nse(coalesce=True)- return the number of specified elements of a coalesced tensor.nse(False)is identical to_nnz().coalesceargument inindices,values,nsedocstrings._indices()withindices(False)everywhere in Python code._values()withvalues(False)everywhere in Python code._nnz()withnse(False)everywhere in Python code._indices,_values,_nse: trigger a deprecation warning when users call these from Python._nnzstarting from PyTorch version 1.9:_indices,_values,_nnz; explaincoalesce=Falsein uncoalesce COO tensor section; add a note thatcoalesceis not a cheap operation and suggestcoalescebefore processing the outputs ofindices/values/nse.nnztonseeverywhere in Python/C++ code, update commentsAt the C++ level, we'll continue using the underscore prefixed functions as unsafe API functions.
Summary
The public Python API contains the following methods:
torch.Tensor.nse(coalesce=True)torch.Tensor.indices(coalesce=True)torch.Tensor.values(coalesce=True)that represent the COO storage format interface of PyTorch tensors with COO layout.
The usage of unsafe Python API methods,
torch.Tensor._nse(),torch.Tensor._indices(),torch.Tensor._values(), is deprecated. However, the methods remain to exist in the Python API.The public C++ API contains the following methods:
Tensor.nse(coalesce=true)Tensor.indices(coalesce=true)Tensor.values(coalesce=true)The unsafe C++ API contains the following methods:
Tensor._nse()that is equivalent toTensor.nse(false)Tensor._indices()that is equivalent toTensor.indices(false)Tensor._values()that is equivalent toTensor.values(false)As a rule, C++ algorithms on tensors with COO layout use the unsafe C++ API.
The private Python/C++ API contains
torch.Tensor._values_coalesce()(orTensor._values_coalesce()in C++) method that usage is deprecated both in Python and C++ (except in calling it fromTensor.values(coalesce)implementation). The method was introduced to ensure that expressionvalues(True)is differentiable whilevalues(False)is not.Out of all the above methods, only the expression
torch.Tensor.values(True)(orTensor.values(true)in C++) is differentiable.The usage of
torch.Tensor._nnz()(orTensor._nnz()in C++) is deprecated and these methods will be removed in the future PyTorch release.