diff --git a/Eigen/Core b/Eigen/Core index ed007dfa9..53cb72c95 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -11,12 +11,20 @@ #ifndef EIGEN_CORE_H #define EIGEN_CORE_H -// first thing Eigen does: stop the compiler from committing suicide -#include "src/Core/util/DisableStupidWarnings.h" -// Handle NVCC/CUDA -#ifdef __CUDACC__ - // Do not try asserts on CUDA! +/// This will no longer be needed after the next release of the computecppCE +#ifdef EIGEN_USE_SYCL +#undef min +#undef max +#undef isnan +#undef isinf +#undef isfinite +#include +#endif + +// Handle NVCC/CUDA/SYCL +#if defined(__CUDACC__) || defined(__SYCL_DEVICE_ONLY__) + // Do not try asserts on CUDA and SYCL! #ifndef EIGEN_NO_DEBUG #define EIGEN_NO_DEBUG #endif @@ -25,7 +33,7 @@ #undef EIGEN_INTERNAL_DEBUGGING #endif - // Do not try to vectorize on CUDA! + // Do not try to vectorize on CUDA and SYCL! #ifndef EIGEN_DONT_VECTORIZE #define EIGEN_DONT_VECTORIZE #endif @@ -35,8 +43,12 @@ #endif // All functions callable from CUDA code must be qualified with __device__ - #define EIGEN_DEVICE_FUNC __host__ __device__ - + #ifdef __CUDACC__ + #define EIGEN_DEVICE_FUNC __host__ __device__ + // For Sycl we dont need that + #else + #define EIGEN_DEVICE_FUNC + #endif #else #define EIGEN_DEVICE_FUNC @@ -51,43 +63,6 @@ #define EIGEN_USING_STD_MATH(FUNC) using std::FUNC; #endif -#ifdef EIGEN_USE_SYCL -#undef min -#undef max -#undef isnan -#undef isinf -#undef isfinite -#include -#endif - -// We need these predefines to determine if asserts need to be disabled for the device compiler -#if defined(__SYCL_DEVICE_ONLY__) - // Do not try asserts on SYCL! - #ifndef EIGEN_NO_DEBUG - #define EIGEN_NO_DEBUG - #endif - - #ifdef EIGEN_INTERNAL_DEBUGGING - #undef EIGEN_INTERNAL_DEBUGGING - #endif - - // Do not try to vectorize on SYCL! - #ifndef EIGEN_DONT_VECTORIZE - #define EIGEN_DONT_VECTORIZE - #endif - - #ifdef EIGEN_EXCEPTIONS - #undef EIGEN_EXCEPTIONS - #endif - - #define EIGEN_DEVICE_FUNC - -#endif - -#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(__CUDA_ARCH__) && !defined(EIGEN_EXCEPTIONS) && !defined(EIGEN_USE_SYCL) - #define EIGEN_EXCEPTIONS -#endif - #ifdef EIGEN_EXCEPTIONS #include #endif diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index a87777b22..2cbcc87c6 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -423,15 +423,15 @@ struct TensorEvaluator, Device> // Precompute output strides. if (NumOutputDims > 0) { if (static_cast(Layout) == static_cast(ColMajor)) { - m_outputStrides[0] = 1; - for (int i = 1; i < NumOutputDims; ++i) { - m_outputStrides[i] = m_outputStrides[i - 1] * m_dimensions[i - 1]; - } + m_outputStrides[0] = 1; + for (int i = 1; i < NumOutputDims; ++i) { + m_outputStrides[i] = m_outputStrides[i - 1] * m_dimensions[i - 1]; + } } else { - m_outputStrides.back() = 1; - for (int i = NumOutputDims - 2; i >= 0; --i) { - m_outputStrides[i] = m_outputStrides[i + 1] * m_dimensions[i + 1]; - } + m_outputStrides.back() = 1; + for (int i = NumOutputDims - 2; i >= 0; --i) { + m_outputStrides[i] = m_outputStrides[i + 1] * m_dimensions[i + 1]; + } } } @@ -439,27 +439,27 @@ struct TensorEvaluator, Device> if (NumInputDims > 0) { array input_strides; if (static_cast(Layout) == static_cast(ColMajor)) { - input_strides[0] = 1; - for (int i = 1; i < NumInputDims; ++i) { - input_strides[i] = input_strides[i-1] * input_dims[i-1]; - } + input_strides[0] = 1; + for (int i = 1; i < NumInputDims; ++i) { + input_strides[i] = input_strides[i-1] * input_dims[i-1]; + } } else { - input_strides.back() = 1; - for (int i = NumInputDims - 2; i >= 0; --i) { - input_strides[i] = input_strides[i + 1] * input_dims[i + 1]; - } + input_strides.back() = 1; + for (int i = NumInputDims - 2; i >= 0; --i) { + input_strides[i] = input_strides[i + 1] * input_dims[i + 1]; + } } int outputIndex = 0; int reduceIndex = 0; for (int i = 0; i < NumInputDims; ++i) { - if (m_reduced[i]) { - m_reducedStrides[reduceIndex] = input_strides[i]; - ++reduceIndex; - } else { - m_preservedStrides[outputIndex] = input_strides[i]; - ++outputIndex; - } + if (m_reduced[i]) { + m_reducedStrides[reduceIndex] = input_strides[i]; + ++reduceIndex; + } else { + m_preservedStrides[outputIndex] = input_strides[i]; + ++outputIndex; + } } } @@ -578,7 +578,7 @@ struct TensorEvaluator, Device> Op reducer(m_reducer); if (ReducingInnerMostDims || RunningFullReduction) { const Index num_values_to_reduce = - (static_cast(Layout) == static_cast(ColMajor)) ? m_preservedStrides[0] : m_preservedStrides[NumPreservedStrides - 1]; + (static_cast(Layout) == static_cast(ColMajor)) ? m_preservedStrides[0] : m_preservedStrides[NumPreservedStrides - 1]; return internal::InnerMostDimReducer::reduce(*this, firstInput(index), num_values_to_reduce, reducer); } else { @@ -602,7 +602,7 @@ struct TensorEvaluator, Device> EIGEN_ALIGN_MAX typename internal::remove_const::type values[PacketSize]; if (ReducingInnerMostDims) { const Index num_values_to_reduce = - (static_cast(Layout) == static_cast(ColMajor)) ? m_preservedStrides[0] : m_preservedStrides[NumPreservedStrides - 1]; + (static_cast(Layout) == static_cast(ColMajor)) ? m_preservedStrides[0] : m_preservedStrides[NumPreservedStrides - 1]; const Index firstIndex = firstInput(index); for (Index i = 0; i < PacketSize; ++i) { Op reducer(m_reducer); diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorSycl.h b/unsupported/Eigen/CXX11/src/Tensor/TensorSycl.h index 277dd739c..da15f7942 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorSycl.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorSycl.h @@ -11,20 +11,35 @@ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. // General include header of SYCL target for Tensor Module -#ifndef TENSORSYCL_H -#define TENSORSYCL_H +#ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_H +#define UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_H #ifdef EIGEN_USE_SYCL -// trait class to extract different attribute contents -template -struct Trait; // global pointer to set different attribute state for a class template struct MakeGlobalPointer { typedef typename cl::sycl::global_ptr::pointer_t Type; }; +namespace Eigen { +namespace TensorSycl { +namespace internal { + +/// This struct is used for special expression nodes with no operations (for example assign and selectOP). + struct NoOP; + +template struct GetType{ + typedef const T Type; +}; +template struct GetType{ + typedef T Type; +}; + +} +} +} + // tuple construction #include "TensorSyclTuple.h" @@ -59,4 +74,4 @@ struct MakeGlobalPointer { #include "TensorSyclRun.h" #endif // end of EIGEN_USE_SYCL -#endif // TENSORSYCL_H +#endif // UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_H diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorSyclConvertToDeviceExpression.h b/unsupported/Eigen/CXX11/src/Tensor/TensorSyclConvertToDeviceExpression.h index b3748131b..a94c30426 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorSyclConvertToDeviceExpression.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorSyclConvertToDeviceExpression.h @@ -19,12 +19,13 @@ * *****************************************************************/ -#ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSORYSYCL_TENSORSYCL_CONVERT_TO_DEVICE_EXPRESSION_HPP -#define UNSUPPORTED_EIGEN_CXX11_SRC_TENSORYSYCL_TENSORSYCL_CONVERT_TO_DEVICE_EXPRESSION_HPP +#ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_CONVERT_TO_DEVICE_EXPRESSION_HPP +#define UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_CONVERT_TO_DEVICE_EXPRESSION_HPP namespace Eigen { namespace TensorSycl { namespace internal { + /// \struct ConvertToDeviceExpression /// \brief This struct is used to convert the MakePointer in the host expression /// to the MakeGlobalPointer for the device expression. For the leafNodes @@ -33,204 +34,74 @@ namespace internal { template struct ConvertToDeviceExpression; +template class NonOpCategory, bool IsConst, typename... Args> +struct NonOpConversion{ + typedef typename GetType::Type...> >::Type Type; +}; + + +template class > class NonOpCategory, bool IsConst, typename Args> +struct DeviceConvertor{ + typedef typename GetType::Type, MakeGlobalPointer> >::Type Type; +}; + /// specialisation of the \ref ConvertToDeviceExpression struct when the node /// type is TensorMap -template class MakePointer_> -struct ConvertToDeviceExpression< - TensorMap, Options2_, - MakePointer_>> { - using Type = TensorMap, - Options2_, MakeGlobalPointer>; +#define TENSORMAPCONVERT(CVQual)\ +template class MakePointer_>\ +struct ConvertToDeviceExpression, Options2_, MakePointer_> > {\ + typedef CVQual TensorMap, Options2_, MakeGlobalPointer> Type;\ }; -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is const TensorMap -template class MakePointer_> -struct ConvertToDeviceExpression< - const TensorMap, - Options2_, MakePointer_>> { - using Type = - const TensorMap, - Options2_, MakeGlobalPointer>; -}; +TENSORMAPCONVERT(const) +TENSORMAPCONVERT() +#undef TENSORMAPCONVERT /// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is const TensorCwiseNullaryOp -template -struct ConvertToDeviceExpression> { - using RHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = const TensorCwiseNullaryOp; +/// type is TensorCwiseNullaryOp, TensorCwiseUnaryOp, TensorCwiseBinaryOp, TensorCwiseTernaryOp, TensorBroadcastingOp +#define CATEGORYCONVERT(CVQual)\ +template class Category, typename OP, typename... subExprs>\ +struct ConvertToDeviceExpression > {\ + typedef CVQual Category::Type... > Type;\ }; +CATEGORYCONVERT(const) +CATEGORYCONVERT() +#undef CATEGORYCONVERT + /// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is TensorCwiseNullaryOp -template -struct ConvertToDeviceExpression> { - using RHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = TensorCwiseNullaryOp; -}; - -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is const TensorBroadcastingOp -template -struct ConvertToDeviceExpression> { - using RHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = const TensorBroadcastingOp; -}; - -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is TensorBroadcastingOp -template -struct ConvertToDeviceExpression> { - using RHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = TensorBroadcastingOp; -}; - -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is const TensorCwiseUnaryOp -template -struct ConvertToDeviceExpression> { - using RHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = const TensorCwiseUnaryOp; -}; - -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is TensorCwiseUnaryOp -template -struct ConvertToDeviceExpression> { - using RHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = TensorCwiseUnaryOp; -}; - -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is const TensorCwiseBinaryOp -template -struct ConvertToDeviceExpression< - const TensorCwiseBinaryOp> { - using LHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using RHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = - const TensorCwiseBinaryOp; -}; - -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is TensorCwiseBinaryOp -template -struct ConvertToDeviceExpression> { - using LHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using RHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = TensorCwiseBinaryOp; -}; - -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is const TensorCwiseTernaryOp -template -struct ConvertToDeviceExpression< - const TensorCwiseTernaryOp> { - using Arg1PlaceHolderType = - typename ConvertToDeviceExpression::Type; - using Arg2PlaceHolderType = - typename ConvertToDeviceExpression::Type; - using Arg3PlaceHolderType = - typename ConvertToDeviceExpression::Type; - using Type = - const TensorCwiseTernaryOp; -}; - -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is TensorCwiseTernaryOp -template -struct ConvertToDeviceExpression< - TensorCwiseTernaryOp> { - using Arg1PlaceHolderType = - typename ConvertToDeviceExpression::Type; - using Arg2PlaceHolderType = - typename ConvertToDeviceExpression::Type; - using Arg3PlaceHolderType = - typename ConvertToDeviceExpression::Type; - using Type = TensorCwiseTernaryOp; -}; - -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is const TensorCwiseSelectOp -template -struct ConvertToDeviceExpression< - const TensorSelectOp> { - using IfPlaceHolderType = typename ConvertToDeviceExpression::Type; - using ThenPlaceHolderType = - typename ConvertToDeviceExpression::Type; - using ElsePlaceHolderType = - typename ConvertToDeviceExpression::Type; - using Type = const TensorSelectOp; -}; - -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is TensorCwiseSelectOp -template -struct ConvertToDeviceExpression> { - using IfPlaceHolderType = typename ConvertToDeviceExpression::Type; - using ThenPlaceHolderType = - typename ConvertToDeviceExpression::Type; - using ElsePlaceHolderType = - typename ConvertToDeviceExpression::Type; - using Type = TensorSelectOp; -}; +/// type is TensorCwiseSelectOp +#define SELECTOPCONVERT(CVQual, Res)\ +template \ +struct ConvertToDeviceExpression >\ +: NonOpConversion {}; +SELECTOPCONVERT(const, true) +SELECTOPCONVERT(, false) +#undef SELECTOPCONVERT /// specialisation of the \ref ConvertToDeviceExpression struct when the node /// type is const AssingOP -template -struct ConvertToDeviceExpression> { - using LHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using RHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = const TensorAssignOp; -}; +#define ASSIGNCONVERT(CVQual, Res)\ +template \ +struct ConvertToDeviceExpression >\ +: NonOpConversion{}; + +ASSIGNCONVERT(const, true) +ASSIGNCONVERT(, false) +#undef ASSIGNCONVERT /// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is AssingOP -template -struct ConvertToDeviceExpression> { - using LHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using RHSPlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = TensorAssignOp; -}; +/// type is either TensorForcedEvalOp or TensorEvalToOp +#define KERNELBROKERCONVERT(CVQual, Res, ExprNode)\ +template \ +struct ConvertToDeviceExpression > \ +: DeviceConvertor{}; -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is const TensorForcedEvalOp -template -struct ConvertToDeviceExpression> { - using PlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = const TensorForcedEvalOp; -}; - -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is const TensorForcedEvalOp -template -struct ConvertToDeviceExpression> { - using PlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = TensorForcedEvalOp; -}; - -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is const TensorEvalToOp -template -struct ConvertToDeviceExpression> { - using PlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = const TensorEvalToOp; -}; - -/// specialisation of the \ref ConvertToDeviceExpression struct when the node -/// type is TensorEvalToOp -template -struct ConvertToDeviceExpression> { - using PlaceHolderType = typename ConvertToDeviceExpression::Type; - using Type = TensorEvalToOp; -}; +KERNELBROKERCONVERT(const, true, TensorForcedEvalOp) +KERNELBROKERCONVERT(, false, TensorForcedEvalOp) +KERNELBROKERCONVERT(const, true, TensorEvalToOp) +KERNELBROKERCONVERT(, false, TensorEvalToOp) +#undef KERNELBROKERCONVERT } // namespace internal } // namespace TensorSycl } // namespace Eigen diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorSyclExprConstructor.h b/unsupported/Eigen/CXX11/src/Tensor/TensorSyclExprConstructor.h index fe3994175..833d5e271 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorSyclExprConstructor.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorSyclExprConstructor.h @@ -19,8 +19,8 @@ * *****************************************************************/ -#ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSORYSYCL_EXPR_CONSTRUCTOR_HPP -#define UNSUPPORTED_EIGEN_CXX11_SRC_TENSORYSYCL_EXPR_CONSTRUCTOR_HPP +#ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_EXPR_CONSTRUCTOR_HPP +#define UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_EXPR_CONSTRUCTOR_HPP namespace Eigen { namespace TensorSycl { @@ -30,8 +30,7 @@ namespace internal { template struct EvalToLHSConstructor { PtrType expr; - EvalToLHSConstructor(const utility::tuple::Tuple &t) - : expr((&(*(utility::tuple::get(t).get_pointer())))) {} + EvalToLHSConstructor(const utility::tuple::Tuple &t): expr((&(*(utility::tuple::get(t).get_pointer())))) {} }; /// \struct ExprConstructor is used to reconstruct the expression on the device @@ -44,447 +43,166 @@ struct EvalToLHSConstructor { template struct ExprConstructor; -/// specialisation of the \ref ExprConstructor struct when the node type is -/// const TensorMap -template class MakePointer_, size_t N, typename... Params> -struct ExprConstructor< - const TensorMap, - Options2_, MakeGlobalPointer>, - const Eigen::internal::PlaceHolder< - const TensorMap, - Options3_, MakePointer_>, - N>, - Params...> { - using Type = - const TensorMap, - Options2_, MakeGlobalPointer>; - - Type expr; - - template - ExprConstructor(FuncDetector &fd, const utility::tuple::Tuple &t) - : expr(Type((&(*(utility::tuple::get(t).get_pointer()))), - fd.dimensions())) {} -}; - /// specialisation of the \ref ExprConstructor struct when the node type is /// TensorMap -template class MakePointer_, size_t N, typename... Params> -struct ExprConstructor< - TensorMap, Options2_, - MakeGlobalPointer>, - Eigen::internal::PlaceHolder< - TensorMap, Options3_, - MakePointer_>, - N>, - Params...> { - using Type = TensorMap, - Options2_, MakeGlobalPointer>; - - Type expr; - template - ExprConstructor(FuncDetector &fd, const utility::tuple::Tuple &t) - : expr(Type((&(*(utility::tuple::get(t).get_pointer()))), - fd.dimensions())) {} +#define TENSORMAP(CVQual)\ +template class MakePointer_, size_t N, typename... Params>\ +struct ExprConstructor< CVQual TensorMap, Options2_, MakeGlobalPointer>,\ +CVQual Eigen::internal::PlaceHolder, Options3_, MakePointer_>, N>, Params...>{\ + typedef CVQual TensorMap, Options2_, MakeGlobalPointer> Type;\ + Type expr;\ + template \ + ExprConstructor(FuncDetector &fd, const utility::tuple::Tuple &t)\ + : expr(Type((&(*(utility::tuple::get(t).get_pointer()))), fd.dimensions())) {}\ }; +TENSORMAP(const) +TENSORMAP() +#undef TENSORMAP + +#define UNARYCATEGORY(CVQual)\ +template class UnaryCategory, typename OP, typename OrigRHSExpr, typename RHSExpr, typename... Params>\ +struct ExprConstructor, CVQual UnaryCategory, Params...> {\ + typedef ExprConstructor my_type;\ + my_type rhsExpr;\ + typedef CVQual UnaryCategory Type;\ + Type expr;\ + template \ + ExprConstructor(FuncDetector &funcD, const utility::tuple::Tuple &t)\ + : rhsExpr(funcD.rhsExpr, t), expr(rhsExpr.expr, funcD.func) {}\ +}; + +UNARYCATEGORY(const) +UNARYCATEGORY() +#undef UNARYCATEGORY + /// specialisation of the \ref ExprConstructor struct when the node type is -/// TensorCwiseNullaryOp -template -struct ExprConstructor, - TensorCwiseNullaryOp, Params...> { - using my_type = ExprConstructor; - my_type rhsExpr; - using Type = TensorCwiseNullaryOp; - Type expr; - - template - ExprConstructor(FuncDetector &funcD, - const utility::tuple::Tuple &t) - : rhsExpr(funcD.rhsExpr, t), expr(rhsExpr.expr, funcD.func) {} +/// TensorBinaryOp +#define BINARYCATEGORY(CVQual)\ +template class BinaryCategory, typename OP, typename OrigLHSExpr, typename OrigRHSExpr, typename LHSExpr,\ +typename RHSExpr, typename... Params>\ +struct ExprConstructor, CVQual BinaryCategory, Params...> {\ + typedef ExprConstructor my_left_type;\ + typedef ExprConstructor my_right_type;\ + typedef CVQual BinaryCategory Type;\ + my_left_type lhsExpr;\ + my_right_type rhsExpr;\ + Type expr;\ + template \ + ExprConstructor(FuncDetector &funcD, const utility::tuple::Tuple &t)\ + : lhsExpr(funcD.lhsExpr, t),rhsExpr(funcD.rhsExpr, t), expr(lhsExpr.expr, rhsExpr.expr, funcD.func) {}\ }; -/// specialisation of the \ref ExprConstructor struct when the node type is -/// const TensorCwiseNullaryOp -template -struct ExprConstructor, - const TensorCwiseNullaryOp, Params...> { - using my_type = const ExprConstructor; - my_type rhsExpr; - using Type = const TensorCwiseNullaryOp; - Type expr; - - template - ExprConstructor(FuncDetector &funcD, - const utility::tuple::Tuple &t) - : rhsExpr(funcD.rhsExpr, t), expr(rhsExpr.expr, funcD.func) {} -}; - -/// specialisation of the \ref ExprConstructor struct when the node type is -/// TensorBroadcastingOp -template -struct ExprConstructor, - TensorBroadcastingOp, Params...> { - using my_type = ExprConstructor; - my_type rhsExpr; - using Type = TensorBroadcastingOp; - Type expr; - - template - ExprConstructor(FuncDetector &funcD, - const utility::tuple::Tuple &t) - : rhsExpr(funcD.rhsExpr, t), expr(rhsExpr.expr, funcD.func) {} -}; - -/// specialisation of the \ref ExprConstructor struct when the node type is -/// const TensorBroadcastingOp -template -struct ExprConstructor, - const TensorBroadcastingOp, Params...> { - using my_type = const ExprConstructor; - my_type rhsExpr; - using Type = const TensorBroadcastingOp; - Type expr; - - template - ExprConstructor(FuncDetector &funcD, - const utility::tuple::Tuple &t) - : rhsExpr(funcD.rhsExpr, t), expr(rhsExpr.expr, funcD.func) {} -}; - -/// specialisation of the \ref ExprConstructor struct when the node type is -/// TensorCwiseUnaryOp -template -struct ExprConstructor, - TensorCwiseUnaryOp, Params...> { - using my_type = ExprConstructor; - using Type = TensorCwiseUnaryOp; - my_type rhsExpr; - Type expr; - - template - ExprConstructor(FuncDetector &funcD, utility::tuple::Tuple &t) - : rhsExpr(funcD.rhsExpr, t), expr(rhsExpr.expr, funcD.func) {} -}; - -/// specialisation of the \ref ExprConstructor struct when the node type is -/// const TensorCwiseUnaryOp -template -struct ExprConstructor, - const TensorCwiseUnaryOp, Params...> { - using my_type = ExprConstructor; - using Type = const TensorCwiseUnaryOp; - my_type rhsExpr; - Type expr; - - template - ExprConstructor(FuncDetector &funcD, - const utility::tuple::Tuple &t) - : rhsExpr(funcD.rhsExpr, t), expr(rhsExpr.expr, funcD.func) {} -}; - -/// specialisation of the \ref ExprConstructor struct when the node type is -/// TensorCwiseBinaryOp -template -struct ExprConstructor, - TensorCwiseBinaryOp, Params...> { - using my_left_type = ExprConstructor; - using my_right_type = ExprConstructor; - using Type = TensorCwiseBinaryOp; - - my_left_type lhsExpr; - my_right_type rhsExpr; - Type expr; - - template - ExprConstructor(FuncDetector &funcD, - const utility::tuple::Tuple &t) - : lhsExpr(funcD.lhsExpr, t), - rhsExpr(funcD.rhsExpr, t), - expr(lhsExpr.expr, rhsExpr.expr, funcD.func) {} -}; - -/// specialisation of the \ref ExprConstructor struct when the node type is -/// const TensorCwiseBinaryOp -template -struct ExprConstructor, - const TensorCwiseBinaryOp, - Params...> { - using my_left_type = ExprConstructor; - using my_right_type = ExprConstructor; - using Type = const TensorCwiseBinaryOp; - - my_left_type lhsExpr; - my_right_type rhsExpr; - Type expr; - - template - ExprConstructor(FuncDetector &funcD, - const utility::tuple::Tuple &t) - : lhsExpr(funcD.lhsExpr, t), - rhsExpr(funcD.rhsExpr, t), - expr(lhsExpr.expr, rhsExpr.expr, funcD.func) {} -}; - -/// specialisation of the \ref ExprConstructor struct when the node type is -/// const TensorCwiseTernaryOp -template -struct ExprConstructor< - const TensorCwiseTernaryOp, - const TensorCwiseTernaryOp, Params...> { - using my_arg1_type = ExprConstructor; - using my_arg2_type = ExprConstructor; - using my_arg3_type = ExprConstructor; - using Type = const TensorCwiseTernaryOp; - - my_arg1_type arg1Expr; - my_arg2_type arg2Expr; - my_arg3_type arg3Expr; - Type expr; - template - ExprConstructor(FuncDetector &funcD, - const utility::tuple::Tuple &t) - : arg1Expr(funcD.arg1Expr, t), - arg2Expr(funcD.arg2Expr, t), - arg3Expr(funcD.arg3Expr, t), - expr(arg1Expr.expr, arg2Expr.expr, arg3Expr.expr, funcD.func) {} -}; +BINARYCATEGORY(const) +BINARYCATEGORY() +#undef BINARYCATEGORY /// specialisation of the \ref ExprConstructor struct when the node type is /// TensorCwiseTernaryOp -template -struct ExprConstructor< - TensorCwiseTernaryOp, - TensorCwiseTernaryOp, Params...> { - using my_arg1_type = ExprConstructor; - using my_arg2_type = ExprConstructor; - using my_arg3_type = ExprConstructor; - using Type = TensorCwiseTernaryOp; - - my_arg1_type arg1Expr; - my_arg2_type arg2Expr; - my_arg3_type arg3Expr; - Type expr; - template - ExprConstructor(FuncDetector &funcD, - const utility::tuple::Tuple &t) - : arg1Expr(funcD.arg1Expr, t), - arg2Expr(funcD.arg2Expr, t), - arg3Expr(funcD.arg3Expr, t), - expr(arg1Expr.expr, arg2Expr.expr, arg3Expr.expr, funcD.func) {} +#define TERNARYCATEGORY(CVQual)\ +template