Replies: 6 comments 1 reply
-
@ferrine It don't think it is valid to make that constant unbroadcastable. Changing the broadcastable flag only makes sense for variables where you don't know the runtime shape yet, and which may or may not be broadcastable. However that constant is known, and is by definition broadcastable. |
Beta Was this translation helpful? Give feedback.
-
A more real-life example highlighting the issue from aesara.graph.opt_utils import is_same_graph, optimize_graph
import aesara.tensor as at
import aesara
v = at.matrix()
v3 = v ** 3
const = at.ones((1, 1))
v3_const = aesara.clone_replace(v3, {v: const})
assert optimize_graph(v3_const).broadcastable == v3.broadcastable Specifying the pattern does not help as well from aesara.graph.opt_utils import is_same_graph, optimize_graph
import aesara.tensor as at
import aesara
v = at.matrix()
v3 = v ** 3
const = at.patternbroadcast(at.ones((1, 1)), (False, False))
v3_const = aesara.clone_replace(v3, {v: const})
assert optimize_graph(v3_const).broadcastable == v3.broadcastable |
Beta Was this translation helpful? Give feedback.
-
To make that rewrite valid, you would have to do the other way around, that is, change the broadcast of the matrix to |
Beta Was this translation helpful? Give feedback.
-
But I don't have an idea of the replacement before the runtime, moreover I would want to change it from time to time |
Beta Was this translation helpful? Give feedback.
-
If you are depending on the broadcastable pattern to be |
Beta Was this translation helpful? Give feedback.
-
What you are observing is the little bit of type inference/synthesis/narrowing that Aesara is now doing. Take a look at the documentation on |
Beta Was this translation helpful? Give feedback.
-
Description of your problem or feature request
Please provide a minimal, self-contained, and reproducible example.
Please provide the full traceback of any errors.
Please provide any additional information below.
Versions and main components
python -c "import aesara; print(aesara.config)"
) not applicableBeta Was this translation helpful? Give feedback.
All reactions