| 1011 | } |
| 1012 | |
| 1013 | __MATX_INLINE__ auto PermuteImpl(const cuda::std::array<int32_t, RANK> &dims) const |
| 1014 | { |
| 1015 | MATX_NVTX_START("", matx::MATX_NVTX_LOG_API) |
| 1016 | |
| 1017 | static_assert(RANK >= 1, "Only tensors of rank 1 and higher can be permuted."); |
| 1018 | cuda::std::array<shape_type, RANK> n; |
| 1019 | cuda::std::array<stride_type, RANK> s; |
| 1020 | [[maybe_unused]] bool done[RANK] = {0}; |
| 1021 | |
| 1022 | MATX_LOOP_UNROLL |
| 1023 | for (int i = 0; i < RANK; i++) { |
| 1024 | int d = dims[i]; |
| 1025 | MATX_ASSERT_STR(d < RANK, matxInvalidDim, |
| 1026 | "Index to permute is larger than tensor rank"); |
| 1027 | MATX_ASSERT_STR(done[d] == false, matxInvalidParameter, |
| 1028 | "Cannot list the same dimension to permute twice"); |
| 1029 | done[d] = true; |
| 1030 | n[i] = this->Size(d); |
| 1031 | s[i] = this->Stride(d); |
| 1032 | } |
| 1033 | |
| 1034 | return Desc{std::move(n), std::move(s)}; |
| 1035 | } |
| 1036 | |
| 1037 | __MATX_INLINE__ auto Permute(const cuda::std::array<int32_t, RANK> &dims) const |
| 1038 | { |