Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How should we handle scalar constants in Elemwise fusions? #1270

Open
brandonwillard opened this issue Oct 18, 2022 · 1 comment
Open

How should we handle scalar constants in Elemwise fusions? #1270

brandonwillard opened this issue Oct 18, 2022 · 1 comment
Labels
graph rewriting help wanted Extra attention is needed performance concern question Further information is requested

Comments

@brandonwillard
Copy link
Member

We should probably look into the kinds of fusions that turn scalar constants into inputs.

For example,

import aesara
import aesara.tensor as at


x = at.vector("x")
y = at.exp(x / 5)
z = y * 2

f = aesara.function([x], z)

aesara.dprint(f)
# Elemwise{Composite{(i0 * exp((i1 * i2)))}} [id A] 0
#  |TensorConstant{(1,) of 2.0} [id B]
#  |TensorConstant{(1,) of 0.2} [id C]
#  |x [id D]

It's not clear to me that this is any better than—say—making i0 and i1 constants and removing those two inputs.

In other words, why don't we produce the following instead?

Elemwise{Composite{(2.0 * exp((0.2 * i0)))}} [id A] 0
 |x [id B]

Originally posted by @brandonwillard in #1237 (comment)

@brandonwillard brandonwillard added help wanted Extra attention is needed question Further information is requested graph rewriting performance concern labels Oct 18, 2022
@brandonwillard
Copy link
Member Author

brandonwillard commented Dec 12, 2022

This issue also affects the applicability of the CAReduce/Elemwise fusion optimization added in #1285, because such graphs (unnecessarily) have multiple inputs, which blocks the optimization—at least until we have the functionality described in #1307.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
graph rewriting help wanted Extra attention is needed performance concern question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant