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

[QST] is define CUTE_LEFT_UNARY_OP right? #1431

Open
shanliang1992 opened this issue Mar 27, 2024 · 2 comments
Open

[QST] is define CUTE_LEFT_UNARY_OP right? #1431

shanliang1992 opened this issue Mar 27, 2024 · 2 comments
Labels
question Question

Comments

@shanliang1992
Copy link

in include/cute/numeric/integral_constant.hpp

#define CUTE_LEFT_UNARY_OP(OP)                                                                                         \
    template <auto t> CUTE_HOST_DEVICE constexpr C<(OP t)> operator OP(C<t>) { return {}; }

CUTE_LEFT_UNARY_OP(+);
CUTE_LEFT_UNARY_OP(-);
CUTE_LEFT_UNARY_OP(~);
CUTE_LEFT_UNARY_OP(!);
CUTE_LEFT_UNARY_OP(*);

how to use <* t> in template?

constexpr auto mul_five = C<* 5>{};
is not correct.

@hwu36
Copy link
Collaborator

hwu36 commented Apr 18, 2024

@thakkarV

@ccecka
Copy link

ccecka commented Apr 18, 2024

This is not a multiplication operator, this is a unary dereference operator.

Although it is not likely used (yet), pointers can be constexpr as well.

#include <cute/tensor.hpp>
using namespace cute;

int main()
{
  static constexpr int a[] = {4,3,2,1};
  auto cute_ptr = C<a>{};
  auto cute_val = *cute_ptr;
  static_assert(cute_val == 4);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question
Projects
None yet
Development

No branches or pull requests

4 participants