mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Adding TensorLayoutSwapOp for sycl.
This commit is contained in:
@@ -91,28 +91,35 @@ ASSIGNCONVERT(, false)
|
||||
#undef ASSIGNCONVERT
|
||||
|
||||
/// specialisation of the \ref ConvertToDeviceExpression struct when the node
|
||||
/// type is either TensorForcedEvalOp or TensorEvalToOp
|
||||
/// type is TensorEvalToOp
|
||||
#define KERNELBROKERCONVERT(CVQual, Res, ExprNode)\
|
||||
template <typename Expr>\
|
||||
struct ConvertToDeviceExpression<CVQual ExprNode<Expr> > \
|
||||
: DeviceConvertor<ExprNode, Res, Expr>{};
|
||||
|
||||
/// specialisation of the \ref ConvertToDeviceExpression struct when the node type is TensorForcedEvalOp
|
||||
#define KERNELBROKERCONVERTFORCEDEVAL(CVQual)\
|
||||
template <typename Expr>\
|
||||
struct ConvertToDeviceExpression<CVQual TensorForcedEvalOp<Expr> > {\
|
||||
typedef CVQual TensorForcedEvalOp< typename ConvertToDeviceExpression<Expr>::Type> Type;\
|
||||
};
|
||||
KERNELBROKERCONVERTFORCEDEVAL(const)
|
||||
KERNELBROKERCONVERTFORCEDEVAL()
|
||||
#undef KERNELBROKERCONVERTFORCEDEVAL
|
||||
|
||||
|
||||
|
||||
KERNELBROKERCONVERT(const, true, TensorEvalToOp)
|
||||
KERNELBROKERCONVERT(, false, TensorEvalToOp)
|
||||
#undef KERNELBROKERCONVERT
|
||||
|
||||
/// specialisation of the \ref ConvertToDeviceExpression struct when the node types are TensorForcedEvalOp and TensorLayoutSwapOp
|
||||
#define KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAP(CVQual, ExprNode)\
|
||||
template <typename Expr>\
|
||||
struct ConvertToDeviceExpression<CVQual ExprNode<Expr> > {\
|
||||
typedef CVQual ExprNode< typename ConvertToDeviceExpression<Expr>::Type> Type;\
|
||||
};
|
||||
|
||||
// TensorForcedEvalOp
|
||||
KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAP(const,TensorForcedEvalOp)
|
||||
KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAP(,TensorForcedEvalOp)
|
||||
|
||||
// TensorLayoutSwapOp
|
||||
KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAP(const,TensorLayoutSwapOp)
|
||||
KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAP(,TensorLayoutSwapOp)
|
||||
#undef KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAP
|
||||
|
||||
|
||||
|
||||
/// specialisation of the \ref ConvertToDeviceExpression struct when the node type is TensorReductionOp
|
||||
#define KERNELBROKERCONVERTREDUCTION(CVQual)\
|
||||
template <typename OP, typename Dim, typename subExpr, template <class> class MakePointer_>\
|
||||
|
||||
@@ -223,7 +223,7 @@ struct ExprConstructor<CVQual TensorEvalToOp<OrigExpr, MakeGlobalPointer>, CVQua
|
||||
Type expr;\
|
||||
template <typename FuncDetector>\
|
||||
ExprConstructor(FuncDetector &funcD, const utility::tuple::Tuple<Params...> &t)\
|
||||
: nestedExpression(funcD.rhsExpr, t), buffer(t), expr(buffer.expr, nestedExpression.expr) {}\
|
||||
: nestedExpression(funcD.xprExpr, t), buffer(t), expr(buffer.expr, nestedExpression.expr) {}\
|
||||
};
|
||||
|
||||
EVALTO(const)
|
||||
@@ -386,6 +386,25 @@ SYCLTENSORCHIPPINGOPEXPR()
|
||||
#undef SYCLTENSORCHIPPINGOPEXPR
|
||||
|
||||
|
||||
|
||||
// TensorLayoutSwapOp
|
||||
#define SYCLTENSORLAYOUTSWAPOPEXPR(CVQual)\
|
||||
template<typename OrigXprType, typename XprType, typename... Params>\
|
||||
struct ExprConstructor<CVQual TensorLayoutSwapOp <OrigXprType> , CVQual TensorLayoutSwapOp<XprType>, Params... >{\
|
||||
typedef ExprConstructor<OrigXprType, XprType, Params...> my_xpr_type;\
|
||||
typedef CVQual TensorLayoutSwapOp<typename my_xpr_type::Type> Type;\
|
||||
my_xpr_type xprExpr;\
|
||||
Type expr;\
|
||||
template <typename FuncDetector>\
|
||||
ExprConstructor(FuncDetector &funcD, const utility::tuple::Tuple<Params...> &t)\
|
||||
: xprExpr(funcD.xprExpr, t), expr(xprExpr.expr) {}\
|
||||
};
|
||||
|
||||
SYCLTENSORLAYOUTSWAPOPEXPR(const)
|
||||
SYCLTENSORLAYOUTSWAPOPEXPR()
|
||||
#undef SYCLTENSORLAYOUTSWAPOPEXPR
|
||||
|
||||
|
||||
/// template deduction for \ref ExprConstructor struct
|
||||
template <typename OrigExpr, typename IndexExpr, typename FuncD, typename... Params>
|
||||
auto createDeviceExpression(FuncD &funcD, const utility::tuple::Tuple<Params...> &t)
|
||||
|
||||
@@ -226,6 +226,21 @@ SYCLTENSORCHIPPINGOPEXTACC()
|
||||
#undef SYCLTENSORCHIPPINGOPEXTACC
|
||||
|
||||
|
||||
// specialisation of the \ref ExtractAccessor struct when the node type is
|
||||
/// TensorLayoutSwapOp.
|
||||
#define SYCLTENSORLAYOUTSWAPOPEXTACC(CVQual)\
|
||||
template<typename XprType, typename Dev>\
|
||||
struct ExtractAccessor<TensorEvaluator<CVQual TensorLayoutSwapOp<XprType>, Dev> >{\
|
||||
static inline auto getTuple(cl::sycl::handler& cgh, const TensorEvaluator<CVQual TensorLayoutSwapOp<XprType>, Dev>& eval)\
|
||||
RETURN_CPP11(AccessorConstructor::getTuple(cgh, eval.impl()))\
|
||||
};
|
||||
|
||||
SYCLTENSORLAYOUTSWAPOPEXTACC(const)
|
||||
SYCLTENSORLAYOUTSWAPOPEXTACC()
|
||||
#undef SYCLTENSORLAYOUTSWAPOPEXTACC
|
||||
|
||||
|
||||
|
||||
/// template deduction for \ref ExtractAccessor
|
||||
template <typename Evaluator>
|
||||
auto createTupleOfAccessors(cl::sycl::handler& cgh, const Evaluator& eval)
|
||||
|
||||
@@ -39,7 +39,6 @@ template <typename Evaluator> struct FunctorExtractor{
|
||||
EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
||||
FunctorExtractor(const Evaluator& expr)
|
||||
: m_dimensions(expr.dimensions()) {}
|
||||
|
||||
};
|
||||
|
||||
/// specialisation of the \ref FunctorExtractor struct when the node type does not require anything
|
||||
@@ -143,19 +142,23 @@ SYCLEXTRFUNCASSIGNOP(const)
|
||||
SYCLEXTRFUNCASSIGNOP()
|
||||
#undef SYCLEXTRFUNCASSIGNOP
|
||||
|
||||
/// specialisation of the \ref FunctorExtractor struct when the node type is
|
||||
/// TensorEvalToOp, This is an specialisation without OP so it has to be separated.
|
||||
#define SYCLEXTRFUNCEVALTOOP(CVQual)\
|
||||
template <typename RHSExpr, typename Dev>\
|
||||
struct FunctorExtractor<TensorEvaluator<CVQual TensorEvalToOp<RHSExpr>, Dev> > {\
|
||||
FunctorExtractor<TensorEvaluator<RHSExpr, Dev> > rhsExpr;\
|
||||
FunctorExtractor(const TensorEvaluator<CVQual TensorEvalToOp<RHSExpr>, Dev>& expr)\
|
||||
: rhsExpr(expr.impl()) {}\
|
||||
/// specialisation of the \ref FunctorExtractor struct when the node types are
|
||||
/// TensorEvalToOp, TensorLayoutSwapOp. This is an specialisation without OP so it has to be separated.
|
||||
#define SYCLEXTRFUNCEVALTOOPSWAPLAYOUT(CVQual, ExprNode)\
|
||||
template <typename Expr, typename Dev>\
|
||||
struct FunctorExtractor<TensorEvaluator<CVQual ExprNode<Expr>, Dev> > {\
|
||||
FunctorExtractor<TensorEvaluator<Expr, Dev> > xprExpr;\
|
||||
FunctorExtractor(const TensorEvaluator<CVQual ExprNode<Expr>, Dev>& expr)\
|
||||
: xprExpr(expr.impl()) {}\
|
||||
};
|
||||
//TensorEvalToOp
|
||||
SYCLEXTRFUNCEVALTOOPSWAPLAYOUT(const, TensorEvalToOp)
|
||||
SYCLEXTRFUNCEVALTOOPSWAPLAYOUT(, TensorEvalToOp)
|
||||
// TensorLayoutSwapOp
|
||||
SYCLEXTRFUNCEVALTOOPSWAPLAYOUT(const, TensorLayoutSwapOp)
|
||||
SYCLEXTRFUNCEVALTOOPSWAPLAYOUT(, TensorLayoutSwapOp)
|
||||
|
||||
SYCLEXTRFUNCEVALTOOP(const)
|
||||
SYCLEXTRFUNCEVALTOOP()
|
||||
#undef SYCLEXTRFUNCEVALTOOP
|
||||
#undef SYCLEXTRFUNCEVALTOOPSWAPLAYOUT
|
||||
|
||||
template<typename Dim, size_t NumOutputDim> struct DimConstr {
|
||||
template<typename InDim>
|
||||
|
||||
@@ -94,15 +94,17 @@ SYCLFORCEDEVALLEAFCOUNT()
|
||||
#undef SYCLFORCEDEVALLEAFCOUNT
|
||||
|
||||
/// specialisation of the \ref LeafCount struct when the node type is TensorEvalToOp
|
||||
#define EVALTOLEAFCOUNT(CVQual)\
|
||||
#define EVALTOLAYOUTSWAPLEAFCOUNT(CVQual , ExprNode, Num)\
|
||||
template <typename Expr>\
|
||||
struct LeafCount<CVQual TensorEvalToOp<Expr> > {\
|
||||
static const size_t Count = 1 + CategoryCount<Expr>::Count;\
|
||||
struct LeafCount<CVQual ExprNode<Expr> > {\
|
||||
static const size_t Count = Num + CategoryCount<Expr>::Count;\
|
||||
};
|
||||
|
||||
EVALTOLEAFCOUNT(const)
|
||||
EVALTOLEAFCOUNT()
|
||||
#undef EVALTOLEAFCOUNT
|
||||
EVALTOLAYOUTSWAPLEAFCOUNT(const, TensorEvalToOp, 1)
|
||||
EVALTOLAYOUTSWAPLEAFCOUNT(, TensorEvalToOp, 1)
|
||||
EVALTOLAYOUTSWAPLEAFCOUNT(const, TensorLayoutSwapOp, 0)
|
||||
EVALTOLAYOUTSWAPLEAFCOUNT(, TensorLayoutSwapOp, 0)
|
||||
#undef EVALTOLAYOUTSWAPLEAFCOUNT
|
||||
|
||||
/// specialisation of the \ref LeafCount struct when the node type is const TensorReductionOp
|
||||
#define REDUCTIONLEAFCOUNT(CVQual)\
|
||||
|
||||
@@ -144,16 +144,19 @@ FORCEDEVAL()
|
||||
#undef FORCEDEVAL
|
||||
|
||||
/// specialisation of the \ref PlaceHolderExpression when the node is
|
||||
/// TensorEvalToOp
|
||||
#define EVALTO(CVQual)\
|
||||
/// TensorEvalToOp, TensorLayoutSwapOp
|
||||
#define EVALTOLAYOUTSWAP(CVQual, ExprNode)\
|
||||
template <typename Expr, size_t N>\
|
||||
struct PlaceHolderExpression<CVQual TensorEvalToOp<Expr>, N> {\
|
||||
typedef CVQual TensorEvalToOp<typename CalculateIndex <N, Expr>::ArgType> Type;\
|
||||
struct PlaceHolderExpression<CVQual ExprNode<Expr>, N> {\
|
||||
typedef CVQual ExprNode<typename CalculateIndex <N, Expr>::ArgType> Type;\
|
||||
};
|
||||
|
||||
EVALTO(const)
|
||||
EVALTO()
|
||||
#undef EVALTO
|
||||
EVALTOLAYOUTSWAP(const, TensorEvalToOp)
|
||||
EVALTOLAYOUTSWAP(, TensorEvalToOp)
|
||||
EVALTOLAYOUTSWAP(const, TensorLayoutSwapOp)
|
||||
EVALTOLAYOUTSWAP(, TensorLayoutSwapOp)
|
||||
|
||||
#undef EVALTOLAYOUTSWAP
|
||||
|
||||
|
||||
/// specialisation of the \ref PlaceHolderExpression when the node is
|
||||
|
||||
Reference in New Issue
Block a user