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

Make Sparse tensor Types extend TensorType #766

Merged
merged 3 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aesara/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def get_scalar_constant_value(v):
"""
# Is it necessary to test for presence of aesara.sparse at runtime?
sparse = globals().get("sparse")
if sparse and isinstance(v.type, sparse.SparseType):
if sparse and isinstance(v.type, sparse.SparseTensorType):
if v.owner is not None and isinstance(v.owner.op, sparse.CSM):
data = v.owner.inputs[0]
return tensor.get_scalar_constant_value(data)
Expand Down
2 changes: 1 addition & 1 deletion aesara/link/c/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CType(Type, CLinkerType):
- `TensorType`: for numpy.ndarray
- `SparseType`: for scipy.sparse
- `SparseTensorType`: for scipy.sparse
But you are encouraged to write your own, as described in WRITEME.
Expand Down
4 changes: 2 additions & 2 deletions aesara/misc/may_share_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
try:
import scipy.sparse

from aesara.sparse.basic import SparseType
from aesara.sparse.basic import SparseTensorType

def _is_sparse(a):
return scipy.sparse.issparse(a)
Expand Down Expand Up @@ -64,4 +64,4 @@ def may_share_memory(a, b, raise_other_type=True):

if a_gpua or b_gpua:
return False
return SparseType.may_share_memory(a, b)
return SparseTensorType.may_share_memory(a, b)
2 changes: 1 addition & 1 deletion aesara/sparse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
enable_sparse = False
warn("SciPy can't be imported. Sparse matrix support is disabled.")

from aesara.sparse.type import SparseType, _is_sparse
from aesara.sparse.type import SparseTensorType, _is_sparse


if enable_sparse:
Expand Down
Loading