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

Propagate constexpr through tl.minimum and tl.maximum? #3815

Open
blaine-rister opened this issue May 2, 2024 · 0 comments
Open

Propagate constexpr through tl.minimum and tl.maximum? #3815

blaine-rister opened this issue May 2, 2024 · 0 comments

Comments

@blaine-rister
Copy link

blaine-rister commented May 2, 2024

I noticed that tl.minimum and tl.maximum do not seem to propagate constexprs.
https://github.com/openai/triton/blob/22af8d80458ee4e6269779dae0a3c34b755aade2/python/triton/language/core.py#L569

Would it be feasible to add this functionality? I'm guessing it would be possible to check if both args are constexpr in the function's implementation.

This could be useful for performing more advanced reshaping operations in TorchInductor. We would like to convert 1D tensor shape into an ND one, which could be expressed with tl.minimum. However, calling tl.minimum seems to drop the constexpr property of its inputs. See pytorch/pytorch#125077 for some additional context.

As an alternative, there might be a way to support similar functionality in constexprs using python builtins, such as min(x,y) = x * (x <= y) + y * (y < x). But tl.minimum(x,y) would be more concise.

@blaine-rister blaine-rister changed the title Add tl.minimum and tl.maximum to constexpr? Propagate constexpr through tl.minimum and tl.maximum? May 2, 2024
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