Skip to content

Alloc does not check for runtime broadcasting #379

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 Jul 13, 2023 · 1 comment · Fixed by #390
Closed

Alloc does not check for runtime broadcasting #379

ricardoV94 opened this issue Jul 13, 2023 · 1 comment · Fixed by #390
Assignees
Labels

Comments

@ricardoV94
Copy link
Member

ricardoV94 commented Jul 13, 2023

Description

import numpy as np
import pytensor.tensor as pt

x = pt.vector("x", shape=(None,))
out = pt.alloc(x, 3, 5)
print(out.eval({x: np.zeros(1)}).shape)  # (3, 5)
grad_out = pt.grad(out.sum(), wrt=x)
print(grad_out.eval({x: np.zeros(1)}).shape)  # (5,)

Interestingly if we do out = pt.alloc(x, 5) then, the rewrites consider that alloc useless and out is replaced by specify_shape(x, 5). AFAICT this was always present in Theano, and was not changed in Aesara.

@ricardoV94 ricardoV94 changed the title Alloc is happy to perform runtime broadcasting Alloc does not check for runtime broadcasting Jul 13, 2023
@ricardoV94 ricardoV94 self-assigned this Jul 19, 2023
@ricardoV94
Copy link
Member Author

This was briefly discussed in this old Theano issue: Theano/Theano#2584 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant