question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exponentiation on int32 data with base 0 gives different results when jitted

See original GitHub issue

Example

from jax import numpy as jnp
import jax

EXP_MULTIPLIER = 1


def power(a, b):
    return a**b


a = jnp.int32(0)
b = jnp.int32(EXP_MULTIPLIER * 64)

result = power(a, b)
result_jit = jax.jit(power)(a, b)

assert result == result_jit, f'{result} != {result_jit}'
AssertionError: 0 != 1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jakevdpcommented, Mar 9, 2021

Fix is in #5990

0reactions
jakevdpcommented, Mar 9, 2021

I’ll try to get a fix in this morning.

Read more comments on GitHub >

github_iconTop Results From Across the Web

strange behavior when casting the result float to int
gives the result of 619999980 so (Int32)(6.2f * 10) gives 61. It's different when two Single are multiplied, in that case there is...
Read more >
Compiling Python code with @jit - Numba documentation
int32 (int32, int32) is the function's signature. In this case, the corresponding specialization will be compiled by the @jit decorator, and no other...
Read more >
12.5.1. Exponential and Logarithmic Functions
If the base-number is of type rational and the power-number is an integer, ... If the power-number is a zero of any other...
Read more >
Troubleshooting and tips — Numba 0.50.1 documentation
There can be various reasons why Numba cannot compile your code, and raises an error instead. One common reason is that your code...
Read more >
Basic rules for exponentiation - Math Insight
A brief overview of the basic rules for exponents or powers. ... Here, x is the base and n is the exponent or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found