-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
Make sparse tensor types extend the existing tensor types #303
Make sparse tensor types extend the existing tensor types #303
Conversation
f593fbc
to
e76a322
Compare
Codecov Report
@@ Coverage Diff @@
## master #303 +/- ##
==========================================
+ Coverage 71.89% 71.91% +0.01%
==========================================
Files 166 166
Lines 54567 54632 +65
==========================================
+ Hits 39232 39288 +56
- Misses 15335 15344 +9
|
e76a322
to
fcf23d6
Compare
@@ -355,8 +360,7 @@ def __getitem__(self, args): | |||
return ret | |||
|
|||
|
|||
class SparseVariable(_sparse_py_operators, Variable): | |||
dtype = property(lambda self: self.type.dtype) | |||
class SparseVariable(_sparse_py_operators, TensorVariable): |
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.
Why are the supertypes in a different order compared to the SparseConstant
below?
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.
Not sure.
@@ -442,7 +451,7 @@ def bsr_matrix(name=None, dtype=None): | |||
csr_fmatrix = SparseType(format="csr", dtype="float32") | |||
bsr_fmatrix = SparseType(format="bsr", dtype="float32") | |||
|
|||
all_dtypes = SparseType.dtype_set | |||
all_dtypes = list(SparseType.dtype_specs_map.keys()) |
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.
Did you make it a list so it can be appended at runtime?
else: | ||
raise NotImplementedError( | ||
f'unsupported dtype "{dtype}" not in list', list(self.dtype_set) | ||
"You can't make SparseType object when SciPy is not available." |
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.
Is it even a supported use case to NOT have scipy?
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.
That's how this project was originally designed, I believe, but there's no point in supporting that optionality now.
This sparse implementation only supports matrices, but we could cover more ground with |
This PR refactors the sparse tensor type structure so that sparse types extend the existing tensor types. A new meta type is used to construct a
DenseTensorType
that can be used to distinguish dense from sparseTensorType
s.Closes #142.
DenseTensorVariable
(using the same approach asDenseTensorType
)SparseTensor
sOp
s (e.g.Elemwise
,CAReduce
)