Merged eigen/eigen into default

This commit is contained in:
Rasmus Munk Larsen 2016-11-01 15:37:00 -07:00
commit 0a6ae41555
8 changed files with 38 additions and 35 deletions

View File

@ -15,7 +15,7 @@ namespace Eigen {
namespace internal { namespace internal {
// Most of the following operations require arch >= 3.0 // Most of the following operations require arch >= 3.0
#if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 300 #if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDACC__) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 300
template<> struct is_arithmetic<half2> { enum { value = true }; }; template<> struct is_arithmetic<half2> { enum { value = true }; };

View File

@ -38,7 +38,9 @@ struct traits<TensorEvalToOp<XprType, MakePointer_> >
}; };
template <class T> template <class T>
struct MakePointer { struct MakePointer {
typedef typename MakePointer_<T>::Type Type; // Intermediate typedef to workaround MSVC issue.
typedef MakePointer_<T> MakePointerT;
typedef typename MakePointerT::Type Type;
}; };
}; };

View File

@ -42,9 +42,10 @@ struct traits<TensorForcedEvalOp<XprType, MakePointer_> >
enum { enum {
Flags = 0 Flags = 0
}; };
template <class T> template <class T> struct MakePointer {
struct MakePointer { // Intermediate typedef to workaround MSVC issue.
typedef typename MakePointer_<T>::Type Type; typedef MakePointer_<T> MakePointerT;
typedef typename MakePointerT::Type Type;
}; };
}; };

View File

@ -80,8 +80,8 @@ struct traits<TensorFixedSize<Scalar_, Dimensions, Options_, IndexType_> >
}; };
template<typename PlainObjectType, int Options_ , template <class> class MakePointer_> template<typename PlainObjectType, int Options_, template <class> class MakePointer_>
struct traits<TensorMap<PlainObjectType, Options_ , MakePointer_> > struct traits<TensorMap<PlainObjectType, Options_, MakePointer_> >
: public traits<PlainObjectType> : public traits<PlainObjectType>
{ {
typedef traits<PlainObjectType> BaseTraits; typedef traits<PlainObjectType> BaseTraits;
@ -142,16 +142,16 @@ struct eval<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>, Eig
typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>& type; typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>& type;
}; };
template<typename PlainObjectType, int Options> template<typename PlainObjectType, int Options, template <class> class MakePointer>
struct eval<TensorMap<PlainObjectType, Options>, Eigen::Dense> struct eval<TensorMap<PlainObjectType, Options, MakePointer>, Eigen::Dense>
{ {
typedef const TensorMap<PlainObjectType, Options>& type; typedef const TensorMap<PlainObjectType, Options, MakePointer>& type;
}; };
template<typename PlainObjectType, int Options> template<typename PlainObjectType, int Options, template <class> class MakePointer>
struct eval<const TensorMap<PlainObjectType, Options>, Eigen::Dense> struct eval<const TensorMap<PlainObjectType, Options, MakePointer>, Eigen::Dense>
{ {
typedef const TensorMap<PlainObjectType, Options>& type; typedef const TensorMap<PlainObjectType, Options, MakePointer>& type;
}; };
template<typename PlainObjectType> template<typename PlainObjectType>
@ -197,16 +197,16 @@ struct nested<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> >
}; };
template <typename PlainObjectType, int Options> template <typename PlainObjectType, int Options, template <class> class MakePointer>
struct nested<TensorMap<PlainObjectType, Options> > struct nested<TensorMap<PlainObjectType, Options, MakePointer> >
{ {
typedef const TensorMap<PlainObjectType, Options>& type; typedef const TensorMap<PlainObjectType, Options, MakePointer>& type;
}; };
template <typename PlainObjectType, int Options> template <typename PlainObjectType, int Options, template <class> class MakePointer>
struct nested<const TensorMap<PlainObjectType, Options> > struct nested<const TensorMap<PlainObjectType, Options, MakePointer> >
{ {
typedef const TensorMap<PlainObjectType, Options>& type; typedef const TensorMap<PlainObjectType, Options, MakePointer>& type;
}; };
template <typename PlainObjectType> template <typename PlainObjectType>

View File

