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.

`jnp.floor_divide()` returns incorrect results when used with `scan`

See original GitHub issue
import jax
from jax import lax
import jax.numpy as jnp

x = jnp.array([2, 2, -3])

def reduce_for_loop(func, arr):
  val = arr[0]
  for i in range(1, len(arr)):
    val = func(val, arr[i])
  return val

def reduce_scan(func, arr):
  val = arr[0]
  body_func = lambda i, val: func(val, arr[i])
  return lax.fori_loop(1, len(arr), body_func, val)

print(reduce_for_loop(jnp.floor_divide, x)) # prints -1
print(reduce_scan(jnp.floor_divide, x))     # prints 0
with jax.disable_jit():
  print(reduce_scan(jnp.floor_divide, x))   # prints -1

Came up when working on #9529

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
chsiggcommented, Jun 7, 2022
0reactions
jakevdpcommented, Jun 29, 2022

Looks like this is fixed in the jaxlib 0.3.14 release

Read more comments on GitHub >

github_iconTop Results From Across the Web

Printf is returning with wrong numbers inputted from scanf
A similar thing happens when a character is inputted, only the printf function displays a square instead. Is there a problem with the...
Read more >
scanf() — Read Data - IBM
The scanf() function reads data from the standard input stream stdin into the locations given by each entry in argument-list.
Read more >
Psychotropic and neurotropic activity1 | SpringerLink
Nikodijevic et al. (1991) studied the behavioral effects of A1- and A2-selective adenosine agonists and antagonists in mice using a Digiscan activity ...
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