mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Adding TensorVolumePatchOP.h for sycl
This commit is contained in:
@@ -177,6 +177,16 @@ KERNELBROKERCONVERTIMAGEPATCHOP()
|
||||
#undef KERNELBROKERCONVERTIMAGEPATCHOP
|
||||
|
||||
|
||||
/// specialisation of the \ref ConvertToDeviceExpression struct when the node type is TensorVolumePatchOp
|
||||
#define KERNELBROKERCONVERTVOLUMEPATCHOP(CVQual)\
|
||||
template<DenseIndex Plannes, DenseIndex Rows, DenseIndex Cols, typename XprType>\
|
||||
struct ConvertToDeviceExpression<CVQual TensorVolumePatchOp<Plannes, Rows, Cols, XprType> >{\
|
||||
typedef CVQual TensorVolumePatchOp<Plannes, Rows, Cols, typename ConvertToDeviceExpression<XprType>::Type> Type;\
|
||||
};
|
||||
KERNELBROKERCONVERTVOLUMEPATCHOP(const)
|
||||
KERNELBROKERCONVERTVOLUMEPATCHOP()
|
||||
#undef KERNELBROKERCONVERTVOLUMEPATCHOP
|
||||
|
||||
|
||||
|
||||
} // namespace internal
|
||||
|
||||
@@ -404,6 +404,28 @@ SYCLTENSORIMAGEPATCHOPEXPR(const)
|
||||
SYCLTENSORIMAGEPATCHOPEXPR()
|
||||
#undef SYCLTENSORIMAGEPATCHOPEXPR
|
||||
|
||||
// TensorVolumePatchOp
|
||||
#define SYCLTENSORVOLUMEPATCHOPEXPR(CVQual)\
|
||||
template<DenseIndex Planes, DenseIndex Rows, DenseIndex Cols, typename OrigXprType, typename XprType, typename... Params>\
|
||||
struct ExprConstructor<CVQual TensorVolumePatchOp<Planes, Rows, Cols, OrigXprType>, CVQual TensorVolumePatchOp<Planes, Rows, Cols, XprType>, Params... > {\
|
||||
typedef ExprConstructor<OrigXprType, XprType, Params...> my_xpr_type;\
|
||||
typedef CVQual TensorVolumePatchOp<Planes, Rows, Cols, 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, funcD.m_patch_planes, funcD.m_patch_rows, funcD.m_patch_cols, funcD.m_plane_strides, funcD.m_row_strides, funcD.m_col_strides,\
|
||||
funcD.m_in_plane_strides, funcD.m_in_row_strides, funcD.m_in_col_strides,funcD.m_plane_inflate_strides, funcD.m_row_inflate_strides, funcD.m_col_inflate_strides, \
|
||||
funcD.m_padding_top_z, funcD.m_padding_bottom_z, funcD.m_padding_top, funcD.m_padding_bottom, funcD.m_padding_left, funcD.m_padding_right, funcD.m_padding_value,\
|
||||
funcD.m_padding_type, funcD.m_padding_explicit){\
|
||||
}\
|
||||
};
|
||||
|
||||
SYCLTENSORVOLUMEPATCHOPEXPR(const)
|
||||
SYCLTENSORVOLUMEPATCHOPEXPR()
|
||||
#undef SYCLTENSORVOLUMEPATCHOPEXPR
|
||||
|
||||
|
||||
|
||||
// TensorLayoutSwapOp
|
||||
#define SYCLTENSORLAYOUTSWAPOPEXPR(CVQual)\
|
||||
|
||||
@@ -240,6 +240,21 @@ SYCLTENSORIMAGEPATCHOPEXTACC()
|
||||
#undef SYCLTENSORIMAGEPATCHOPEXTACC
|
||||
|
||||
|
||||
|
||||
// specialisation of the \ref ExtractAccessor struct when the node type is
|
||||
/// TensorVolumePatchOp.
|
||||
#define SYCLTENSORVOLUMEPATCHOPEXTACC(CVQual)\
|
||||
template<DenseIndex Planes, DenseIndex Rows, DenseIndex Cols, typename XprType, typename Dev>\
|
||||
struct ExtractAccessor<TensorEvaluator<CVQual TensorVolumePatchOp<Planes, Rows, Cols, XprType>, Dev> >{\
|
||||
static inline auto getTuple(cl::sycl::handler& cgh, const TensorEvaluator<CVQual TensorVolumePatchOp<Planes, Rows, Cols, XprType>, Dev>& eval)\
|
||||
RETURN_CPP11(AccessorConstructor::getTuple(cgh, eval.impl()))\
|
||||
};
|
||||
|
||||
SYCLTENSORVOLUMEPATCHOPEXTACC(const)
|
||||
SYCLTENSORVOLUMEPATCHOPEXTACC()
|
||||
#undef SYCLTENSORVOLUMEPATCHOPEXTACC
|
||||
|
||||
|
||||
// specialisation of the \ref ExtractAccessor struct when the node type is
|
||||
/// TensorLayoutSwapOp.
|
||||
#define SYCLTENSORLAYOUTSWAPOPEXTACC(CVQual)\
|
||||
|
||||
@@ -344,6 +344,50 @@ FunctorExtractor(const TensorEvaluator<Self, Device>& expr)\
|
||||
SYCLEXTRFUNCIMAGEPATCHOP(const)
|
||||
SYCLEXTRFUNCIMAGEPATCHOP()
|
||||
#undef SYCLEXTRFUNCIMAGEPATCHOP
|
||||
|
||||
/// TensorVolumePatchOp
|
||||
#define SYCLEXTRFUNCVOLUMEPATCHOP(CVQual)\
|
||||
template<DenseIndex Planes, DenseIndex Rows, DenseIndex Cols, typename XprType, typename Device>\
|
||||
struct FunctorExtractor<TensorEvaluator<CVQual TensorVolumePatchOp<Planes, Rows, Cols, XprType>, Device> >{\
|
||||
typedef CVQual TensorVolumePatchOp<Planes, Rows, Cols, XprType> Self;\
|
||||
FunctorExtractor<Eigen::TensorEvaluator<XprType, Device> > xprExpr;\
|
||||
const DenseIndex m_patch_planes;\
|
||||
const DenseIndex m_patch_rows;\
|
||||
const DenseIndex m_patch_cols;\
|
||||
const DenseIndex m_plane_strides;\
|
||||
const DenseIndex m_row_strides;\
|
||||
const DenseIndex m_col_strides;\
|
||||
const DenseIndex m_in_plane_strides;\
|
||||
const DenseIndex m_in_row_strides;\
|
||||
const DenseIndex m_in_col_strides;\
|
||||
const DenseIndex m_plane_inflate_strides;\
|
||||
const DenseIndex m_row_inflate_strides;\
|
||||
const DenseIndex m_col_inflate_strides;\
|
||||
const bool m_padding_explicit;\
|
||||
const DenseIndex m_padding_top_z;\
|
||||
const DenseIndex m_padding_bottom_z;\
|
||||
const DenseIndex m_padding_top;\
|
||||
const DenseIndex m_padding_bottom;\
|
||||
const DenseIndex m_padding_left;\
|
||||
const DenseIndex m_padding_right;\
|
||||
const PaddingType m_padding_type;\
|
||||
const typename Self::Scalar m_padding_value;\
|
||||
FunctorExtractor(const TensorEvaluator<Self, Device>& expr)\
|
||||
: xprExpr(expr.impl()), m_patch_planes(expr.xpr().patch_planes()), m_patch_rows(expr.xpr().patch_rows()), m_patch_cols(expr.xpr().patch_cols()),\
|
||||
m_plane_strides(expr.xpr().plane_strides()), m_row_strides(expr.xpr().row_strides()), m_col_strides(expr.xpr().col_strides()),\
|
||||
m_in_plane_strides(expr.xpr().in_plane_strides()), m_in_row_strides(expr.xpr().in_row_strides()), m_in_col_strides(expr.xpr().in_col_strides()),\
|
||||
m_plane_inflate_strides(expr.xpr().plane_inflate_strides()),m_row_inflate_strides(expr.xpr().row_inflate_strides()),\
|
||||
m_col_inflate_strides(expr.xpr().col_inflate_strides()), m_padding_explicit(expr.xpr().padding_explicit()),\
|
||||
m_padding_top_z(expr.xpr().padding_top_z()), m_padding_bottom_z(expr.xpr().padding_bottom_z()), \
|
||||
m_padding_top(expr.xpr().padding_top()), m_padding_bottom(expr.xpr().padding_bottom()), m_padding_left(expr.xpr().padding_left()),\
|
||||
m_padding_right(expr.xpr().padding_right()), m_padding_type(expr.xpr().padding_type()),m_padding_value(expr.xpr().padding_value()){}\
|
||||
};
|
||||
SYCLEXTRFUNCVOLUMEPATCHOP(const)
|
||||
SYCLEXTRFUNCVOLUMEPATCHOP()
|
||||
#undef SYCLEXTRFUNCVOLUMEPATCHOP
|
||||
|
||||
|
||||
|
||||
/// template deduction function for FunctorExtractor
|
||||
template <typename Evaluator>
|
||||
auto inline extractFunctors(const Evaluator& evaluator)-> FunctorExtractor<Evaluator> {
|
||||
|
||||
@@ -151,7 +151,7 @@ CHIPPINGOPLEAFCOUNT(const)
|
||||
CHIPPINGOPLEAFCOUNT()
|
||||
#undef CHIPPINGOPLEAFCOUNT
|
||||
|
||||
|
||||
///TensorStridingSlicingOp
|
||||
#define SLICESTRIDEOPLEAFCOUNT(CVQual)\
|
||||
template<typename StartIndices, typename StopIndices, typename Strides, typename XprType>\
|
||||
struct LeafCount<CVQual TensorStridingSlicingOp<StartIndices, StopIndices, Strides, XprType> >:CategoryCount<XprType>{};
|
||||
@@ -160,7 +160,7 @@ SLICESTRIDEOPLEAFCOUNT(const)
|
||||
SLICESTRIDEOPLEAFCOUNT()
|
||||
#undef SLICESTRIDEOPLEAFCOUNT
|
||||
|
||||
|
||||
//TensorImagePatchOp
|
||||
#define TENSORIMAGEPATCHOPLEAFCOUNT(CVQual)\
|
||||
template<DenseIndex Rows, DenseIndex Cols, typename XprType>\
|
||||
struct LeafCount<CVQual TensorImagePatchOp<Rows, Cols, XprType> >:CategoryCount<XprType>{};
|
||||
@@ -170,6 +170,15 @@ TENSORIMAGEPATCHOPLEAFCOUNT(const)
|
||||
TENSORIMAGEPATCHOPLEAFCOUNT()
|
||||
#undef TENSORIMAGEPATCHOPLEAFCOUNT
|
||||
|
||||
// TensorVolumePatchOp
|
||||
#define TENSORVOLUMEPATCHOPLEAFCOUNT(CVQual)\
|
||||
template<DenseIndex Planes, DenseIndex Rows, DenseIndex Cols, typename XprType>\
|
||||
struct LeafCount<CVQual TensorVolumePatchOp<Planes, Rows, Cols, XprType> >:CategoryCount<XprType>{};
|
||||
|
||||
|
||||
TENSORVOLUMEPATCHOPLEAFCOUNT(const)
|
||||
TENSORVOLUMEPATCHOPLEAFCOUNT()
|
||||
#undef TENSORVOLUMEPATCHOPLEAFCOUNT
|
||||
|
||||
} /// namespace TensorSycl
|
||||
} /// namespace internal
|
||||
|
||||
@@ -235,6 +235,20 @@ SYCLTENSORIMAGEPATCHOP()
|
||||
#undef SYCLTENSORIMAGEPATCHOP
|
||||
|
||||
|
||||
|
||||
/// specialisation of the \ref PlaceHolderExpression when the node is
|
||||
/// TensorVolumePatchOp
|
||||
#define SYCLTENSORVOLUMEPATCHOP(CVQual)\
|
||||
template<DenseIndex Planes, DenseIndex Rows, DenseIndex Cols, typename XprType, size_t N>\
|
||||
struct PlaceHolderExpression<CVQual TensorVolumePatchOp<Planes,Rows, Cols, XprType>, N> {\
|
||||
typedef CVQual TensorVolumePatchOp<Planes,Rows, Cols, typename CalculateIndex <N, XprType>::ArgType> Type;\
|
||||
};
|
||||
|
||||
SYCLTENSORVOLUMEPATCHOP(const)
|
||||
SYCLTENSORVOLUMEPATCHOP()
|
||||
#undef SYCLTENSORVOLUMEPATCHOP
|
||||
|
||||
|
||||
/// template deduction for \ref PlaceHolderExpression struct
|
||||
template <typename Expr>
|
||||
struct createPlaceHolderExpression {
|
||||
|
||||
@@ -65,12 +65,8 @@ class TensorVolumePatchOp : public TensorBase<TensorVolumePatchOp<Planes, Rows,
|
||||
DenseIndex in_plane_strides, DenseIndex in_row_strides, DenseIndex in_col_strides,
|
||||
DenseIndex plane_inflate_strides, DenseIndex row_inflate_strides, DenseIndex col_inflate_strides,
|
||||
PaddingType padding_type, Scalar padding_value)
|
||||
: m_xpr(expr), m_patch_planes(patch_planes), m_patch_rows(patch_rows), m_patch_cols(patch_cols),
|
||||
m_plane_strides(plane_strides), m_row_strides(row_strides), m_col_strides(col_strides),
|
||||
m_in_plane_strides(in_plane_strides), m_in_row_strides(in_row_strides), m_in_col_strides(in_col_strides),
|
||||
m_plane_inflate_strides(plane_inflate_strides), m_row_inflate_strides(row_inflate_strides), m_col_inflate_strides(col_inflate_strides),
|
||||
m_padding_explicit(false), m_padding_top_z(0), m_padding_bottom_z(0), m_padding_top(0), m_padding_bottom(0), m_padding_left(0), m_padding_right(0),
|
||||
m_padding_type(padding_type), m_padding_value(padding_value) {}
|
||||
: TensorVolumePatchOp(expr, patch_planes, patch_rows, patch_cols, plane_strides, row_strides, col_strides, in_plane_strides, in_row_strides, in_col_strides,
|
||||
plane_inflate_strides, row_inflate_strides, col_inflate_strides, 0,0,0,0,0,0,padding_value, padding_type, false) {}
|
||||
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorVolumePatchOp(const XprType& expr, DenseIndex patch_planes, DenseIndex patch_rows, DenseIndex patch_cols,
|
||||
DenseIndex plane_strides, DenseIndex row_strides, DenseIndex col_strides,
|
||||
@@ -79,14 +75,14 @@ class TensorVolumePatchOp : public TensorBase<TensorVolumePatchOp<Planes, Rows,
|
||||
DenseIndex padding_top_z, DenseIndex padding_bottom_z,
|
||||
DenseIndex padding_top, DenseIndex padding_bottom,
|
||||
DenseIndex padding_left, DenseIndex padding_right,
|
||||
Scalar padding_value)
|
||||
Scalar padding_value, PaddingType padding_type=PADDING_VALID, bool padding_explicit=true)
|
||||
: m_xpr(expr), m_patch_planes(patch_planes), m_patch_rows(patch_rows), m_patch_cols(patch_cols),
|
||||
m_plane_strides(plane_strides), m_row_strides(row_strides), m_col_strides(col_strides),
|
||||
m_in_plane_strides(in_plane_strides), m_in_row_strides(in_row_strides), m_in_col_strides(in_col_strides),
|
||||
m_plane_inflate_strides(plane_inflate_strides), m_row_inflate_strides(row_inflate_strides), m_col_inflate_strides(col_inflate_strides),
|
||||
m_padding_explicit(true), m_padding_top_z(padding_top_z), m_padding_bottom_z(padding_bottom_z), m_padding_top(padding_top), m_padding_bottom(padding_bottom),
|
||||
m_padding_explicit(padding_explicit), m_padding_top_z(padding_top_z), m_padding_bottom_z(padding_bottom_z), m_padding_top(padding_top), m_padding_bottom(padding_bottom),
|
||||
m_padding_left(padding_left), m_padding_right(padding_right),
|
||||
m_padding_type(PADDING_VALID), m_padding_value(padding_value) {}
|
||||
m_padding_type(padding_type), m_padding_value(padding_value) {}
|
||||
|
||||
EIGEN_DEVICE_FUNC
|
||||
DenseIndex patch_planes() const { return m_patch_planes; }
|
||||
@@ -183,9 +179,13 @@ struct TensorEvaluator<const TensorVolumePatchOp<Planes, Rows, Cols, ArgType>, D
|
||||
CoordAccess = false,
|
||||
RawAccess = false
|
||||
};
|
||||
#ifdef __SYCL_DEVICE_ONLY__
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator( const XprType op, const Device& device)
|
||||
#else
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator( const XprType& op, const Device& device)
|
||||
#endif
|
||||
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(const XprType& op, const Device& device)
|
||||
: m_impl(op.expression(), device)
|
||||
: m_impl(op.expression(), device), m_op(op)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT((NumDims >= 5), YOU_MADE_A_PROGRAMMING_MISTAKE);
|
||||
|
||||
@@ -321,7 +321,9 @@ struct TensorEvaluator<const TensorVolumePatchOp<Planes, Rows, Cols, ArgType>, D
|
||||
m_outputPlanesRows = m_outputPlanes * m_outputRows;
|
||||
|
||||
// Fast representations of different variables.
|
||||
// printf("THis is m_otherStride: %lu\n", m_otherStride );
|
||||
m_fastOtherStride = internal::TensorIntDivisor<Index>(m_otherStride);
|
||||
|
||||
m_fastPatchStride = internal::TensorIntDivisor<Index>(m_patchStride);
|
||||
m_fastColStride = internal::TensorIntDivisor<Index>(m_colStride);
|
||||
m_fastRowStride = internal::TensorIntDivisor<Index>(m_rowStride);
|
||||
@@ -338,7 +340,6 @@ struct TensorEvaluator<const TensorVolumePatchOp<Planes, Rows, Cols, ArgType>, D
|
||||
m_fastOutputDepth = internal::TensorIntDivisor<Index>(m_dimensions[NumDims-1]);
|
||||
}
|
||||
}
|
||||
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
||||
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* /*data*/) {
|
||||
@@ -352,6 +353,7 @@ struct TensorEvaluator<const TensorVolumePatchOp<Planes, Rows, Cols, ArgType>, D
|
||||
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
|
||||
{
|
||||
|
||||
// Patch index corresponding to the passed in index.
|
||||
const Index patchIndex = index / m_fastPatchStride;
|
||||
|
||||
@@ -505,6 +507,8 @@ struct TensorEvaluator<const TensorVolumePatchOp<Planes, Rows, Cols, ArgType>, D
|
||||
EIGEN_DEVICE_FUNC Scalar* data() const { return NULL; }
|
||||
|
||||
const TensorEvaluator<ArgType, Device>& impl() const { return m_impl; }
|
||||
// required by sycl
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const XprType& xpr() const { return m_op; }
|
||||
|
||||
Index planePaddingTop() const { return m_planePaddingTop; }
|
||||
Index rowPaddingTop() const { return m_rowPaddingTop; }
|
||||
@@ -600,6 +604,8 @@ struct TensorEvaluator<const TensorVolumePatchOp<Planes, Rows, Cols, ArgType>, D
|
||||
Scalar m_paddingValue;
|
||||
|
||||
TensorEvaluator<ArgType, Device> m_impl;
|
||||
// required by sycl
|
||||
XprType m_op;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user