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
importluisaluisa.init('cuda')
@luisa.funcdeff():
ifdispatch_id().x==999:
a=0else:
a=0.5print('a:', a)
f(dispatch_size=1)
Result:
a: 0
While the expected result is 0.5.
Change the condition to False and result will become a: 0.5
Above code crashes when using cpu backend instead:
thread '<unnamed>' panicked at 'index out of bounds: the len is 5 but the index is 5', luisa_compute_backend_impl/src/cpu/codegen/cpp.rs:1799:16
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
terminate called without an active exception
The text was updated successfully, but these errors were encountered:
The type of a variable is decided at its first occurrence so
ifdispatch_id().x==999:
a=0else:
a=0.5
leads to an int-typed a (as initialized by int(0)).
On the other hand, we perform some basic control flow simplification, so if you change the condition to a constant False, the above code folds to the unbranched version
a=0.5
where a now is initialized by a float(0.5).
You may solve such inconsistence by either changing 0 to 0.0 or explicitly type a as float aforehand:
importluisaluisa.init('cuda')
@luisa.funcdeff():
a=float()
ifdispatch_id().x==999:
a=0else:
a=0.5print('a:', a)
f(dispatch_size=1)
Above code crashes when using cpu backend instead:
thread '<unnamed>' panicked at 'index out of bounds: the len is 5 but the index is 5', luisa_compute_backend_impl/src/cpu/codegen/cpp.rs:1799:16
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
terminate called without an active exception
This should have been fixed in new luisa-python releases. Please upgrade with the following command:
Result:
While the expected result is
0.5
.Change the condition to
False
and result will becomea: 0.5
Above code crashes when using
cpu
backend instead:The text was updated successfully, but these errors were encountered: