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
A case where I found a possible bug with drjit Loop feature:
importdrjitasdrfromdrjit.llvm.adimportUInt, Float, Loopdeff(x): # returns x + 0 + 1 + ... + 9i=UInt(0)
loop=Loop("Loop", lambda: (x, i))
whileloop(i<10):
x=x+ii+=1returnxa=dr.zeros(Float, 10)
dr.make_opaque(a)
a_old_index=a.indexprint(f'{a.index=}, {a}')
b=f(a)
print(f'{b.index=}, {b}')
assertdr.allclose(b, [45] *10)
asserta.index!=a_old_index# drjit.loop seems to change the index of the captured variable to that of a placeholderprint(f'{a.index=}, {a}') # runtime error: a is the placeholder, which cannot be evaluated
Adding a copy in the first line of def f(x): solves this issue, but it just appears strange to me that after instantiating Loop, the original jit variable becomes a placeholder without any notice.
The text was updated successfully, but these errors were encountered:
This is a well understood issue of the current implementation of Dr.Jit symbolic loops. So far we have always assumed that the loop state variables wouldn't be referenced elsewhere (e.g. otherwise would be copied).
In the future we might change the API of dr.Loop to make this assumption for explicit.
In this specific example you expect a == b, in which case it would make more sense to do a = f(a). Otherwise adding x = Float(x) before the loop initialization will also ensure that you don't end up with a placeholder variable in a.
Let's keep it open as it is an important issue and should be fixed in the future somehow.
A case where I found a possible bug with drjit Loop feature:
Adding a copy in the first line of
def f(x):
solves this issue, but it just appears strange to me that after instantiatingLoop
, the original jit variable becomes a placeholder without any notice.The text was updated successfully, but these errors were encountered: