Open
Description
Description
import numpy as np
import pytensor.tensor as pt
x = pt.tensor("x", shape=(0, 2))
pt.logsumexp(x).eval({x: np.zeros((0, 2))}) # ValueError: Input of CAReduce{maximum} has zero-size on axis %d
Interestingly, scipy has the same failure point
import numpy as np
import scipy
scipy.special.logsumexp(np.zeros((0, 2))) # ValueError: zero-size array to reduction operation maximum which has no identity
This is arguably an edge case. I think a good compromise is to reject the rewrite when the static size is 0, but not otherwise.