Skip to content

Shared and Constants are not instances of respective Variables #627

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

Closed
ricardoV94 opened this issue Feb 5, 2024 · 1 comment · Fixed by #628
Closed

Shared and Constants are not instances of respective Variables #627

ricardoV94 opened this issue Feb 5, 2024 · 1 comment · Fixed by #628

Comments

@ricardoV94
Copy link
Member

Description

import pytensor
import pytensor.tensor as pt
import pytensor.sparse as ps

x = pt.as_tensor([[1, 0, 1.], [0, 1, 0]])
y = pt.exp(x)
assert isinstance(x, pt.TensorConstant)
assert isinstance(x, pt.TensorVariable)
assert not isinstance(y, pt.TensorConstant)
assert isinstance(y, pt.TensorVariable)

x = ps.as_sparse(ps.csr_from_dense(x).eval())
y = ps.structured_exp(x)
assert isinstance(x, ps.SparseConstant)
assert isinstance(x, ps.SparseVariable)  # Fails
assert not isinstance(y, ps.SparseConstant)
assert isinstance(y, ps.SparseVariable)

This was observed in pymc-devs/pymc#7114 (comment)

@ricardoV94
Copy link
Member Author

Similarly, shared variables (dense or sparse) are not instances of TensorVariables either...

DenseTensor Constants also didn't use to be considered instances of DenseTensor Variables until: aesara-devs/aesara#556

@ricardoV94 ricardoV94 changed the title SparseConstants are not seen as instances of SparseVariables Shared and Constants are not instances of respective Variables Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant