12b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang// This file is part of Eigen, a lightweight C++ template library 22b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang// for linear algebra. 32b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang// 42b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang// Mehdi Goli Codeplay Software Ltd. 52b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang// Ralph Potter Codeplay Software Ltd. 62b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang// Luke Iwanski Codeplay Software Ltd. 72b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang// Contact: <eigen@codeplay.com> 82b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang// 92b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang// This Source Code Form is subject to the terms of the Mozilla 102b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang// Public License v. 2.0. If a copy of the MPL was not distributed 112b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 122b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 132b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/***************************************************************** 142b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang * TensorSyclLeafCount.h 152b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang * 162b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang * \brief: 172b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang * The leaf count used the pre-order expression tree traverse in order to name 182b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang * count the number of leaf nodes in the expression 192b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang * 202b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang*****************************************************************/ 212b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 222b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang#ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_LEAF_COUNT_HPP 232b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang#define UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_LEAF_COUNT_HPP 242b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 252b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangnamespace Eigen { 262b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangnamespace TensorSycl { 272b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangnamespace internal { 282b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// \brief LeafCount used to counting terminal nodes. The total number of 292b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// leaf nodes is used by MakePlaceHolderExprHelper to find the order 302b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// of the leaf node in a expression tree at compile time. 312b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <typename Expr> 322b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount; 332b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 342b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate<typename... Args> struct CategoryCount; 352b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 362b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate<> struct CategoryCount<> 372b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang{ 382b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang static const size_t Count =0; 392b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang}; 402b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 412b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate<typename Arg, typename... Args> 422b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct CategoryCount<Arg,Args...>{ 432b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang static const size_t Count = LeafCount<Arg>::Count + CategoryCount<Args...>::Count; 442b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang}; 452b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 462b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// specialisation of the \ref LeafCount struct when the node type is const TensorMap 472b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <typename PlainObjectType, int Options_, template <class> class MakePointer_> 482b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<const TensorMap<PlainObjectType, Options_, MakePointer_> > { 492b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang static const size_t Count =1; 502b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang}; 512b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 522b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// specialisation of the \ref LeafCount struct when the node type is TensorMap 532b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <typename PlainObjectType, int Options_, template <class> class MakePointer_> 542b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<TensorMap<PlainObjectType, Options_, MakePointer_> > :LeafCount<const TensorMap<PlainObjectType, Options_, MakePointer_> >{}; 552b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 562b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang// const TensorCwiseUnaryOp, const TensorCwiseNullaryOp, const TensorCwiseBinaryOp, const TensorCwiseTernaryOp, and Const TensorBroadcastingOp 572b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <template <class, class...> class CategoryExpr, typename OP, typename... RHSExpr> 582b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<const CategoryExpr<OP, RHSExpr...> >: CategoryCount<RHSExpr...> {}; 592b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang// TensorCwiseUnaryOp, TensorCwiseNullaryOp, TensorCwiseBinaryOp, TensorCwiseTernaryOp, and TensorBroadcastingOp 602b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <template <class, class...> class CategoryExpr, typename OP, typename... RHSExpr> 612b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<CategoryExpr<OP, RHSExpr...> > :LeafCount<const CategoryExpr<OP, RHSExpr...> >{}; 622b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 632b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// specialisation of the \ref LeafCount struct when the node type is const TensorSelectOp is an exception 642b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <typename IfExpr, typename ThenExpr, typename ElseExpr> 652b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<const TensorSelectOp<IfExpr, ThenExpr, ElseExpr> > : CategoryCount<IfExpr, ThenExpr, ElseExpr> {}; 662b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// specialisation of the \ref LeafCount struct when the node type is TensorSelectOp 672b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <typename IfExpr, typename ThenExpr, typename ElseExpr> 682b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<TensorSelectOp<IfExpr, ThenExpr, ElseExpr> >: LeafCount<const TensorSelectOp<IfExpr, ThenExpr, ElseExpr> > {}; 692b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 702b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 712b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// specialisation of the \ref LeafCount struct when the node type is const TensorAssignOp 722b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <typename LHSExpr, typename RHSExpr> 732b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<const TensorAssignOp<LHSExpr, RHSExpr> >: CategoryCount<LHSExpr,RHSExpr> {}; 742b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 752b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// specialisation of the \ref LeafCount struct when the node type is 762b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// TensorAssignOp is an exception. It is not the same as Unary 772b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <typename LHSExpr, typename RHSExpr> 782b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<TensorAssignOp<LHSExpr, RHSExpr> > :LeafCount<const TensorAssignOp<LHSExpr, RHSExpr> >{}; 792b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 802b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// specialisation of the \ref LeafCount struct when the node type is const TensorForcedEvalOp 812b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <typename Expr> 822b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<const TensorForcedEvalOp<Expr> > { 832b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang static const size_t Count =1; 842b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang}; 852b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 862b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// specialisation of the \ref LeafCount struct when the node type is TensorForcedEvalOp 872b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <typename Expr> 882b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<TensorForcedEvalOp<Expr> >: LeafCount<const TensorForcedEvalOp<Expr> > {}; 892b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 902b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// specialisation of the \ref LeafCount struct when the node type is const TensorEvalToOp 912b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <typename Expr> 922b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<const TensorEvalToOp<Expr> > { 932b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang static const size_t Count = 1 + CategoryCount<Expr>::Count; 942b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang}; 952b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 962b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// specialisation of the \ref LeafCount struct when the node type is const TensorReductionOp 972b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <typename OP, typename Dim, typename Expr> 982b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<const TensorReductionOp<OP, Dim, Expr> > { 992b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang static const size_t Count =1; 1002b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang}; 1012b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 1022b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// specialisation of the \ref LeafCount struct when the node type is TensorReductionOp 1032b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <typename OP, typename Dim, typename Expr> 1042b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<TensorReductionOp<OP, Dim, Expr> >: LeafCount<const TensorReductionOp<OP, Dim, Expr> >{}; 1052b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 1062b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang/// specialisation of the \ref LeafCount struct when the node type is TensorEvalToOp 1072b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangtemplate <typename Expr> 1082b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wangstruct LeafCount<TensorEvalToOp<Expr> >: LeafCount<const TensorEvalToOp<Expr> >{}; 1092b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 1102b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang} /// namespace TensorSycl 1112b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang} /// namespace internal 1122b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang} /// namespace Eigen 1132b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang 1142b8756b6f1de65d3f8bffab45be6c44ceb7411fcMiao Wang#endif // UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_LEAF_COUNT_HPP 115