Fix sizes of literals in frozen functions#499
Conversation
|
Hi @dvicini, Sorry for the delayed response. import drjit as dr
Float = dr.llvm.Float
def func(x):
fixed = dr.ones(Float, 3)
return fixed
frozen = dr.freeze(func)
# Recording: x=3, literal=3 -> same size class
x = Float([1, 2, 3])
res = frozen(x)
ref = func(x)
print(f"record: res_w={dr.width(res)} ref_w={dr.width(ref)}")
# Replay: x=5 -> literal should stay 3, not become 5
x2 = Float([1, 2, 3, 4, 5])
res2 = frozen(x2)
ref2 = func(x2)
print(f"replay: res_w={dr.width(res2)} ref_w={dr.width(ref2)} PASS={dr.width(res2)==dr.width(ref2)}")Because we fundamentally loose the information about input-output relations, for literals, we could decide for one or the other approach. I'm fine with it either way (not sure what causes more confusion)? I tested your implementation for performance. The fix introduces a bunch of hash-set lookups for literals, which make up the largest part of the variables in most scenes. It it seems fine (slight regression on bistro scene, but within noise for my tests): (measured by profiling 10 times). Best |
|
Hi Christian, I see, the size suddenly becoming "5" in your example also seems very confusing. My fix was purely AI generated, so there is no need to use it as is, if it's not the best solution. Isn't it somehow possible in this test to ensure that the literal stays of the size 3, at which it was explicitly created? I am not too concerned about the performance hit, as long as we can get correct behavior for various versions of this test. |
This addresses #498
This fix was AI generated, so it needs careful review. The core ideas seem reasonable, but I am not aware of possible pitfalls.