mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-11 19:29:02 +08:00
Silenced a few compilation warnings
Generalized a TensorMap constructor
This commit is contained in:
parent
94e47798f4
commit
ae697b471c
@ -1,6 +1,7 @@
|
|||||||
// This file is part of Eigen, a lightweight C++ template library
|
// This file is part of Eigen, a lightweight C++ template library
|
||||||
// for linear algebra.
|
// for linear algebra.
|
||||||
//
|
//
|
||||||
|
// Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
|
||||||
// Copyright (C) 2013 Christian Seiler <christian@iwakd.de>
|
// Copyright (C) 2013 Christian Seiler <christian@iwakd.de>
|
||||||
//
|
//
|
||||||
// This Source Code Form is subject to the terms of the Mozilla
|
// This Source Code Form is subject to the terms of the Mozilla
|
||||||
|
@ -114,7 +114,7 @@ struct TensorEvaluator<const TensorBroadcastingOp<Broadcast, ArgType>, Device>
|
|||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* data) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* /*data*/) {
|
||||||
m_impl.evalSubExprsIfNeeded(NULL);
|
m_impl.evalSubExprsIfNeeded(NULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ struct TensorEvaluator<const TensorChippingOp<DimId, ArgType>, Device>
|
|||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* data) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* /*data*/) {
|
||||||
m_impl.evalSubExprsIfNeeded(NULL);
|
m_impl.evalSubExprsIfNeeded(NULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ struct TensorEvaluator<const TensorConcatenationOp<Axis, LeftArgType, RightArgTy
|
|||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
||||||
|
|
||||||
// TODO(phli): Add short-circuit memcpy evaluation if underlying data are linear?
|
// TODO(phli): Add short-circuit memcpy evaluation if underlying data are linear?
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* data)
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* /*data*/)
|
||||||
{
|
{
|
||||||
m_leftImpl.evalSubExprsIfNeeded(NULL);
|
m_leftImpl.evalSubExprsIfNeeded(NULL);
|
||||||
m_rightImpl.evalSubExprsIfNeeded(NULL);
|
m_rightImpl.evalSubExprsIfNeeded(NULL);
|
||||||
@ -202,13 +202,13 @@ struct TensorEvaluator<const TensorConcatenationOp<Axis, LeftArgType, RightArgTy
|
|||||||
Scalar* data() const { return NULL; }
|
Scalar* data() const { return NULL; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const Axis m_axis;
|
|
||||||
Dimensions m_dimensions;
|
Dimensions m_dimensions;
|
||||||
array<Index, NumDims> m_outputStrides;
|
array<Index, NumDims> m_outputStrides;
|
||||||
array<Index, NumDims> m_leftStrides;
|
array<Index, NumDims> m_leftStrides;
|
||||||
array<Index, NumDims> m_rightStrides;
|
array<Index, NumDims> m_rightStrides;
|
||||||
TensorEvaluator<LeftArgType, Device> m_leftImpl;
|
TensorEvaluator<LeftArgType, Device> m_leftImpl;
|
||||||
TensorEvaluator<RightArgType, Device> m_rightImpl;
|
TensorEvaluator<RightArgType, Device> m_rightImpl;
|
||||||
|
const Axis m_axis;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -671,10 +671,10 @@ struct TensorContractionEvaluatorBase
|
|||||||
Index m_j_size;
|
Index m_j_size;
|
||||||
Index m_k_size;
|
Index m_k_size;
|
||||||
|
|
||||||
const Device& m_device;
|
|
||||||
Scalar* m_result;
|
|
||||||
TensorEvaluator<LeftArgType, Device> m_leftImpl;
|
TensorEvaluator<LeftArgType, Device> m_leftImpl;
|
||||||
TensorEvaluator<RightArgType, Device> m_rightImpl;
|
TensorEvaluator<RightArgType, Device> m_rightImpl;
|
||||||
|
const Device& m_device;
|
||||||
|
Scalar* m_result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ struct TensorEvaluator<const TensorConvolutionOp<Indices, InputArgType, KernelAr
|
|||||||
};
|
};
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(const XprType& op, const Device& device)
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(const XprType& op, const Device& device)
|
||||||
: m_inputImpl(op.inputExpression(), device), m_kernelImpl(op.kernelExpression(), device), m_kernel(NULL), m_kernelArg(op.kernelExpression()), m_local_kernel(false), m_device(device)
|
: m_inputImpl(op.inputExpression(), device), m_kernelImpl(op.kernelExpression(), device), m_kernelArg(op.kernelExpression()), m_kernel(NULL), m_local_kernel(false), m_device(device)
|
||||||
{
|
{
|
||||||
const typename TensorEvaluator<InputArgType, Device>::Dimensions& input_dims = m_inputImpl.dimensions();
|
const typename TensorEvaluator<InputArgType, Device>::Dimensions& input_dims = m_inputImpl.dimensions();
|
||||||
const typename TensorEvaluator<KernelArgType, Device>::Dimensions& kernel_dims = m_kernelImpl.dimensions();
|
const typename TensorEvaluator<KernelArgType, Device>::Dimensions& kernel_dims = m_kernelImpl.dimensions();
|
||||||
|
@ -64,7 +64,8 @@ template<typename PlainObjectType, int Options_> class TensorMap : public Tensor
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline TensorMap(PointerArgType dataPtr, const array<Index, NumIndices>& dimensions)
|
template <typename Dimensions>
|
||||||
|
inline TensorMap(PointerArgType dataPtr, const Dimensions& dimensions)
|
||||||
: m_data(dataPtr), m_dimensions(dimensions)
|
: m_data(dataPtr), m_dimensions(dimensions)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -130,8 +130,8 @@ struct TensorEvaluator<const TensorReshapingOp<NewDimensions, ArgType>, Device>
|
|||||||
Scalar* data() const { return m_impl.data(); }
|
Scalar* data() const { return m_impl.data(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NewDimensions m_dimensions;
|
|
||||||
TensorEvaluator<ArgType, Device> m_impl;
|
TensorEvaluator<ArgType, Device> m_impl;
|
||||||
|
NewDimensions m_dimensions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -381,13 +381,13 @@ struct TensorEvaluator<const TensorSlicingOp<StartIndices, Sizes, ArgType>, Devi
|
|||||||
return inputIndex;
|
return inputIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dimensions m_dimensions;
|
|
||||||
array<Index, NumDims> m_outputStrides;
|
array<Index, NumDims> m_outputStrides;
|
||||||
array<internal::TensorIntDivisor<Index>, NumDims> m_fastOutputStrides;
|
array<internal::TensorIntDivisor<Index>, NumDims> m_fastOutputStrides;
|
||||||
array<Index, NumDims> m_inputStrides;
|
array<Index, NumDims> m_inputStrides;
|
||||||
const StartIndices m_offsets;
|
|
||||||
TensorEvaluator<ArgType, Device> m_impl;
|
TensorEvaluator<ArgType, Device> m_impl;
|
||||||
const Device& m_device;
|
const Device& m_device;
|
||||||
|
Dimensions m_dimensions;
|
||||||
|
const StartIndices m_offsets;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,11 +215,11 @@ struct TensorEvaluator<const TensorPaddingOp<PaddingDimensions, ArgType>, Device
|
|||||||
return rslt;
|
return rslt;
|
||||||
}
|
}
|
||||||
|
|
||||||
PaddingDimensions m_padding;
|
|
||||||
Dimensions m_dimensions;
|
Dimensions m_dimensions;
|
||||||
array<Index, NumDims+1> m_outputStrides;
|
array<Index, NumDims+1> m_outputStrides;
|
||||||
array<Index, NumDims> m_inputStrides;
|
array<Index, NumDims> m_inputStrides;
|
||||||
TensorEvaluator<ArgType, Device> m_impl;
|
TensorEvaluator<ArgType, Device> m_impl;
|
||||||
|
PaddingDimensions m_padding;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ struct TensorEvaluator<const TensorPatchOp<PatchDim, ArgType>, Device>
|
|||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* data) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* /*data*/) {
|
||||||
m_impl.evalSubExprsIfNeeded(NULL);
|
m_impl.evalSubExprsIfNeeded(NULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ struct TensorEvaluator<const TensorReductionOp<Op, Dims, ArgType>, Device>
|
|||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* data) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* /*data*/) {
|
||||||
m_impl.evalSubExprsIfNeeded(NULL);
|
m_impl.evalSubExprsIfNeeded(NULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -217,8 +217,8 @@ struct TensorEvaluator<const TensorReductionOp<Op, Dims, ArgType>, Device>
|
|||||||
array<Index, NumDims> m_preservedStrides;
|
array<Index, NumDims> m_preservedStrides;
|
||||||
array<Index, NumReducedDims> m_reducedStrides;
|
array<Index, NumReducedDims> m_reducedStrides;
|
||||||
array<Index, NumReducedDims> m_reducedDims;
|
array<Index, NumReducedDims> m_reducedDims;
|
||||||
Op m_reducer;
|
|
||||||
TensorEvaluator<ArgType, Device> m_impl;
|
TensorEvaluator<ArgType, Device> m_impl;
|
||||||
|
Op m_reducer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
@ -131,7 +131,7 @@ struct TensorEvaluator<const TensorShufflingOp<Shuffle, ArgType>, Device>
|
|||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* data) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* /*data*/) {
|
||||||
m_impl.evalSubExprsIfNeeded(NULL);
|
m_impl.evalSubExprsIfNeeded(NULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -32,10 +32,10 @@ static void test_1d()
|
|||||||
vec1(5) = 42.0; vec2(5) = 5.0;
|
vec1(5) = 42.0; vec2(5) = 5.0;
|
||||||
|
|
||||||
float data3[6];
|
float data3[6];
|
||||||
TensorMap<TensorFixedSize<float, Sizes<6> > > vec3(data3, 6);
|
TensorMap<TensorFixedSize<float, Sizes<6> > > vec3(data3, Sizes<6>());
|
||||||
vec3 = vec1.sqrt();
|
vec3 = vec1.sqrt();
|
||||||
float data4[6];
|
float data4[6];
|
||||||
TensorMap<TensorFixedSize<float, Sizes<6>, RowMajor> > vec4(data4, 6);
|
TensorMap<TensorFixedSize<float, Sizes<6>, RowMajor> > vec4(data4, Sizes<6>());
|
||||||
vec4 = vec2.sqrt();
|
vec4 = vec2.sqrt();
|
||||||
|
|
||||||
VERIFY_IS_EQUAL((vec3.size()), 6);
|
VERIFY_IS_EQUAL((vec3.size()), 6);
|
||||||
@ -68,9 +68,9 @@ static void test_1d()
|
|||||||
static void test_2d()
|
static void test_2d()
|
||||||
{
|
{
|
||||||
float data1[6];
|
float data1[6];
|
||||||
TensorMap<TensorFixedSize<float, Sizes<2, 3> >> mat1(data1,2,3);
|
TensorMap<TensorFixedSize<float, Sizes<2, 3> >> mat1(data1, Sizes<2, 3>());
|
||||||
float data2[6];
|
float data2[6];
|
||||||
TensorMap<TensorFixedSize<float, Sizes<2, 3>, RowMajor>> mat2(data2,2,3);
|
TensorMap<TensorFixedSize<float, Sizes<2, 3>, RowMajor>> mat2(data2, Sizes<2, 3>());
|
||||||
|
|
||||||
VERIFY_IS_EQUAL((mat1.size()), 2*3);
|
VERIFY_IS_EQUAL((mat1.size()), 2*3);
|
||||||
// VERIFY_IS_EQUAL((mat1.dimension(0)), 2);
|
// VERIFY_IS_EQUAL((mat1.dimension(0)), 2);
|
||||||
@ -166,7 +166,7 @@ static void test_array()
|
|||||||
for (int i = 0; i < 2; ++i) {
|
for (int i = 0; i < 2; ++i) {
|
||||||
for (int j = 0; j < 3; ++j) {
|
for (int j = 0; j < 3; ++j) {
|
||||||
for (int k = 0; k < 7; ++k) {
|
for (int k = 0; k < 7; ++k) {
|
||||||
mat1(array<ptrdiff_t, 3>(i,j,k)) = val;
|
mat1(array<ptrdiff_t, 3>{{i,j,k}}) = val;
|
||||||
val += 1.0;
|
val += 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user