NVIDIA / cutlass

CUDA Templates for Linear Algebra Subroutines
Other
5.21k stars 876 forks source link

[QST] is define CUTE_LEFT_UNARY_OP right? #1431

Closed shanliang1992 closed 3 weeks ago

shanliang1992 commented 4 months ago

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 commented 4 months ago

@thakkarV

ccecka commented 4 months ago

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);
}
github-actions[bot] commented 2 months ago

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.