-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
torch.mm(dense, sparse_csr) #73686
Closed
Closed
torch.mm(dense, sparse_csr) #73686
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5de502a
Subset of code
cpuhrsch f714a13
SparseCsrTensorMath.cpp
cpuhrsch 0f23c94
Support mul(scalar, sparse)
cpuhrsch dddccaf
Merge branch 'master' into sparsedensemm1
cpuhrsch 3cd3346
Support mul(scalar, sparse_csr)
cpuhrsch 1f8537a
Merge branch 'master' of github.com:pytorch/pytorch into sparsedensemm1
cpuhrsch 81dd4f4
Remove debugging code
cpuhrsch 8118928
Use inline
cpuhrsch f5e1e61
Merge branch 'master' of github.com:pytorch/pytorch into sparsedensemm1
cpuhrsch c71d386
Merge branch 'master' of github.com:pytorch/pytorch into sparsedensemm1
cpuhrsch 345ce5a
Introduce _is_sparse_and_zero
cpuhrsch ca596ca
Avoid in-place expand
cpuhrsch 6ec1929
Use native::resize_output for deprecation warning
cpuhrsch File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 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 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 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,63 @@ | ||
#pragma once | ||
|
||
#include <ATen/Tensor.h> | ||
#include <ATen/core/Scalar.h> | ||
|
||
namespace at { | ||
namespace native { | ||
namespace sparse { | ||
namespace impl { | ||
|
||
// Returns true if all entries of self are zero | ||
// TODO: This has potential to be a generic helper | ||
inline bool _is_sparse_and_zero(const Tensor& self) { | ||
if (self.is_sparse_csr() || self.is_sparse()) { | ||
if (self._nnz() == 0) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
inline void _check_is_cpu(const Tensor& self, c10::string_view name) { | ||
TORCH_CHECK( | ||
self.is_cpu(), | ||
"Expected all tensors to be on the same device. addmm expected '", | ||
name, | ||
"' to be CPU tensor, but got ", | ||
self.device(), | ||
" tensor"); | ||
} | ||
|
||
inline void _check_is_cuda(const Tensor& self, c10::string_view name) { | ||
TORCH_CHECK( | ||
self.is_cuda(), | ||
"Expected all tensors to be on the same device. addmm expected '", | ||
name, | ||
"' to be CUDA tensor, but got ", | ||
self.device(), | ||
" tensor"); | ||
} | ||
|
||
inline void _check_dim(const Tensor& self, int64_t target_dim, c10::string_view name) { | ||
if (target_dim == 2) { | ||
TORCH_CHECK( | ||
self.dim() == target_dim, | ||
name, " must be a matrix, ", | ||
"got ", self.dim(), "-D tensor"); | ||
} | ||
TORCH_CHECK( | ||
self.dim() == target_dim, | ||
"Expected ", | ||
name, | ||
" to be of dimension ", | ||
target_dim, | ||
" but got ", | ||
self.dim(), | ||
" instead."); | ||
} | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains 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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be already in the generated code. The easy way to check this is to pass tensors on different devices and see whether you get an error from these lines or from somewhere higher in the call chain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but then we have to update all the error message tests etc. Sounds like good follow up work.