-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lang] [refactor] deprecate @boardcast_if_scalar, all use @binary and @unary #943
Conversation
Why fail? |
I found why: cannot self assign. If I change to |
Have to sleep to prevent a class drop, I believe CI will pass and you will like these changes, cutmr. ========================================= FAILURES ==========================================
_______________________________________ test_pow_i32 ________________________________________
[gw2] linux -- Python 3.8.2 /usr/bin/python3
@ti.all_archs
def test_pow_i32():
> _test_pow_i(ti.i32)
tests/python/test_pow.py:43:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dt = DataType.int32
def _test_pow_i(dt):
z = ti.var(dt, shape=())
@ti.kernel
def func(x: dt, y: ti.template()):
z[None] = x**y
for x in range(-5, 5):
for y in range(0, 4):
func(x, y)
> assert z[None] == x**y
E assert 124 == -125
E -124
E +-125
tests/python/test_pow.py:27: AssertionError
=============================== 1 failed, 3 passed in 10.05s ================================ Will fix tmr. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general! Just some minor issues.
tests/python/test_element_wise.py
Outdated
@@ -12,7 +13,7 @@ def rand(dtype): | |||
if ti.core.is_integral(dtype): | |||
return randint(1, 5) | |||
else: | |||
return float(randint(1, 5)) / 5 | |||
return float(randint(1, 5)) / 5 - 0.01 # prevent floordiv step |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what this means...sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because GLSL doesn't provide pow(int, int)
, it only provide pow(float, float)
, so:
pow(4.999, 3) = 124
pow(5.001, 3) = 125
And due to binary floating-point problems, 5
becames 4.99
, therefore:
pow(5, 4) = 124
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. (Btw should the comment be something like "prevent integer operands in pow in GLSL")?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's the same case with floordiv... let's say prevent integer operands in pow and floordiv in GLSL
then.
Co-authored-by: Yuanming Hu <yuanming-hu@users.noreply.github.com>
@k-ye I'm merging this now to prevent further conflict. Please try this out when you are free. |
I can confirm that |
Related issue = #937 (comment)
[Click here for the format server]