![]() |
Eigen-unsupported
3.3.3
|
00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Mehdi Goli Codeplay Software Ltd. 00005 // Ralph Potter Codeplay Software Ltd. 00006 // Luke Iwanski Codeplay Software Ltd. 00007 // Contact: <eigen@codeplay.com> 00008 // 00009 // This Source Code Form is subject to the terms of the Mozilla 00010 // Public License v. 2.0. If a copy of the MPL was not distributed 00011 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 00012 00013 /***************************************************************** 00014 * TensorSyclPlaceHolderExpr.h 00015 * 00016 * \brief: 00017 * This is the specialisation of the placeholder expression based on the 00018 * operation type 00019 * 00020 *****************************************************************/ 00021 00022 #ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_PLACEHOLDER_EXPR_HPP 00023 #define UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_PLACEHOLDER_EXPR_HPP 00024 00025 namespace Eigen { 00026 namespace TensorSycl { 00027 namespace internal { 00028 00033 template <typename Scalar, size_t N> 00034 struct PlaceHolder { 00035 static constexpr size_t I = N; 00036 typedef Scalar Type; 00037 }; 00038 00043 template <typename Expr, size_t N> 00044 struct PlaceHolderExpression; 00045 00046 template<size_t N, typename... Args> 00047 struct CalculateIndex; 00048 00049 template<size_t N, typename Arg> 00050 struct CalculateIndex<N, Arg>{ 00051 typedef typename PlaceHolderExpression<Arg, N>::Type ArgType; 00052 typedef utility::tuple::Tuple<ArgType> ArgsTuple; 00053 }; 00054 00055 template<size_t N, typename Arg1, typename Arg2> 00056 struct CalculateIndex<N, Arg1, Arg2>{ 00057 static const size_t Arg2LeafCount = LeafCount<Arg2>::Count; 00058 typedef typename PlaceHolderExpression<Arg1, N - Arg2LeafCount>::Type Arg1Type; 00059 typedef typename PlaceHolderExpression<Arg2, N>::Type Arg2Type; 00060 typedef utility::tuple::Tuple<Arg1Type, Arg2Type> ArgsTuple; 00061 }; 00062 00063 template<size_t N, typename Arg1, typename Arg2, typename Arg3> 00064 struct CalculateIndex<N, Arg1, Arg2, Arg3> { 00065 static const size_t Arg3LeafCount = LeafCount<Arg3>::Count; 00066 static const size_t Arg2LeafCount = LeafCount<Arg2>::Count; 00067 typedef typename PlaceHolderExpression<Arg1, N - Arg3LeafCount - Arg2LeafCount>::Type Arg1Type; 00068 typedef typename PlaceHolderExpression<Arg2, N - Arg3LeafCount>::Type Arg2Type; 00069 typedef typename PlaceHolderExpression<Arg3, N>::Type Arg3Type; 00070 typedef utility::tuple::Tuple<Arg1Type, Arg2Type, Arg3Type> ArgsTuple; 00071 }; 00072 00073 template<template<class...> class Category , class OP, class TPL> 00074 struct CategoryHelper; 00075 00076 template<template<class...> class Category , class OP, class ...T > 00077 struct CategoryHelper<Category, OP, utility::tuple::Tuple<T...> > { 00078 typedef Category<OP, T... > Type; 00079 }; 00080 00081 template<template<class...> class Category , class ...T > 00082 struct CategoryHelper<Category, NoOP, utility::tuple::Tuple<T...> > { 00083 typedef Category<T... > Type; 00084 }; 00085 00088 #define OPEXPRCATEGORY(CVQual)\ 00089 template <template <class, class... > class Category, typename OP, typename... SubExpr, size_t N>\ 00090 struct PlaceHolderExpression<CVQual Category<OP, SubExpr...>, N>{\ 00091 typedef CVQual typename CategoryHelper<Category, OP, typename CalculateIndex<N, SubExpr...>::ArgsTuple>::Type Type;\ 00092 }; 00093 00094 OPEXPRCATEGORY(const) 00095 OPEXPRCATEGORY() 00096 #undef OPEXPRCATEGORY 00097 00100 #define SELECTEXPR(CVQual)\ 00101 template <typename IfExpr, typename ThenExpr, typename ElseExpr, size_t N>\ 00102 struct PlaceHolderExpression<CVQual TensorSelectOp<IfExpr, ThenExpr, ElseExpr>, N> {\ 00103 typedef CVQual typename CategoryHelper<TensorSelectOp, NoOP, typename CalculateIndex<N, IfExpr, ThenExpr, ElseExpr>::ArgsTuple>::Type Type;\ 00104 }; 00105 00106 SELECTEXPR(const) 00107 SELECTEXPR() 00108 #undef SELECTEXPR 00109 00112 #define ASSIGNEXPR(CVQual)\ 00113 template <typename LHSExpr, typename RHSExpr, size_t N>\ 00114 struct PlaceHolderExpression<CVQual TensorAssignOp<LHSExpr, RHSExpr>, N> {\ 00115 typedef CVQual typename CategoryHelper<TensorAssignOp, NoOP, typename CalculateIndex<N, LHSExpr, RHSExpr>::ArgsTuple>::Type Type;\ 00116 }; 00117 00118 ASSIGNEXPR(const) 00119 ASSIGNEXPR() 00120 #undef ASSIGNEXPR 00121 00124 #define TENSORMAPEXPR(CVQual)\ 00125 template <typename Scalar_, int Options_, int Options2_, int NumIndices_, typename IndexType_, template <class> class MakePointer_, size_t N>\ 00126 struct PlaceHolderExpression< CVQual TensorMap< Tensor<Scalar_, NumIndices_, Options_, IndexType_>, Options2_, MakePointer_>, N> {\ 00127 typedef CVQual PlaceHolder<CVQual TensorMap<Tensor<Scalar_, NumIndices_, Options_, IndexType_>, Options2_, MakePointer_>, N> Type;\ 00128 }; 00129 00130 TENSORMAPEXPR(const) 00131 TENSORMAPEXPR() 00132 #undef TENSORMAPEXPR 00133 00136 #define FORCEDEVAL(CVQual)\ 00137 template <typename Expr, size_t N>\ 00138 struct PlaceHolderExpression<CVQual TensorForcedEvalOp<Expr>, N> {\ 00139 typedef CVQual PlaceHolder<CVQual TensorForcedEvalOp<Expr>, N> Type;\ 00140 }; 00141 00142 FORCEDEVAL(const) 00143 FORCEDEVAL() 00144 #undef FORCEDEVAL 00145 00148 #define EVALTO(CVQual)\ 00149 template <typename Expr, size_t N>\ 00150 struct PlaceHolderExpression<CVQual TensorEvalToOp<Expr>, N> {\ 00151 typedef CVQual TensorEvalToOp<typename CalculateIndex <N, Expr>::ArgType> Type;\ 00152 }; 00153 00154 EVALTO(const) 00155 EVALTO() 00156 #undef EVALTO 00157 00158 00161 #define SYCLREDUCTION(CVQual)\ 00162 template <typename OP, typename Dims, typename Expr, size_t N>\ 00163 struct PlaceHolderExpression<CVQual TensorReductionOp<OP, Dims, Expr>, N>{\ 00164 typedef CVQual PlaceHolder<CVQual TensorReductionOp<OP, Dims,Expr>, N> Type;\ 00165 }; 00166 SYCLREDUCTION(const) 00167 SYCLREDUCTION() 00168 #undef SYCLREDUCTION 00169 00171 template <typename Expr> 00172 struct createPlaceHolderExpression { 00173 static const size_t TotalLeaves = LeafCount<Expr>::Count; 00174 typedef typename PlaceHolderExpression<Expr, TotalLeaves - 1>::Type Type; 00175 }; 00176 00177 } // internal 00178 } // TensorSycl 00179 } // namespace Eigen 00180 00181 #endif // UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_PLACEHOLDER_EXPR_HPP