-
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] User-friendly exception when copying between ti.field #3442
Conversation
✔️ Deploy Preview for jovial-fermat-aa59dc canceled. 🔨 Explore the source changes: 97b7826 🔍 Inspect the deploy log: https://app.netlify.com/sites/jovial-fermat-aa59dc/deploys/61bec90737e4e80007b63a60 |
/format |
/format |
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.
cc: @ljjsalt the test failures on GPU seem related?
tests/python/test_field.py
Outdated
@ti.test() | ||
@pytest.mark.parametrize('shape', field_shapes) | ||
def test_field_copy_from(shape): | ||
shapes = [ti.i32, ti.f32] # Metal kernel only supports <= 32-bit data |
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.
name shape
doesn't match what's inside the array :P
Using parameterize for dtype should work and pass CI :D
+@ti.test()
+@pytest.mark.parametrize('shape', field_shapes)
+@pytest.mark.parametrize('dtype', [ti.i32, ti.f32])
+def test_field_copy_from(shape, dtype):
+ x = ti.field(dtype=ti.f32, shape=shape)
+ other = ti.field(dtype=dtype, shape=shape)
+ other.fill(1)
+ x.copy_from(other)
+ convert = lambda arr: arr[0] if len(arr) == 1 else arr
+ assert (convert(x.shape) == shape)
+ assert (x.dtype == ti.f32)
+ assert ((x.to_numpy() == 1).all())
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.
@ailzhang
Hi, I finally have time to keep working on this PR, how can I test locally? I have run the pytest script.
Sorry for taking you so long for this PR, this commit should work.
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.
LGTM! Thanks a lot for contributing!
Related issue = #2846
Test 0
Result 0
Test 1
Result 1