mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-29 07:14:12 +08:00
Fix the cxx11_tensor_cuda.cu test on 32bit platforms.
This commit is contained in:
parent
49c0390ce0
commit
6c05c3dd49
@ -64,9 +64,9 @@ void test_cuda_nullary() {
|
||||
}
|
||||
|
||||
void test_cuda_elementwise_small() {
|
||||
Tensor<float, 1> in1(Eigen::array<int64_t, 1>(2));
|
||||
Tensor<float, 1> in2(Eigen::array<int64_t, 1>(2));
|
||||
Tensor<float, 1> out(Eigen::array<int64_t, 1>(2));
|
||||
Tensor<float, 1> in1(Eigen::array<Eigen::DenseIndex, 1>(2));
|
||||
Tensor<float, 1> in2(Eigen::array<Eigen::DenseIndex, 1>(2));
|
||||
Tensor<float, 1> out(Eigen::array<Eigen::DenseIndex, 1>(2));
|
||||
in1.setRandom();
|
||||
in2.setRandom();
|
||||
|
||||
@ -88,11 +88,11 @@ void test_cuda_elementwise_small() {
|
||||
Eigen::GpuDevice gpu_device(&stream);
|
||||
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_in1(
|
||||
d_in1, Eigen::array<int64_t, 1>(2));
|
||||
d_in1, Eigen::array<Eigen::DenseIndex, 1>(2));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_in2(
|
||||
d_in2, Eigen::array<int64_t, 1>(2));
|
||||
d_in2, Eigen::array<Eigen::DenseIndex, 1>(2));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_out(
|
||||
d_out, Eigen::array<int64_t, 1>(2));
|
||||
d_out, Eigen::array<Eigen::DenseIndex, 1>(2));
|
||||
|
||||
gpu_out.device(gpu_device) = gpu_in1 + gpu_in2;
|
||||
|
||||
@ -102,8 +102,8 @@ void test_cuda_elementwise_small() {
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
VERIFY_IS_APPROX(
|
||||
out(Eigen::array<int64_t, 1>(i)),
|
||||
in1(Eigen::array<int64_t, 1>(i)) + in2(Eigen::array<int64_t, 1>(i)));
|
||||
out(Eigen::array<Eigen::DenseIndex, 1>(i)),
|
||||
in1(Eigen::array<Eigen::DenseIndex, 1>(i)) + in2(Eigen::array<Eigen::DenseIndex, 1>(i)));
|
||||
}
|
||||
|
||||
cudaFree(d_in1);
|
||||
@ -113,10 +113,10 @@ void test_cuda_elementwise_small() {
|
||||
|
||||
void test_cuda_elementwise()
|
||||
{
|
||||
Tensor<float, 3> in1(Eigen::array<int64_t, 3>(72,53,97));
|
||||
Tensor<float, 3> in2(Eigen::array<int64_t, 3>(72,53,97));
|
||||
Tensor<float, 3> in3(Eigen::array<int64_t, 3>(72,53,97));
|
||||
Tensor<float, 3> out(Eigen::array<int64_t, 3>(72,53,97));
|
||||
Tensor<float, 3> in1(Eigen::array<Eigen::DenseIndex, 3>(72,53,97));
|
||||
Tensor<float, 3> in2(Eigen::array<Eigen::DenseIndex, 3>(72,53,97));
|
||||
Tensor<float, 3> in3(Eigen::array<Eigen::DenseIndex, 3>(72,53,97));
|
||||
Tensor<float, 3> out(Eigen::array<Eigen::DenseIndex, 3>(72,53,97));
|
||||
in1.setRandom();
|
||||
in2.setRandom();
|
||||
in3.setRandom();
|
||||
@ -142,10 +142,10 @@ void test_cuda_elementwise()
|
||||
Eigen::CudaStreamDevice stream;
|
||||
Eigen::GpuDevice gpu_device(&stream);
|
||||
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_in1(d_in1, Eigen::array<int64_t, 3>(72,53,97));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_in2(d_in2, Eigen::array<int64_t, 3>(72,53,97));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_in3(d_in3, Eigen::array<int64_t, 3>(72,53,97));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_out(d_out, Eigen::array<int64_t, 3>(72,53,97));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_in1(d_in1, Eigen::array<Eigen::DenseIndex, 3>(72,53,97));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_in2(d_in2, Eigen::array<Eigen::DenseIndex, 3>(72,53,97));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_in3(d_in3, Eigen::array<Eigen::DenseIndex, 3>(72,53,97));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_out(d_out, Eigen::array<Eigen::DenseIndex, 3>(72,53,97));
|
||||
|
||||
gpu_out.device(gpu_device) = gpu_in1 + gpu_in2 * gpu_in3;
|
||||
|
||||
@ -155,7 +155,7 @@ void test_cuda_elementwise()
|
||||
for (int i = 0; i < 72; ++i) {
|
||||
for (int j = 0; j < 53; ++j) {
|
||||
for (int k = 0; k < 97; ++k) {
|
||||
VERIFY_IS_APPROX(out(Eigen::array<int64_t, 3>(i,j,k)), in1(Eigen::array<int64_t, 3>(i,j,k)) + in2(Eigen::array<int64_t, 3>(i,j,k)) * in3(Eigen::array<int64_t, 3>(i,j,k)));
|
||||
VERIFY_IS_APPROX(out(Eigen::array<Eigen::DenseIndex, 3>(i,j,k)), in1(Eigen::array<Eigen::DenseIndex, 3>(i,j,k)) + in2(Eigen::array<Eigen::DenseIndex, 3>(i,j,k)) * in3(Eigen::array<Eigen::DenseIndex, 3>(i,j,k)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -225,7 +225,7 @@ void test_cuda_reduction()
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 4> > gpu_in1(d_in1, 72,53,97,113);
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 2> > gpu_out(d_out, 72,97);
|
||||
|
||||
array<int64_t, 2> reduction_axis;
|
||||
array<Eigen::DenseIndex, 2> reduction_axis;
|
||||
reduction_axis[0] = 1;
|
||||
reduction_axis[1] = 3;
|
||||
|
||||
@ -258,8 +258,8 @@ void test_cuda_contraction()
|
||||
// more than 30 * 1024, which is the number of threads in blocks on
|
||||
// a 15 SM GK110 GPU
|
||||
Tensor<float, 4, DataLayout> t_left(6, 50, 3, 31);
|
||||
Tensor<float, 5, DataLayout> t_right(Eigen::array<int64_t, 5>(3, 31, 7, 20, 1));
|
||||
Tensor<float, 5, DataLayout> t_result(Eigen::array<int64_t, 5>(6, 50, 7, 20, 1));
|
||||
Tensor<float, 5, DataLayout> t_right(Eigen::array<Eigen::DenseIndex, 5>(3, 31, 7, 20, 1));
|
||||
Tensor<float, 5, DataLayout> t_result(Eigen::array<Eigen::DenseIndex, 5>(6, 50, 7, 20, 1));
|
||||
|
||||
t_left.setRandom();
|
||||
t_right.setRandom();
|
||||
@ -343,7 +343,7 @@ void test_cuda_convolution_1d()
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 1, DataLayout> > gpu_kernel(d_kernel, 4);
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout> > gpu_out(d_out, 74,34,11,137);
|
||||
|
||||
Eigen::array<int64_t, 1> dims(1);
|
||||
Eigen::array<Eigen::DenseIndex, 1> dims(1);
|
||||
gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
|
||||
|
||||
assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess);
|
||||
@ -396,7 +396,7 @@ void test_cuda_convolution_inner_dim_col_major_1d()
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 1, ColMajor> > gpu_kernel(d_kernel,4);
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 4, ColMajor> > gpu_out(d_out,71,9,11,7);
|
||||
|
||||
Eigen::array<int64_t, 1> dims(0);
|
||||
Eigen::array<Eigen::DenseIndex, 1> dims(0);
|
||||
gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
|
||||
|
||||
assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess);
|
||||
@ -449,7 +449,7 @@ void test_cuda_convolution_inner_dim_row_major_1d()
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 1, RowMajor> > gpu_kernel(d_kernel, 4);
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 4, RowMajor> > gpu_out(d_out, 7,9,11,71);
|
||||
|
||||
Eigen::array<int64_t, 1> dims(3);
|
||||
Eigen::array<Eigen::DenseIndex, 1> dims(3);
|
||||
gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
|
||||
|
||||
assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess);
|
||||
@ -503,7 +503,7 @@ void test_cuda_convolution_2d()
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 2, DataLayout> > gpu_kernel(d_kernel,3,4);
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout> > gpu_out(d_out,74,35,8,137);
|
||||
|
||||
Eigen::array<int64_t, 2> dims(1,2);
|
||||
Eigen::array<Eigen::DenseIndex, 2> dims(1,2);
|
||||
gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
|
||||
|
||||
assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess);
|
||||
@ -540,9 +540,9 @@ void test_cuda_convolution_2d()
|
||||
template<int DataLayout>
|
||||
void test_cuda_convolution_3d()
|
||||
{
|
||||
Tensor<float, 5, DataLayout> input(Eigen::array<int64_t, 5>(74,37,11,137,17));
|
||||
Tensor<float, 5, DataLayout> input(Eigen::array<Eigen::DenseIndex, 5>(74,37,11,137,17));
|
||||
Tensor<float, 3, DataLayout> kernel(3,4,2);
|
||||
Tensor<float, 5, DataLayout> out(Eigen::array<int64_t, 5>(74,35,8,136,17));
|
||||
Tensor<float, 5, DataLayout> out(Eigen::array<Eigen::DenseIndex, 5>(74,35,8,136,17));
|
||||
input = input.constant(10.0f) + input.random();
|
||||
kernel = kernel.constant(7.0f) + kernel.random();
|
||||
|
||||
@ -567,7 +567,7 @@ void test_cuda_convolution_3d()
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 3, DataLayout> > gpu_kernel(d_kernel,3,4,2);
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 5, DataLayout> > gpu_out(d_out,74,35,8,136,17);
|
||||
|
||||
Eigen::array<int64_t, 3> dims(1,2,3);
|
||||
Eigen::array<Eigen::DenseIndex, 3> dims(1,2,3);
|
||||
gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
|
||||
|
||||
assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess);
|
||||
|
Loading…
x
Reference in New Issue
Block a user