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 · 3 comments
Open

[QST] is define CUTE_LEFT_UNARY_OP right? #1431

shanliang1992 opened this issue Mar 27, 2024 · 3 comments

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);
}

Copy link

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

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

No branches or pull requests

4 participants