Debian Codegraph @

packages/kokkos-kernels/batched/dense/impl/KokkosBatched_Gemm_TeamVector_Impl.hpp

raw
1 //@HEADER
2 // ************************************************************************
3 //
4 // Kokkos v. 4.0
5 // Copyright (2022) National Technology & Engineering
6 // Solutions of Sandia, LLC (NTESS).
7 //
8 // Under the terms of Contract DE-NA0003525 with NTESS,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
12 // See https://kokkos.org/LICENSE for license information.
13 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 //
15 //@HEADER
16 #ifndef KOKKOSBATCHED_GEMM_TEAMVECTOR_IMPL_HPP
17 #define KOKKOSBATCHED_GEMM_TEAMVECTOR_IMPL_HPP
18
19 /// \author Kyungjoo Kim ([email protected])
20
21 #include "KokkosBatched_Util.hpp"
22 #include "KokkosBatched_Gemm_TeamVector_Internal.hpp"
23
24 namespace KokkosBatched {
25
26 ///
27 /// Team Impl
28 /// =========
29
30 ///
31 /// Implemented:
32 /// NT/NT, T/NT, NT/T, T/T
33 ///
34 /// Not yet implemented (ConjTranspose)
35 /// CT/NT, NT/CT, CT/CT
36 ///
37
38 ///
39 /// NT/NT
40 ///
41
42 template <typename MemberType>
43 struct TeamVectorGemm<MemberType, Trans::NoTranspose, Trans::NoTranspose, Algo::Gemm::Unblocked> {
44 template <typename ScalarType, typename AViewType, typename BViewType, typename CViewType>
45 KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A,
46 const BViewType &B, const ScalarType beta, const CViewType &C) {
47 // C = beta C + alpha A B
48 // C (m x n), A(m x k), B(k x n)
49 return TeamVectorGemmInternal<Algo::Gemm::Unblocked>::invoke(
50 member, C.extent(0), C.extent(1), A.extent(1), alpha, A.data(), A.stride_0(), A.stride_1(), B.data(),
51 B.stride_0(), B.stride_1(), beta, C.data(), C.stride_0(), C.stride_1());
52 }
53 };
54
55 ///
56 /// T/NT
57 ///
58
59 template <typename MemberType>
60 struct TeamVectorGemm<MemberType, Trans::Transpose, Trans::NoTranspose, Algo::Gemm::Unblocked> {
61 template <typename ScalarType, typename AViewType, typename BViewType, typename CViewType>
62 KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A,
63 const BViewType &B, const ScalarType beta, const CViewType &C) {
64 // C = beta C + alpha A B
65 // C (m x n), A(m x k), B(k x n)
66 return TeamVectorGemmInternal<Algo::Gemm::Unblocked>::invoke(
67 member, C.extent(0), C.extent(1), A.extent(0), alpha, A.data(), A.stride_1(), A.stride_0(), B.data(),
68 B.stride_0(), B.stride_1(), beta, C.data(), C.stride_0(), C.stride_1());
69 }
70 };
71
72 ///
73 /// NT/T
74 ///
75
76 template <typename MemberType>
77 struct TeamVectorGemm<MemberType, Trans::NoTranspose, Trans::Transpose, Algo::Gemm::Unblocked> {
78 template <typename ScalarType, typename AViewType, typename BViewType, typename CViewType>
79 KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A,
80 const BViewType &B, const ScalarType beta, const CViewType &C) {
81 // C = beta C + alpha A B
82 // C (m x n), A(m x k), B(k x n)
83 return TeamVectorGemmInternal<Algo::Gemm::Unblocked>::invoke(
84 member, C.extent(0), C.extent(1), A.extent(1), alpha, A.data(), A.stride_0(), A.stride_1(), B.data(),
85 B.stride_1(), B.stride_0(), beta, C.data(), C.stride_0(), C.stride_1());
86 }
87 };
88
89 ///
90 /// T/T
91 ///
92
93 template <typename MemberType>
94 struct TeamVectorGemm<MemberType, Trans::Transpose, Trans::Transpose, Algo::Gemm::Unblocked> {
95 template <typename ScalarType, typename AViewType, typename BViewType, typename CViewType>
96 KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A,
97 const BViewType &B, const ScalarType beta, const CViewType &C) {
98 // C = beta C + alpha A B
99 // C (m x n), A(m x k), B(k x n)
100 return TeamVectorGemmInternal<Algo::Gemm::Unblocked>::invoke(
101 member, C.extent(0), C.extent(1), A.extent(0), alpha, A.data(), A.stride_1(), A.stride_0(), B.data(),
102 B.stride_1(), B.stride_0(), beta, C.data(), C.stride_0(), C.stride_1());
103 }
104 };
105
106 } // namespace KokkosBatched
107
108 #endif