@ -69,7 +69,7 @@ void test_cuda_contraction(int m_size, int k_size, int n_size)
t_result = t_left.contract(t_right, dims); t_result = t_left.contract(t_right, dims);
cudaMemcpy(t_result_gpu.data(), d_t_result, t_result_bytes, cudaMemcpyDeviceToHost); cudaMemcpy(t_result_gpu.data(), d_t_result, t_result_bytes, cudaMemcpyDeviceToHost);
for (size_t i = 0; i < t_result.size(); i++) { for (DenseIndex i = 0; i < t_result.size(); i++) {
if (fabs(t_result(i) - t_result_gpu(i)) < 1e-4f) { if (fabs(t_result(i) - t_result_gpu(i)) < 1e-4f) {
continue; continue;
} }

View File

@ -303,8 +303,8 @@ void test_cuda_contraction()
cudaMemcpy(t_result.data(), d_t_result, t_result_bytes, cudaMemcpyDeviceToHost); cudaMemcpy(t_result.data(), d_t_result, t_result_bytes, cudaMemcpyDeviceToHost);
for (size_t i = 0; i < t_result.dimensions().TotalSize(); i++) { for (DenseIndex i = 0; i < t_result.size(); i++) {
if (fabs(t_result.data()[i] - m_result.data()[i]) >= 1e-4) { if (fabs(t_result.data()[i] - m_result.data()[i]) >= 1e-4f) {
std::cout << "mismatch detected at index " << i << ": " << t_result.data()[i] << " vs " << m_result.data()[i] << std::endl; std::cout << "mismatch detected at index " << i << ": " << t_result.data()[i] << " vs " << m_result.data()[i] << std::endl;
assert(false); assert(false);
} }

View File

@ -13,7 +13,7 @@
using Eigen::Tensor; using Eigen::Tensor;
static void test_simple_patch() void test_simple_patch()
{ {
Tensor<float, 4> tensor(2,3,5,7); Tensor<float, 4> tensor(2,3,5,7);
tensor.setRandom(); tensor.setRandom();
@ -180,7 +180,7 @@ static void test_simple_patch()
} }
// Verifies VALID padding (no padding) with incrementing values. // Verifies VALID padding (no padding) with incrementing values.
static void test_patch_padding_valid() void test_patch_padding_valid()
{ {
int input_depth = 3; int input_depth = 3;
int input_rows = 3; int input_rows = 3;
@ -256,7 +256,7 @@ static void test_patch_padding_valid()
} }
// Verifies VALID padding (no padding) with the same value. // Verifies VALID padding (no padding) with the same value.
static void test_patch_padding_valid_same_value() void test_patch_padding_valid_same_value()
{ {
int input_depth = 1; int input_depth = 1;
int input_rows = 5; int input_rows = 5;
@ -329,7 +329,7 @@ static void test_patch_padding_valid_same_value()
} }
// Verifies SAME padding. // Verifies SAME padding.
static void test_patch_padding_same() void test_patch_padding_same()
{ {
int input_depth = 3; int input_depth = 3;
int input_rows = 4; int input_rows = 4;
@ -405,7 +405,7 @@ static void test_patch_padding_same()
} }
} }
static void test_patch_no_extra_dim() void test_patch_no_extra_dim()
{ {
Tensor<float, 3> tensor(2,3,5); Tensor<float, 3> tensor(2,3,5);
tensor.setRandom(); tensor.setRandom();
@ -553,7 +553,7 @@ static void test_patch_no_extra_dim()
} }
} }
static void test_imagenet_patches() void test_imagenet_patches()
{ {
// Test the code on typical configurations used by the 'imagenet' benchmarks at // Test the code on typical configurations used by the 'imagenet' benchmarks at
// https://github.com/soumith/convnet-benchmarks // https://github.com/soumith/convnet-benchmarks
@ -748,10 +748,10 @@ static void test_imagenet_patches()
void test_cxx11_tensor_image_patch() void test_cxx11_tensor_image_patch()
{ {
CALL_SUBTEST(test_simple_patch()); CALL_SUBTEST_1(test_simple_patch());
CALL_SUBTEST(test_patch_no_extra_dim()); CALL_SUBTEST_2(test_patch_no_extra_dim());
CALL_SUBTEST(test_patch_padding_valid()); CALL_SUBTEST_3(test_patch_padding_valid());
CALL_SUBTEST(test_patch_padding_valid_same_value()); CALL_SUBTEST_4(test_patch_padding_valid_same_value());
CALL_SUBTEST(test_patch_padding_same()); CALL_SUBTEST_5(test_patch_padding_same());
CALL_SUBTEST(test_imagenet_patches()); CALL_SUBTEST_6(test_imagenet_patches());
} }

View File

@ -55,7 +55,7 @@ void test_cuda_cumsum(int m_size, int k_size, int n_size)
t_result = t_input.cumsum(1); t_result = t_input.cumsum(1);
cudaMemcpy(t_result_gpu.data(), d_t_result, t_result_bytes, cudaMemcpyDeviceToHost); cudaMemcpy(t_result_gpu.data(), d_t_result, t_result_bytes, cudaMemcpyDeviceToHost);
for (size_t i = 0; i < t_result.size(); i++) { for (DenseIndex i = 0; i < t_result.size(); i++) {
if (fabs(t_result(i) - t_result_gpu(i)) < 1e-4f) { if (fabs(t_result(i) - t_result_gpu(i)) < 1e-4f) {
continue; continue;
} }