Open
Description
Description
We have a local_0_dot_x
that removes useless dots with zero'd inputs. We don't seem to have anything for dots with ones as reported in #637 (comment)
import pytensor
import pytensor.tensor as pt
from pytensor.compile.mode import get_default_mode
x = tn.col('x')
f = x @ [[1.]]
with pytensor.config.change_flags(optimizer_verbose=True):
fn = pytensor.function([x], f, mode=get_default_mode().excluding("BlasOpt"))
pytensor.dprint(fn)
dot [id A] 0
├─ x [id B]
└─ [[1.]] [id C]
I excluded the BlasOpt just to have a simpler graph, but it will still not rewrite it away with those, just add the more complex Blas Op.
pytensor/pytensor/tensor/rewriting/math.py
Lines 155 to 190 in d3dd34e