Home | History | Annotate | Download | only in Tensor

Lines Matching defs:Tuple

17  *  Minimal implementation of std::tuple that can be used inside a SYCL kernel.
24 namespace tuple {
35 /// \struct Tuple
37 /// \ztparam Ts... - the types of the elements that the tuple stores.
40 struct Tuple {};
42 /// \brief specialisation of the \ref Tuple class when the tuple has at least
44 /// \tparam T : the type of the first element in the tuple.
45 /// \tparam Ts... the rest of the elements in the tuple. Ts... can be empty.
47 struct Tuple<T, Ts...> {
48 Tuple(T t, Ts... ts) : head(t), tail(ts...) {}
50 Tuple<Ts...> tail;
55 /// elements inside the tuple
56 /// \tparam size_t the number of elements inside the tuple
57 /// \tparam class the tuple class
62 /// elements inside the tuple is 1
64 struct ElemTypeHolder<0, Tuple<T, Ts...> > {
69 /// elements inside the tuple is bigger than 1. It recursively calls itself to
70 /// detect the type of each element in the tuple
71 /// \tparam T : the type of the first element in the tuple.
72 /// \tparam Ts... the rest of the elements in the tuple. Ts... can be empty.
73 /// \tparam K is the Kth element in the tuple
75 struct ElemTypeHolder<k, Tuple<T, Ts...> > {
76 typedef typename ElemTypeHolder<k - 1, Tuple<Ts...> >::type type;
80 /// \brief Extracts the first element from the tuple.
81 /// K=0 represents the first element of the tuple. The tuple cannot be empty.
82 /// \tparam Ts... are the type of the elements in the tuple.
83 /// \param t is the tuple whose contents to extract
84 /// \return typename ElemTypeHolder<0, Tuple<Ts...> >::type &>::type
88 typename StaticIf<k == 0, CVQual typename ElemTypeHolder<0, Tuple<Ts...> >::type &>::type \
89 get(CVQual Tuple<Ts...> &t) { \
90 static_assert(sizeof...(Ts)!=0, "The requseted value is bigger than the size of the tuple"); \
98 /// \brief Extracts the Kth element from the tuple.
100 /// \tparam T is the (sizeof...(Types) -(K+1)) element in the tuple
101 /// \tparam Ts... are the type of the elements in the tuple.
102 /// \param t is the tuple whose contents to extract
103 /// \return typename ElemTypeHolder<K, Tuple<Ts...> >::type &>::type
106 typename StaticIf<k != 0, CVQual typename ElemTypeHolder<k, Tuple<T, Ts...> >::type &>::type \
107 get(CVQual Tuple<T, Ts...> &t) { \
108 return utility::tuple::get<k - 1>(t.tail); \
115 /// \brief Creates a tuple object, deducing the target type from the types of
117 /// \tparam Args the type of the arguments to construct the tuple from
118 /// \param args zero or more arguments to construct the tuple from
119 /// \return Tuple<Args...>
121 Tuple<Args...> make_tuple(Args... args) {
122 return Tuple<Args...>(args...);
126 /// \brief Provides access to the number of elements in a tuple as a
128 /// \tparam Args the type of the arguments to construct the tuple from
131 static constexpr size_t size(Tuple<Args...> &) {
136 /// \brief Creates a list of index from the elements in the tuple
137 /// \tparam Is... a list of index from [0 to sizeof...(tuple elements))
144 /// \tparam MIN is the starting index in the tuple
151 /// MIN==MAX. In this case the Is... is [0 to sizeof...(tuple elements))
152 /// \tparam MIN is the starting index of the tuple
153 /// \tparam Is is [0 to sizeof...(tuple elements))
162 /// \tparam MIN is the starting index in the tuple
169 /// \tparam MIN is the starting index in the tuple
170 /// \tparam MAX is the size of the tuple
175 /// \brief unpacking the elements of the input tuple t and creating a new tuple
177 ///\tparam Args... the type of the elements inside the tuple t
178 /// \tparam T the type of the new element going to be added at the end of tuple
180 /// \param t the tuple on which we want to append a.
181 /// \param a the new elements going to be added to the tuple
182 /// \return Tuple<Args..., T>
184 Tuple<Args..., T> append_base(Tuple<Args...> t, T a,IndexList<I...>) {
185 return utility::tuple::make_tuple(get<I>(t)..., a);
191 ///\tparam Args... the type of the elements inside the tuple t
192 /// \tparam T the type of the new element going to be added at the end of tuple
193 /// \param t the tuple on which we want to append a.
194 /// \param a the new elements going to be added to the tuple
195 /// \return Tuple<Args..., T>
197 Tuple<Args..., T> append(Tuple<Args...> t, T a) {
198 return utility::tuple::append_base(t, a, IndexRange<0, sizeof...(Args)>());
204 /// tuple t2 at the end of the tuple t1. Here we unpack both tuples, generate the
205 /// IndexRange for each of them and create an output tuple T that contains both
207 ///\tparam Args1... the type of the elements inside the tuple t1
208 ///\tparam Args2... the type of the elements inside the tuple t2
211 /// \param t1 is the tuple on which we want to append t2.
212 /// \param t2 is the tuple that is going to be added on t1.
213 /// \return Tuple<Args1..., Args2...>
215 Tuple<Args1..., Args2...> append_base(Tuple<Args1...> t1, Tuple<Args2...> t2, IndexList<I1...>, IndexList<I2...>) {
216 return utility::tuple::make_tuple(get<I1>(t1)...,get<I2>(t2)...);
220 /// \brief deduction function for \ref append_base when we are appending tuple
221 /// t1 by tuple t2. In this case the \ref IndexRange for both tuple are
223 ///\tparam Args1... the type of the elements inside the tuple t1
224 ///\tparam Args2... the type of the elements inside the tuple t2
225 /// \param t1 is the tuple on which we want to append t2.
226 /// \param t2 is the tuple that is going to be added on t1.
227 /// \return Tuple<Args1..., Args2...>
229 Tuple<Args1..., Args2...> append(Tuple<Args1...> t1,Tuple<Args2...> t2) {
230 return utility::tuple::append_base(t1, t2, IndexRange<0, sizeof...(Args1)>(), IndexRange<0, sizeof...(Args2)>());
232 } // tuple