Skip to content
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

[BUG] from __future__ import annotations breaks warp #256

Closed
koen-v opened this issue Jul 5, 2024 · 3 comments
Closed

[BUG] from __future__ import annotations breaks warp #256

koen-v opened this issue Jul 5, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@koen-v
Copy link

koen-v commented Jul 5, 2024

Bug Description

When I add
from __future__ import annotations

to a warp script, the kernel wont compile, the first thing I hit is in:
python\warp\types.py

;'str' object has no attribute '__module__'

removing the annotations import makes it go away

Thanks,
Koen

System Information

Windows 11, Python 3.10

@koen-v koen-v added the bug Something isn't working label Jul 5, 2024
@shi-eric
Copy link
Contributor

shi-eric commented Jul 5, 2024

A quick look at the issue shows that the type annotations get turned into strings with from __future__ import annotations (postponed evaluation of annotations), which interferes with the Warp Var.type variables created for the kernel parameters. Here's a minimal example :

from __future__ import annotations

import warp as wp

wp.init()


@wp.kernel
def test_kernel(a: wp.array(dtype=wp.float32)):
    i = wp.tid()


test_array = wp.empty(shape=(10,), dtype=wp.float32)

wp.launch(test_kernel, test_array.shape, inputs=[test_array])

wp.synchronize()

@christophercrouzet: Can you look into if we can support this use case?

@christophercrouzet
Copy link
Member

Hi @koen-v, thanks for reporting this issue!

We've just merged some changes in e10a583 to add support for from __future__ import annotations. It's available in the branch main for now and will be part of the next release.

@koen-v
Copy link
Author

koen-v commented Jul 15, 2024

great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants