Merge with upstream.

This commit is contained in:
Mehdi Goli 2018-08-13 15:40:31 +01:00
commit 1aa86aad14
2 changed files with 26 additions and 30 deletions

View File

@ -60,7 +60,7 @@ struct cond<RowMajor> {
* - kSkewedInnerDims: 100 blocks of size 100x1 (or 1x100 depending on a column * - kSkewedInnerDims: 100 blocks of size 100x1 (or 1x100 depending on a column
* or row major layout) * or row major layout)
*/ */
enum class TensorBlockShapeType { enum TensorBlockShapeType {
kUniformAllDims, kUniformAllDims,
kSkewedInnerDims, kSkewedInnerDims,
}; };
@ -152,11 +152,11 @@ struct TensorBlockCopyOp {
const Scalar* src_base = &src_data[src_index]; const Scalar* src_base = &src_data[src_index];
Scalar* dst_base = &dst_data[dst_index]; Scalar* dst_base = &dst_data[dst_index];
using Src = const Eigen::Array<Scalar, Dynamic, 1>; typedef const Eigen::Array<Scalar, Dynamic, 1> Src;
using Dst = Eigen::Array<Scalar, Dynamic, 1>; typedef Eigen::Array<Scalar, Dynamic, 1> Dst;
using SrcMap = Eigen::Map<Src, 0, InnerStride<>>; typedef Eigen::Map<Src, 0, InnerStride<>> SrcMap;
using DstMap = Eigen::Map<Dst, 0, InnerStride<>>; typedef Eigen::Map<Dst, 0, InnerStride<>> DstMap;
const SrcMap src(src_base, num_coeff_to_copy, InnerStride<>(src_stride)); const SrcMap src(src_base, num_coeff_to_copy, InnerStride<>(src_stride));
DstMap dst(dst_base, num_coeff_to_copy, InnerStride<>(dst_stride)); DstMap dst(dst_base, num_coeff_to_copy, InnerStride<>(dst_stride));
@ -401,13 +401,13 @@ struct TensorBlockCwiseBinaryOp {
const StorageIndex left_stride, const LeftScalar* left_data, const StorageIndex left_stride, const LeftScalar* left_data,
const StorageIndex right_index, const StorageIndex right_stride, const StorageIndex right_index, const StorageIndex right_stride,
const RightScalar* right_data) { const RightScalar* right_data) {
using Lhs = const Eigen::Array<LeftScalar, Dynamic, 1>; typedef const Eigen::Array<LeftScalar, Dynamic, 1> Lhs;
using Rhs = const Eigen::Array<RightScalar, Dynamic, 1>; typedef const Eigen::Array<RightScalar, Dynamic, 1> Rhs;
using Out = Eigen::Array<OutputScalar, Dynamic, 1>; typedef Eigen::Array<OutputScalar, Dynamic, 1> Out;
using LhsMap = Eigen::Map<Lhs, 0, InnerStride<>>; typedef Eigen::Map<Lhs, 0, InnerStride<>> LhsMap;
using RhsMap = Eigen::Map<Rhs, 0, InnerStride<>>; typedef Eigen::Map<Rhs, 0, InnerStride<>> RhsMap;
using OutMap = Eigen::Map<Out, 0, InnerStride<>>; typedef Eigen::Map<Out, 0, InnerStride<>> OutMap;
const LeftScalar* lhs_base = &left_data[left_index]; const LeftScalar* lhs_base = &left_data[left_index];
const RightScalar* rhs_base = &right_data[right_index]; const RightScalar* rhs_base = &right_data[right_index];

View File

@ -36,7 +36,7 @@ template <typename Expression, typename Device, bool Vectorizable,
bool Tileable> bool Tileable>
class TensorExecutor { class TensorExecutor {
public: public:
using StorageIndex = typename Expression::Index; typedef typename Expression::Index StorageIndex;
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE void run(const Expression& expr, static EIGEN_STRONG_INLINE void run(const Expression& expr,
@ -60,7 +60,7 @@ template <typename Expression>
class TensorExecutor<Expression, DefaultDevice, /*Vectorizable*/ true, class TensorExecutor<Expression, DefaultDevice, /*Vectorizable*/ true,
/*Tileable*/ false> { /*Tileable*/ false> {
public: public:
using StorageIndex = typename Expression::Index; typedef typename Expression::Index StorageIndex;
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE void run(const Expression& expr, static EIGEN_STRONG_INLINE void run(const Expression& expr,
@ -102,21 +102,19 @@ template <typename Expression, bool Vectorizable>
class TensorExecutor<Expression, DefaultDevice, Vectorizable, class TensorExecutor<Expression, DefaultDevice, Vectorizable,
/*Tileable*/ true> { /*Tileable*/ true> {
public: public:
using Scalar = typename traits<Expression>::Scalar; typedef typename traits<Expression>::Scalar Scalar;
using ScalarNoConst = typename remove_const<Scalar>::type; typedef typename remove_const<Scalar>::type ScalarNoConst;
using Evaluator = TensorEvaluator<Expression, DefaultDevice>; typedef TensorEvaluator<Expression, DefaultDevice> Evaluator;
using StorageIndex = typename traits<Expression>::Index; typedef typename traits<Expression>::Index StorageIndex;
static const int NumDims = traits<Expression>::NumDimensions; static const int NumDims = traits<Expression>::NumDimensions;
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE void run(const Expression& expr, static EIGEN_STRONG_INLINE void run(const Expression& expr,
const DefaultDevice& device = DefaultDevice()) { const DefaultDevice& device = DefaultDevice()) {
using TensorBlock = typedef TensorBlock<ScalarNoConst, StorageIndex, NumDims, Evaluator::Layout> TensorBlock;
TensorBlock<ScalarNoConst, StorageIndex, NumDims, Evaluator::Layout>; typedef TensorBlockMapper<ScalarNoConst, StorageIndex, NumDims, Evaluator::Layout> TensorBlockMapper;
using TensorBlockMapper = TensorBlockMapper<ScalarNoConst, StorageIndex,
NumDims, Evaluator::Layout>;
Evaluator evaluator(expr, device); Evaluator evaluator(expr, device);
Index total_size = array_prod(evaluator.dimensions()); Index total_size = array_prod(evaluator.dimensions());
@ -221,7 +219,7 @@ struct EvalRange<Evaluator, StorageIndex, /*Vectorizable*/ true> {
template <typename Expression, bool Vectorizable, bool Tileable> template <typename Expression, bool Vectorizable, bool Tileable>
class TensorExecutor<Expression, ThreadPoolDevice, Vectorizable, Tileable> { class TensorExecutor<Expression, ThreadPoolDevice, Vectorizable, Tileable> {
public: public:
using StorageIndex = typename Expression::Index; typedef typename Expression::Index StorageIndex;
static EIGEN_STRONG_INLINE void run(const Expression& expr, static EIGEN_STRONG_INLINE void run(const Expression& expr,
const ThreadPoolDevice& device) { const ThreadPoolDevice& device) {
@ -249,20 +247,18 @@ class TensorExecutor<Expression, ThreadPoolDevice, Vectorizable, Tileable> {
template <typename Expression, bool Vectorizable> template <typename Expression, bool Vectorizable>
class TensorExecutor<Expression, ThreadPoolDevice, Vectorizable, /*Tileable*/ true> { class TensorExecutor<Expression, ThreadPoolDevice, Vectorizable, /*Tileable*/ true> {
public: public:
using Scalar = typename traits<Expression>::Scalar; typedef typename traits<Expression>::Scalar Scalar;
using ScalarNoConst = typename remove_const<Scalar>::type; typedef typename remove_const<Scalar>::type ScalarNoConst;
using Evaluator = TensorEvaluator<Expression, ThreadPoolDevice>; typedef TensorEvaluator<Expression, ThreadPoolDevice> Evaluator;
using StorageIndex = typename traits<Expression>::Index; typedef typename traits<Expression>::Index StorageIndex;
static const int NumDims = traits<Expression>::NumDimensions; static const int NumDims = traits<Expression>::NumDimensions;
static EIGEN_STRONG_INLINE void run(const Expression& expr, static EIGEN_STRONG_INLINE void run(const Expression& expr,
const ThreadPoolDevice& device) { const ThreadPoolDevice& device) {
using TensorBlock = typedef TensorBlock<ScalarNoConst, StorageIndex, NumDims, Evaluator::Layout> TensorBlock;
TensorBlock<ScalarNoConst, StorageIndex, NumDims, Evaluator::Layout>; typedef TensorBlockMapper<ScalarNoConst, StorageIndex, NumDims, Evaluator::Layout> TensorBlockMapper;
using TensorBlockMapper =
TensorBlockMapper<ScalarNoConst, StorageIndex, NumDims, Evaluator::Layout>;
Evaluator evaluator(expr, device); Evaluator evaluator(expr, device);
StorageIndex total_size = array_prod(evaluator.dimensions()); StorageIndex total_size = array_prod(evaluator.dimensions());