pymc-devs / pytensor

PyTensor allows you to define, optimize, and efficiently evaluate mathematical expressions involving multi-dimensional arrays.
https://pytensor.readthedocs.io
Other
362 stars 108 forks source link

Incorrect shape inferrence for blockwise dot #464

Closed aseyboldt closed 1 year ago

aseyboldt commented 1 year ago

Description

It seems some part of the shape inference for blockwise gives incorrect results:

import pytensor
import pytensor.tensor as pt

x = pt.tensor("x", shape=(19, 19))
q = np.random.randn(20, 19)
(q @ x).type
# TensorType(float64, shape=(19, 19))

This gives me (19, 19) on main, when it should be (20, 19).

If I wrap q into a tensor variable I get the correct result:

import pytensor
import pytensor.tensor as pt

x = pt.tensor("x", shape=(19, 19))
q = pt.as_tensor_variable(np.random.randn(20, 19))
(q @ x).type
# TensorType(float64, shape=(20, 19))
ricardoV94 commented 1 year ago

Should be solved by #465