Reductions can quietly muck with loop in/out types
See original GitHub issueSimple example:
import jax
jax.config.update('jax_enable_x64', True)
print(jax.config.values)
from jax import lax, numpy as jnp
def f(carry, y):
return carry + jnp.prod(y, axis=-1), None
lax.scan(f, init=jnp.zeros([2], dtype=jnp.int32), xs=jnp.ones([3, 2, 0],dtype=jnp.int32))[0]
TypeError: scan carry output and input must have identical types, got
ShapedArray(int64[2])
and
ShapedArray(int32[2]).
The issue seems to be that prod
without the dtype
arg upcasts (agreeing w/ the numpy spec) to the platform int precision, which jax apparently interprets as 64-bit with 'jax_enable_x64'
set to True
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
rollup.js
rollup.config.js // can be an array (for multiple inputs) export default ... when the primary purpose of the imported code is to muck...
Read more >Recommended minimum requirements for plumbing - GovInfo
The factor of safety in a plumbing system and determination of the upper limit of service for a 3-inch soil stack. 146. Establishment...
Read more >The 5 Best Pressure Washers of 2022 | Reviews by Wirecutter
The Ryobi RY142300 2300 PSI Brushless Electric Pressure Washer is the best pressure washer we found after 70 hours of research and testing....
Read more >Dictionary of Terminology - Nemaplex
Aberrant Deviating from the usual type or form. ... Abyssal Fauna Organisms dwelling at oceanic depths below 6,000 feet, quiet water, complete darkness....
Read more >Glossaries of BLM surveying and mapping terms
The definitions are not meant to conflict with those in other glossaries, but since the glossary is for. BLM cadastral personnel, some terms...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Also bear in mind the accumulator could use a higher precision and still return a downcast matching dtype.
On Thu, May 21, 2020, 12:58 AM Stephan Hoyer notifications@github.com wrote:
Revisiting this… it looks like this is only an issue for integer dtypes:
I think it’s reasonable to make the result type match the input by default: you could always recover the current behavior via explicit casts, but there’s currently no way to make the reduction preserve the input dtype.