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

Support ast.IfExp in kernels #500

Open
shi-eric opened this issue Feb 5, 2025 · 0 comments
Open

Support ast.IfExp in kernels #500

shi-eric opened this issue Feb 5, 2025 · 0 comments

Comments

@shi-eric
Copy link
Contributor

shi-eric commented Feb 5, 2025

Kernels should support expressions like out[i] = 1.0 if out[i] < value else -1, e.g.

import warp as wp

wp.init()


@wp.kernel
def threshold(value: float, out: wp.array(dtype=float)):
    i = wp.tid()

    out[i] = 1.0 if out[i] < value else -1


a = wp.ones(10, dtype=float)
wp.launch(threshold, (10,), inputs=[0.5, a])

print(a.numpy())

Currently, the above code yields:

warp.codegen.WarpCodegenError: Error while parsing function "threshold" at /home/eshi/code-projects/warp/ershi-tests/test_single_line.py:10:
    out[i] = 1.0 if out[i] < value else -1
;Construct `ast.IfExp` not supported in kernels.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant