You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import pytensor
import pytensor.tensor as pt
x = pt.tensor("x", shape=(None, None))
y = x.dimshuffle("x", "x")
pytensor.function([x], y).dprint()
# DeepCopyOp [id A] 1
# └─ DimShuffle{order=[x,x]} [id B] 0
# └─ x [id C]
Whenever a DimShuffle only has x and it has as many entries as the inputs, it's basically a specify_shape(x, (1,) * x.type.ndim). If the dimensions were known to be length1, the DimShuffle would be removed correctly
This is a low priority one since the DimShuffle is little more expensive than the specify_shape
The text was updated successfully, but these errors were encountered:
ricardoV94
changed the title
Useless squeeze/expand_dims dimshuffle
Useless dimshuffle("x", "x")Feb 24, 2025
ricardoV94
changed the title
Useless dimshuffle("x", "x")
Useless dimshuffle("x","x")Feb 24, 2025
Description
Whenever a DimShuffle only has
x
and it has as many entries as the inputs, it's basically aspecify_shape(x, (1,) * x.type.ndim)
. If the dimensions were known to be length1, the DimShuffle would be removed correctlyThis is a low priority one since the DimShuffle is little more expensive than the specify_shape
The text was updated successfully, but these errors were encountered: