mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Fixed another batch of compilation warnings
This commit is contained in:
parent
fb53384b0f
commit
bb483313f6
@ -32,7 +32,7 @@ enum {
|
||||
template<typename Scalar, typename Index, int side,
|
||||
typename Tensor,
|
||||
typename nocontract_t, typename contract_t,
|
||||
size_t packet_size, bool inner_dim_contiguous>
|
||||
int packet_size, bool inner_dim_contiguous>
|
||||
class BaseTensorContractionMapper {
|
||||
public:
|
||||
EIGEN_DEVICE_FUNC
|
||||
@ -162,14 +162,14 @@ class BaseTensorContractionMapper {
|
||||
template<typename Scalar, typename Index, int side,
|
||||
typename Tensor,
|
||||
typename nocontract_t, typename contract_t,
|
||||
size_t packet_size,
|
||||
int packet_size,
|
||||
bool inner_dim_contiguous, bool inner_dim_reordered, int Alignment>
|
||||
class TensorContractionInputMapper;
|
||||
|
||||
template<typename Scalar, typename Index, int side,
|
||||
typename Tensor,
|
||||
typename nocontract_t, typename contract_t,
|
||||
size_t packet_size,
|
||||
int packet_size,
|
||||
bool inner_dim_contiguous, bool inner_dim_reordered, int Alignment>
|
||||
class TensorContractionSubMapper {
|
||||
public:
|
||||
@ -231,7 +231,7 @@ class TensorContractionSubMapper {
|
||||
template<typename Scalar, typename Index, int side,
|
||||
typename Tensor,
|
||||
typename nocontract_t, typename contract_t,
|
||||
size_t packet_size = (Tensor::PacketAccess ? packet_traits<Scalar>::size : 1),
|
||||
int packet_size = (Tensor::PacketAccess ? packet_traits<Scalar>::size : 1),
|
||||
bool inner_dim_contiguous = false, bool inner_dim_reordered = (side != Lhs), int Alignment=Unaligned>
|
||||
class TensorContractionInputMapper
|
||||
: public BaseTensorContractionMapper<Scalar, Index, side, Tensor, nocontract_t, contract_t, packet_size, inner_dim_contiguous> {
|
||||
@ -591,7 +591,7 @@ struct TensorContractionEvaluatorBase
|
||||
// dimensions and right non-contracting dimensions.
|
||||
m_lhs_inner_dim_contiguous = true;
|
||||
int dim_idx = 0;
|
||||
int nocontract_idx = 0;
|
||||
unsigned int nocontract_idx = 0;
|
||||
|
||||
for (int i = 0; i < LDims; i++) {
|
||||
// find if we are contracting on index i of left tensor
|
||||
@ -651,7 +651,7 @@ struct TensorContractionEvaluatorBase
|
||||
// each tensor, we'll only look at the first tensor here.
|
||||
m_rhs_inner_dim_contiguous = true;
|
||||
m_rhs_inner_dim_reordered = false;
|
||||
for (int i = 0; i < ContractDims; i++) {
|
||||
for (unsigned int i = 0; i < ContractDims; i++) {
|
||||
Index left = eval_op_indices[i].first;
|
||||
Index right = eval_op_indices[i].second;
|
||||
|
||||
@ -751,8 +751,8 @@ struct TensorContractionEvaluatorBase
|
||||
typedef typename internal::remove_const<typename EvalRightArgType::Scalar>::type RhsScalar;
|
||||
typedef TensorEvaluator<EvalLeftArgType, Device> LeftEvaluator;
|
||||
typedef TensorEvaluator<EvalRightArgType, Device> RightEvaluator;
|
||||
const int lhs_packet_size = internal::packet_traits<LhsScalar>::size;
|
||||
const int rhs_packet_size = internal::packet_traits<RhsScalar>::size;
|
||||
const Index lhs_packet_size = internal::packet_traits<LhsScalar>::size;
|
||||
const Index rhs_packet_size = internal::packet_traits<RhsScalar>::size;
|
||||
typedef internal::TensorContractionInputMapper<LhsScalar, Index, internal::Lhs,
|
||||
LeftEvaluator, left_nocontract_t,
|
||||
contract_t, lhs_packet_size,
|
||||
@ -916,8 +916,8 @@ struct TensorEvaluator<const TensorContractionOp<Indices, LeftArgType, RightArgT
|
||||
typedef TensorEvaluator<EvalLeftArgType, Device> LeftEvaluator;
|
||||
typedef TensorEvaluator<EvalRightArgType, Device> RightEvaluator;
|
||||
|
||||
const int lhs_packet_size = internal::packet_traits<LhsScalar>::size;
|
||||
const int rhs_packet_size = internal::packet_traits<RhsScalar>::size;
|
||||
const Index lhs_packet_size = internal::packet_traits<LhsScalar>::size;
|
||||
const Index rhs_packet_size = internal::packet_traits<RhsScalar>::size;
|
||||
|
||||
typedef internal::TensorContractionInputMapper<LhsScalar, Index, internal::Lhs,
|
||||
LeftEvaluator, left_nocontract_t,
|
||||
|
@ -312,15 +312,15 @@ struct TensorEvaluator<const TensorContractionOp<Indices, LeftArgType, RightArgT
|
||||
}
|
||||
|
||||
// Make sure all the kernels are done.
|
||||
for (int i = 0; i < kernel_futures.size(); ++i) {
|
||||
for (size_t i = 0; i < kernel_futures.size(); ++i) {
|
||||
wait_until_ready(&kernel_futures[i]);
|
||||
}
|
||||
|
||||
// deallocate all of the memory for both A and B's
|
||||
for (int i = 0; i < blockAs.size(); i++) {
|
||||
for (size_t i = 0; i < blockAs.size(); i++) {
|
||||
this->m_device.deallocate(blockAs[i]);
|
||||
}
|
||||
for (int i = 0; i < blockBs.size(); i++) {
|
||||
for (size_t i = 0; i < blockBs.size(); i++) {
|
||||
this->m_device.deallocate(blockBs[i]);
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ struct TensorIntDivisor {
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T divide(const T numerator) const {
|
||||
const int N = 32;
|
||||
eigen_assert(numerator >= 0);
|
||||
eigen_assert(numerator <= (1ull<<N) - 1);
|
||||
eigen_assert(numerator <= static_cast<T>(1ull<<N) - 1);
|
||||
|
||||
uint32_t t1 = (multiplier * numerator) >> 32;
|
||||
uint32_t t = (static_cast<uint32_t>(numerator) - t1) >> shift1;
|
||||
|
@ -364,7 +364,7 @@ struct TensorEvaluator<const TensorSlicingOp<StartIndices, Sizes, ArgType>, Devi
|
||||
}
|
||||
}
|
||||
// Use memcpy if it's going to be faster than using the regular evaluation.
|
||||
if (contiguous_values > 2 * m_device.numThreads()) {
|
||||
if (contiguous_values > static_cast<Index>(2 * m_device.numThreads())) {
|
||||
Scalar* src = m_impl.data();
|
||||
for (int i = 0; i < internal::array_prod(dimensions()); i += contiguous_values) {
|
||||
Index offset = srcCoeff(i);
|
||||
|
@ -360,7 +360,7 @@ static void test_large_contraction()
|
||||
t_result = t_left.contract(t_right, dims);
|
||||
m_result = m_left * m_right;
|
||||
|
||||
for (size_t i = 0; i < t_result.dimensions().TotalSize(); i++) {
|
||||
for (int i = 0; i < t_result.dimensions().TotalSize(); i++) {
|
||||
VERIFY(&t_result.data()[i] != &m_result.data()[i]);
|
||||
VERIFY_IS_APPROX(t_result.data()[i], m_result.data()[i]);
|
||||
}
|
||||
@ -388,7 +388,7 @@ static void test_matrix_vector()
|
||||
t_result = t_left.contract(t_right, dims);
|
||||
m_result = m_left * m_right;
|
||||
|
||||
for (size_t i = 0; i < t_result.dimensions().TotalSize(); i++) {
|
||||
for (int i = 0; i < t_result.dimensions().TotalSize(); i++) {
|
||||
VERIFY(internal::isApprox(t_result(i), m_result(i, 0), 1));
|
||||
}
|
||||
}
|
||||
@ -412,7 +412,7 @@ static void test_tensor_vector()
|
||||
MapXf m_right(t_right.data(), 1, 7);
|
||||
Eigen::Matrix<float, Dynamic, Dynamic, DataLayout> m_result = m_left.transpose() * m_right.transpose();
|
||||
|
||||
for (size_t i = 0; i < t_result.dimensions().TotalSize(); i++) {
|
||||
for (int i = 0; i < t_result.dimensions().TotalSize(); i++) {
|
||||
VERIFY(internal::isApprox(t_result(i), m_result(i, 0), 1));
|
||||
}
|
||||
}
|
||||
@ -443,7 +443,7 @@ static void test_small_blocking_factors()
|
||||
Map<Eigen::Matrix<float, Dynamic, Dynamic, DataLayout>> m_right(t_right.data(), 93, 140);
|
||||
Eigen::Matrix<float, Dynamic, Dynamic, DataLayout> m_result = m_left * m_right;
|
||||
|
||||
for (size_t i = 0; i < t_result.dimensions().TotalSize(); i++) {
|
||||
for (int i = 0; i < t_result.dimensions().TotalSize(); i++) {
|
||||
VERIFY_IS_APPROX(t_result.data()[i], m_result.data()[i]);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ static void test_dynamic_size()
|
||||
VERIFY_IS_EQUAL((int)Eigen::internal::array_get<0>(dimensions), 2);
|
||||
VERIFY_IS_EQUAL((int)Eigen::internal::array_get<1>(dimensions), 3);
|
||||
VERIFY_IS_EQUAL((int)Eigen::internal::array_get<2>(dimensions), 7);
|
||||
VERIFY_IS_EQUAL(dimensions.TotalSize(), (size_t)2*3*7);
|
||||
VERIFY_IS_EQUAL(dimensions.TotalSize(), 2*3*7);
|
||||
VERIFY_IS_EQUAL((int)dimensions[0], 2);
|
||||
VERIFY_IS_EQUAL((int)dimensions[1], 3);
|
||||
VERIFY_IS_EQUAL((int)dimensions[2], 7);
|
||||
@ -34,7 +34,7 @@ static void test_fixed_size()
|
||||
VERIFY_IS_EQUAL((int)Eigen::internal::array_get<0>(dimensions), 2);
|
||||
VERIFY_IS_EQUAL((int)Eigen::internal::array_get<1>(dimensions), 3);
|
||||
VERIFY_IS_EQUAL((int)Eigen::internal::array_get<2>(dimensions), 7);
|
||||
VERIFY_IS_EQUAL(dimensions.TotalSize(), (size_t)2*3*7);
|
||||
VERIFY_IS_EQUAL(dimensions.TotalSize(), 2*3*7);
|
||||
}
|
||||
|
||||
|
||||
|
@ -221,33 +221,33 @@ static void test_slice_raw_data()
|
||||
Eigen::DSizes<ptrdiff_t, 4> extents(1,1,1,1);
|
||||
typedef TensorEvaluator<decltype(tensor.slice(offsets, extents)), DefaultDevice> SliceEvaluator;
|
||||
auto slice1 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
|
||||
VERIFY_IS_EQUAL(slice1.dimensions().TotalSize(), 1ul);
|
||||
VERIFY_IS_EQUAL(slice1.dimensions().TotalSize(), 1);
|
||||
VERIFY_IS_EQUAL(slice1.data()[0], tensor(1,2,3,4));
|
||||
|
||||
if (DataLayout == ColMajor) {
|
||||
extents = Eigen::DSizes<ptrdiff_t, 4>(2,1,1,1);
|
||||
auto slice2 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
|
||||
VERIFY_IS_EQUAL(slice2.dimensions().TotalSize(), 2ul);
|
||||
VERIFY_IS_EQUAL(slice2.dimensions().TotalSize(), 2);
|
||||
VERIFY_IS_EQUAL(slice2.data()[0], tensor(1,2,3,4));
|
||||
VERIFY_IS_EQUAL(slice2.data()[1], tensor(2,2,3,4));
|
||||
} else {
|
||||
extents = Eigen::DSizes<ptrdiff_t, 4>(1,1,1,2);
|
||||
auto slice2 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
|
||||
VERIFY_IS_EQUAL(slice2.dimensions().TotalSize(), 2ul);
|
||||
VERIFY_IS_EQUAL(slice2.dimensions().TotalSize(), 2);
|
||||
VERIFY_IS_EQUAL(slice2.data()[0], tensor(1,2,3,4));
|
||||
VERIFY_IS_EQUAL(slice2.data()[1], tensor(1,2,3,5));
|
||||
}
|
||||
|
||||
extents = Eigen::DSizes<ptrdiff_t, 4>(1,2,1,1);
|
||||
auto slice3 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
|
||||
VERIFY_IS_EQUAL(slice3.dimensions().TotalSize(), 2ul);
|
||||
VERIFY_IS_EQUAL(slice3.dimensions().TotalSize(), 2);
|
||||
VERIFY_IS_EQUAL(slice3.data(), static_cast<float*>(0));
|
||||
|
||||
if (DataLayout == ColMajor) {
|
||||
offsets = Eigen::DSizes<ptrdiff_t, 4>(0,2,3,4);
|
||||
extents = Eigen::DSizes<ptrdiff_t, 4>(3,2,1,1);
|
||||
auto slice4 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
|
||||
VERIFY_IS_EQUAL(slice4.dimensions().TotalSize(), 6ul);
|
||||
VERIFY_IS_EQUAL(slice4.dimensions().TotalSize(), 6);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
VERIFY_IS_EQUAL(slice4.data()[i+3*j], tensor(i,2+j,3,4));
|
||||
@ -257,7 +257,7 @@ static void test_slice_raw_data()
|
||||
offsets = Eigen::DSizes<ptrdiff_t, 4>(1,2,3,0);
|
||||
extents = Eigen::DSizes<ptrdiff_t, 4>(1,1,2,11);
|
||||
auto slice4 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
|
||||
VERIFY_IS_EQUAL(slice4.dimensions().TotalSize(), 22ul);
|
||||
VERIFY_IS_EQUAL(slice4.dimensions().TotalSize(), 22);
|
||||
for (int l = 0; l < 11; ++l) {
|
||||
for (int k = 0; k < 2; ++k) {
|
||||
VERIFY_IS_EQUAL(slice4.data()[l+11*k], tensor(1,2,3+k,l));
|
||||
@ -269,7 +269,7 @@ static void test_slice_raw_data()
|
||||
offsets = Eigen::DSizes<ptrdiff_t, 4>(0,0,0,4);
|
||||
extents = Eigen::DSizes<ptrdiff_t, 4>(3,5,7,2);
|
||||
auto slice5 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
|
||||
VERIFY_IS_EQUAL(slice5.dimensions().TotalSize(), 210ul);
|
||||
VERIFY_IS_EQUAL(slice5.dimensions().TotalSize(), 210);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 5; ++j) {
|
||||
for (int k = 0; k < 7; ++k) {
|
||||
@ -284,7 +284,7 @@ static void test_slice_raw_data()
|
||||
offsets = Eigen::DSizes<ptrdiff_t, 4>(1,0,0,0);
|
||||
extents = Eigen::DSizes<ptrdiff_t, 4>(2,5,7,11);
|
||||
auto slice5 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
|
||||
VERIFY_IS_EQUAL(slice5.dimensions().TotalSize(), 770ul);
|
||||
VERIFY_IS_EQUAL(slice5.dimensions().TotalSize(), 770);
|
||||
for (int l = 0; l < 11; ++l) {
|
||||
for (int k = 0; k < 7; ++k) {
|
||||
for (int j = 0; j < 5; ++j) {
|
||||
@ -301,7 +301,7 @@ static void test_slice_raw_data()
|
||||
offsets = Eigen::DSizes<ptrdiff_t, 4>(0,0,0,0);
|
||||
extents = Eigen::DSizes<ptrdiff_t, 4>(3,5,7,11);
|
||||
auto slice6 = SliceEvaluator(tensor.slice(offsets, extents), DefaultDevice());
|
||||
VERIFY_IS_EQUAL(slice6.dimensions().TotalSize(), 3ul*5*7*11);
|
||||
VERIFY_IS_EQUAL(slice6.dimensions().TotalSize(), 3*5*7*11);
|
||||
VERIFY_IS_EQUAL(slice6.data(), tensor.data());
|
||||
}
|
||||
|
||||
@ -315,7 +315,7 @@ static void test_composition()
|
||||
Eigen::Tensor<float, 3, DataLayout> tensor =
|
||||
matrix.slice(DSizes<ptrdiff_t, 2>(2, 0), DSizes<ptrdiff_t, 2>(1, 11)).reshape(newDims);
|
||||
|
||||
VERIFY_IS_EQUAL(tensor.dimensions().TotalSize(), 11ul);
|
||||
VERIFY_IS_EQUAL(tensor.dimensions().TotalSize(), 11);
|
||||
VERIFY_IS_EQUAL(tensor.dimension(0), 1);
|
||||
VERIFY_IS_EQUAL(tensor.dimension(1), 1);
|
||||
VERIFY_IS_EQUAL(tensor.dimension(2), 11);
|
||||
|
@ -67,7 +67,7 @@ static void test_contractions()
|
||||
Eigen::array<DimPair, 2> dims({{DimPair(2, 0), DimPair(3, 1)}});
|
||||
t_result = t_left.contract(t_right, dims);
|
||||
m_result = m_left * m_right;
|
||||
for (size_t i = 0; i < t_result.dimensions().TotalSize(); i++) {
|
||||
for (int i = 0; i < t_result.dimensions().TotalSize(); i++) {
|
||||
VERIFY_IS_APPROX(t_result.data()[i], m_result.data()[i]);
|
||||
}
|
||||
}
|
||||
|
@ -267,21 +267,21 @@ static void test_resize()
|
||||
VERIFY_IS_EQUAL(epsilon.dimension(0), 2);
|
||||
VERIFY_IS_EQUAL(epsilon.dimension(1), 3);
|
||||
VERIFY_IS_EQUAL(epsilon.dimension(2), 7);
|
||||
VERIFY_IS_EQUAL(epsilon.dimensions().TotalSize(), 2ul*3*7);
|
||||
VERIFY_IS_EQUAL(epsilon.dimensions().TotalSize(), 2*3*7);
|
||||
|
||||
const int* old_data = epsilon.data();
|
||||
epsilon.resize(3,2,7);
|
||||
VERIFY_IS_EQUAL(epsilon.dimension(0), 3);
|
||||
VERIFY_IS_EQUAL(epsilon.dimension(1), 2);
|
||||
VERIFY_IS_EQUAL(epsilon.dimension(2), 7);
|
||||
VERIFY_IS_EQUAL(epsilon.dimensions().TotalSize(), 2ul*3*7);
|
||||
VERIFY_IS_EQUAL(epsilon.dimensions().TotalSize(), 2*3*7);
|
||||
VERIFY_IS_EQUAL(epsilon.data(), old_data);
|
||||
|
||||
epsilon.resize(3,5,7);
|
||||
VERIFY_IS_EQUAL(epsilon.dimension(0), 3);
|
||||
VERIFY_IS_EQUAL(epsilon.dimension(1), 5);
|
||||
VERIFY_IS_EQUAL(epsilon.dimension(2), 7);
|
||||
VERIFY_IS_EQUAL(epsilon.dimensions().TotalSize(), 3ul*5*7);
|
||||
VERIFY_IS_EQUAL(epsilon.dimensions().TotalSize(), 3*5*7);
|
||||
VERIFY_IS_NOT_EQUAL(epsilon.data(), old_data);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user