aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/CXX11/src/Tensor/TensorSyclPlaceHolder.h
blob: 87995a25e980641e773c467f433a43976db2a381 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Mehdi Goli    Codeplay Software Ltd.
// Ralph Potter  Codeplay Software Ltd.
// Luke Iwanski  Codeplay Software Ltd.
// Contact: <eigen@codeplay.com>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

/*****************************************************************
 * TensorSyclPlaceHolder.h
 *
 * \brief:
 *  The PlaceHolder expression are nothing but a container preserving
 *  the order of actual data in the tuple of sycl buffer.
 *
*****************************************************************/

#ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSORYSYCL_PLACEHOLDER_HPP
#define UNSUPPORTED_EIGEN_CXX11_SRC_TENSORYSYCL_PLACEHOLDER_HPP

namespace Eigen {
namespace internal {
/// \struct PlaceHolder
/// \brief PlaceHolder is used to replace the \ref TensorMap in the expression
/// tree.
/// PlaceHolder contains the order of the leaf node in the expression tree.
template <typename Scalar, size_t N>
struct PlaceHolder {
  static constexpr size_t I = N;
  using Type = Scalar;
};

template <typename PlainObjectType, int Options_,
          template <class> class MakePointer_, size_t N>
struct PlaceHolder<const TensorMap<PlainObjectType, Options_, MakePointer_>,
                   N> {
  static constexpr size_t I = N;

  using Type = const TensorMap<PlainObjectType, Options_, MakePointer_>;

  typedef typename Type::Self Self;
  typedef typename Type::Base Base;
  typedef typename Type::Nested Nested;
  typedef typename Type::StorageKind StorageKind;
  typedef typename Type::Index Index;
  typedef typename Type::Scalar Scalar;
  typedef typename Type::RealScalar RealScalar;
  typedef typename Type::CoeffReturnType CoeffReturnType;
};

/// \brief specialisation of the PlaceHolder node for TensorForcedEvalOp. The
/// TensorForcedEvalOp act as a leaf node for its parent node.
template <typename Expression, size_t N>
struct PlaceHolder<const TensorForcedEvalOp<Expression>, N> {
  static constexpr size_t I = N;

  using Type = const TensorForcedEvalOp<Expression>;

  typedef typename Type::Nested Nested;
  typedef typename Type::StorageKind StorageKind;
  typedef typename Type::Index Index;

  typedef typename Type::Scalar Scalar;
  typedef typename Type::Packet Packet;

  typedef typename Type::RealScalar RealScalar;
  typedef typename Type::CoeffReturnType CoeffReturnType;
  typedef typename Type::PacketReturnType PacketReturnType;
};

template <typename Expression, size_t N>
struct PlaceHolder<TensorForcedEvalOp<Expression>, N> {
  static constexpr size_t I = N;

  using Type = TensorForcedEvalOp<Expression>;

  typedef typename Type::Nested Nested;
  typedef typename Type::StorageKind StorageKind;
  typedef typename Type::Index Index;

  typedef typename Type::Scalar Scalar;
  typedef typename Type::Packet Packet;

  typedef typename Type::RealScalar RealScalar;
  typedef typename Type::CoeffReturnType CoeffReturnType;
  typedef typename Type::PacketReturnType PacketReturnType;
};

/// \brief specialisation of the PlaceHolder node for const TensorMap
template <typename PlainObjectType, int Options_,
          template <class> class Makepointer_, size_t N>
struct PlaceHolder<TensorMap<PlainObjectType, Options_, Makepointer_>, N> {
  static constexpr size_t I = N;

  using Type = TensorMap<PlainObjectType, Options_, Makepointer_>;

  typedef typename Type::Self Self;
  typedef typename Type::Base Base;
  typedef typename Type::Nested Nested;
  typedef typename Type::StorageKind StorageKind;
  typedef typename Type::Index Index;
  typedef typename Type::Scalar Scalar;
  typedef typename Type::Packet Packet;
  typedef typename Type::RealScalar RealScalar;
  typedef typename Type::CoeffReturnType CoeffReturnType;
  typedef typename Base::PacketReturnType PacketReturnType;
};

/// specialisation of the traits struct for PlaceHolder
template <typename PlainObjectType, int Options_,
          template <class> class Makepointer_, size_t N>
struct traits<
    PlaceHolder<TensorMap<PlainObjectType, Options_, Makepointer_>, N>>
    : public traits<PlainObjectType> {
  typedef traits<PlainObjectType> BaseTraits;
  typedef typename BaseTraits::Scalar Scalar;
  typedef typename BaseTraits::StorageKind StorageKind;
  typedef typename BaseTraits::Index Index;
  static const int NumDimensions = BaseTraits::NumDimensions;
  static const int Layout = BaseTraits::Layout;
  enum {
    Options = Options_,
    Flags = BaseTraits::Flags,
  };
};

template <typename PlainObjectType, int Options_,
          template <class> class Makepointer_, size_t N>
struct traits<
    PlaceHolder<const TensorMap<PlainObjectType, Options_, Makepointer_>, N>>
    : public traits<PlainObjectType> {
  typedef traits<PlainObjectType> BaseTraits;
  typedef typename BaseTraits::Scalar Scalar;
  typedef typename BaseTraits::StorageKind StorageKind;
  typedef typename BaseTraits::Index Index;
  static const int NumDimensions = BaseTraits::NumDimensions;
  static const int Layout = BaseTraits::Layout;
  enum {
    Options = Options_,
    Flags = BaseTraits::Flags,
  };
};

}  // end namespoace internal
}  // end namespoace Eigen

#endif  // UNSUPPORTED_EIGEN_CXX11_SRC_TENSORYSYCL_PLACEHOLDER_HPP