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
When I implement normalizer in SPU, I counter a problem that a pattern containing the reciprocal of the sqrt is not optimized to rsqrt automatically. I want to ask here whether this kind of pattern can be supported in the future and whether this automatic optimization may have side effect.
Standalone code to reproduce the issue
# The original code containing the reciprocal of the sqrtX=jnp.array([[4, 1, 2, 2], [1, 3, 9, 3], [5, 7, 5, 1]])
norms=jnp.einsum("ij,ij->i", X, X)
X/jnp.sqrt(norms)[:, jnp.newaxis]
# The manually optimized code with the same result but better speedX=jnp.array([[4, 1, 2, 2], [1, 3, 9, 3], [5, 7, 5, 1]])
norms=jnp.einsum("ij,ij->i", X, X)
norms=norms.astype(jnp.float32)
X*jax.lax.rsqrt(norms)[:, jnp.newaxis]
Thanks for reporting this. Yes, this can be optimized by our compiler stack. Will try to add this in next release.
Best
~Yancheng
anakinxc
changed the title
[Bug]: A pattern containing the reciprocal of the sqrt is not optimized to rsqrt automatically
[Compiler Optimization]: A pattern containing the reciprocal of the sqrt is not optimized to rsqrt automatically
Jan 18, 2024
# Pull Request
## What problem does this PR solve?
Issue Number: Fixed#507, partial resolved#387
## Possible side effects?
- Performance:
- Backward compatibility:
Issue Type
Performance
Modules Involved
SPU compiler
Have you reproduced the bug with SPU HEAD?
Yes
Have you searched existing issues?
Yes
SPU Version
spu 0.7.0b0
OS Platform and Distribution
Linux Ubuntu 22.04
Python Version
3.10
Compiler Version
No response
Current Behavior?
Hello, sorry for disturbing you.
When I implement normalizer in SPU, I counter a problem that a pattern containing the reciprocal of the sqrt is not optimized to rsqrt automatically. I want to ask here whether this kind of pattern can be supported in the future and whether this automatic optimization may have side effect.
Standalone code to reproduce the issue
Relevant log output
The text was updated successfully, but these errors were encountered: