mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 02:33:59 +08:00
Fix usages of Eigen::array to be compatible with std::array.
This commit is contained in:
parent
77833f9320
commit
13092b5d04
@ -898,8 +898,8 @@ struct TensorEvaluator<const TensorConvolutionOp<Indices, InputArgType, KernelAr
|
||||
// num_blocks.x: " << num_blocks.x << " num_blocks.y: " << num_blocks.y << " maxX: " << maxX << " shared_mem: "
|
||||
// << shared_mem << " in stream " << m_device.stream() << endl;
|
||||
|
||||
const array<Index, 1> indices(m_indices[0]);
|
||||
const array<Index, 1> kernel_dims(m_kernelImpl.dimensions()[0]);
|
||||
const array<Index, 1> indices{m_indices[0]};
|
||||
const array<Index, 1> kernel_dims{m_kernelImpl.dimensions()[0]};
|
||||
internal::IndexMapper<Index, InputDims, 1, Layout> indexMapper(m_inputImpl.dimensions(), kernel_dims, indices);
|
||||
switch (kernel_size) {
|
||||
case 4: {
|
||||
@ -965,8 +965,8 @@ struct TensorEvaluator<const TensorConvolutionOp<Indices, InputArgType, KernelAr
|
||||
// " num_blocks.z: " << num_blocks.z << " maxX: " << maxX << " maxY: " << maxY << " maxP: " << maxP << "
|
||||
// shared_mem: " << shared_mem << " in stream " << m_device.stream() << endl;
|
||||
|
||||
const array<Index, 2> indices(m_indices[idxX], m_indices[idxY]);
|
||||
const array<Index, 2> kernel_dims(m_kernelImpl.dimensions()[idxX], m_kernelImpl.dimensions()[idxY]);
|
||||
const array<Index, 2> indices{m_indices[idxX], m_indices[idxY]};
|
||||
const array<Index, 2> kernel_dims{m_kernelImpl.dimensions()[idxX], m_kernelImpl.dimensions()[idxY]};
|
||||
internal::IndexMapper<Index, InputDims, 2, Layout> indexMapper(m_inputImpl.dimensions(), kernel_dims, indices);
|
||||
switch (kernel_size_x) {
|
||||
case 4: {
|
||||
@ -1059,9 +1059,9 @@ struct TensorEvaluator<const TensorConvolutionOp<Indices, InputArgType, KernelAr
|
||||
// block_size.z: " << block_size.z << " num_blocks.x: " << num_blocks.x << " num_blocks.y: " << num_blocks.y <<
|
||||
// " num_blocks.z: " << num_blocks.z << " shared_mem: " << shared_mem << " in stream " << m_device.stream() <<
|
||||
// endl;
|
||||
const array<Index, 3> indices(m_indices[idxX], m_indices[idxY], m_indices[idxZ]);
|
||||
const array<Index, 3> kernel_dims(m_kernelImpl.dimensions()[idxX], m_kernelImpl.dimensions()[idxY],
|
||||
m_kernelImpl.dimensions()[idxZ]);
|
||||
const array<Index, 3> indices{m_indices[idxX], m_indices[idxY], m_indices[idxZ]};
|
||||
const array<Index, 3> kernel_dims{m_kernelImpl.dimensions()[idxX], m_kernelImpl.dimensions()[idxY],
|
||||
m_kernelImpl.dimensions()[idxZ]};
|
||||
internal::IndexMapper<Index, InputDims, 3, Layout> indexMapper(m_inputImpl.dimensions(), kernel_dims, indices);
|
||||
|
||||
LAUNCH_GPU_KERNEL((EigenConvolutionKernel3D<TensorEvaluator<InputArgType, GpuDevice>, Index, InputDims>),
|
||||
|
@ -977,11 +977,12 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M
|
||||
// Dimensions of the output of the operation.
|
||||
Dimensions m_dimensions;
|
||||
// Precomputed strides for the output tensor.
|
||||
array<Index, NumOutputDims> m_outputStrides;
|
||||
array<internal::TensorIntDivisor<Index>, NumOutputDims> m_fastOutputStrides;
|
||||
array<Index, NumPreservedStrides> m_preservedStrides;
|
||||
// Avoid zero-sized arrays, since element access fails to compile on GPU.
|
||||
array<Index, (std::max)(NumOutputDims, 1)> m_outputStrides;
|
||||
array<internal::TensorIntDivisor<Index>, (std::max)(NumOutputDims, 1)> m_fastOutputStrides;
|
||||
array<Index, (std::max)(NumPreservedStrides, 1)> m_preservedStrides;
|
||||
// Map from output to input dimension index.
|
||||
array<Index, NumOutputDims> m_output_to_input_dim_map;
|
||||
array<Index, (std::max)(NumOutputDims, 1)> m_output_to_input_dim_map;
|
||||
// How many values go into each reduction
|
||||
Index m_numValuesToReduce;
|
||||
|
||||
|
@ -20,7 +20,7 @@ using Eigen::Tensor;
|
||||
|
||||
template <int Layout>
|
||||
void test_gpu_simple_argmax() {
|
||||
Tensor<double, 3, Layout> in(Eigen::array<DenseIndex, 3>(72, 53, 97));
|
||||
Tensor<double, 3, Layout> in(Eigen::array<DenseIndex, 3>{72, 53, 97});
|
||||
Tensor<DenseIndex, 0, Layout> out_max;
|
||||
Tensor<DenseIndex, 0, Layout> out_min;
|
||||
in.setRandom();
|
||||
@ -43,7 +43,7 @@ void test_gpu_simple_argmax() {
|
||||
Eigen::GpuStreamDevice stream;
|
||||
Eigen::GpuDevice gpu_device(&stream);
|
||||
|
||||
Eigen::TensorMap<Eigen::Tensor<double, 3, Layout>, Aligned> gpu_in(d_in, Eigen::array<DenseIndex, 3>(72, 53, 97));
|
||||
Eigen::TensorMap<Eigen::Tensor<double, 3, Layout>, Aligned> gpu_in(d_in, Eigen::array<DenseIndex, 3>{72, 53, 97});
|
||||
Eigen::TensorMap<Eigen::Tensor<DenseIndex, 0, Layout>, Aligned> gpu_out_max(d_out_max);
|
||||
Eigen::TensorMap<Eigen::Tensor<DenseIndex, 0, Layout>, Aligned> gpu_out_min(d_out_min);
|
||||
|
||||
@ -113,7 +113,7 @@ void test_gpu_argmax_dim() {
|
||||
Eigen::GpuDevice gpu_device(&stream);
|
||||
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout>, Aligned> gpu_in(d_in,
|
||||
Eigen::array<DenseIndex, 4>(2, 3, 5, 7));
|
||||
Eigen::array<DenseIndex, 4>{2, 3, 5, 7});
|
||||
Eigen::TensorMap<Eigen::Tensor<DenseIndex, 3, DataLayout>, Aligned> gpu_out(d_out, out_shape);
|
||||
|
||||
gpu_out.device(gpu_device) = gpu_in.argmax(dim);
|
||||
@ -212,7 +212,7 @@ void test_gpu_argmin_dim() {
|
||||
Eigen::GpuDevice gpu_device(&stream);
|
||||
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout>, Aligned> gpu_in(d_in,
|
||||
Eigen::array<DenseIndex, 4>(2, 3, 5, 7));
|
||||
Eigen::array<DenseIndex, 4>{2, 3, 5, 7});
|
||||
Eigen::TensorMap<Eigen::Tensor<DenseIndex, 3, DataLayout>, Aligned> gpu_out(d_out, out_shape);
|
||||
|
||||
gpu_out.device(gpu_device) = gpu_in.argmin(dim);
|
||||
|
@ -28,7 +28,7 @@ void test_gpu_contraction(int m_size, int k_size, int n_size) {
|
||||
Tensor<float, 2, DataLayout> t_right(k_size, n_size);
|
||||
Tensor<float, 2, DataLayout> t_result(m_size, n_size);
|
||||
Tensor<float, 2, DataLayout> t_result_gpu(m_size, n_size);
|
||||
Eigen::array<DimPair, 1> dims(DimPair(1, 0));
|
||||
Eigen::array<DimPair, 1> dims{DimPair(1, 0)};
|
||||
|
||||
t_left.setRandom();
|
||||
t_right.setRandom();
|
||||
@ -51,9 +51,9 @@ void test_gpu_contraction(int m_size, int k_size, int n_size) {
|
||||
Eigen::GpuStreamDevice stream;
|
||||
Eigen::GpuDevice gpu_device(&stream);
|
||||
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 2, DataLayout> > gpu_t_left(d_t_left, Eigen::array<int, 2>(m_size, k_size));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 2, DataLayout> > gpu_t_right(d_t_right, Eigen::array<int, 2>(k_size, n_size));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 2, DataLayout> > gpu_t_result(d_t_result, Eigen::array<int, 2>(m_size, n_size));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 2, DataLayout> > gpu_t_left(d_t_left, Eigen::array<int, 2>{m_size, k_size});
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 2, DataLayout> > gpu_t_right(d_t_right, Eigen::array<int, 2>{k_size, n_size});
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 2, DataLayout> > gpu_t_result(d_t_result, Eigen::array<int, 2>{m_size, n_size});
|
||||
|
||||
gpu_t_result.device(gpu_device) = gpu_t_left.contract(gpu_t_right, dims);
|
||||
t_result = t_left.contract(t_right, dims);
|
||||
@ -85,7 +85,7 @@ void test_scalar(int m_size, int k_size, int n_size) {
|
||||
Tensor<float, 2, DataLayout> t_right(k_size, n_size);
|
||||
Tensor<float, 0, DataLayout> t_result;
|
||||
Tensor<float, 0, DataLayout> t_result_gpu;
|
||||
Eigen::array<DimPair, 2> dims(DimPair(0, 0), DimPair(1, 1));
|
||||
Eigen::array<DimPair, 2> dims{DimPair(0, 0), DimPair(1, 1)};
|
||||
|
||||
t_left.setRandom();
|
||||
t_right.setRandom();
|
||||
|
@ -140,7 +140,7 @@ void test_contraction(Context* context) {
|
||||
dims[0] = std::make_pair(1, 1);
|
||||
dims[1] = std::make_pair(2, 2);
|
||||
|
||||
Eigen::array<int, 2> shape(40, 50 * 70);
|
||||
Eigen::array<int, 2> shape{40, 50 * 70};
|
||||
|
||||
Eigen::DSizes<int, 2> indices(0, 0);
|
||||
Eigen::DSizes<int, 2> sizes(40, 40);
|
||||
@ -154,7 +154,7 @@ void test_1d_convolution(Context* context) {
|
||||
Eigen::DSizes<int, 3> indices(0, 0, 0);
|
||||
Eigen::DSizes<int, 3> sizes(40, 49, 70);
|
||||
|
||||
Eigen::array<int, 1> dims(1);
|
||||
Eigen::array<int, 1> dims{1};
|
||||
context->out().slice(indices, sizes).device(context->device()) = context->in1().convolve(context->kernel1d(), dims);
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ void test_2d_convolution(Context* context) {
|
||||
Eigen::DSizes<int, 3> indices(0, 0, 0);
|
||||
Eigen::DSizes<int, 3> sizes(40, 49, 69);
|
||||
|
||||
Eigen::array<int, 2> dims(1, 2);
|
||||
Eigen::array<int, 2> dims{1, 2};
|
||||
context->out().slice(indices, sizes).device(context->device()) = context->in1().convolve(context->kernel2d(), dims);
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ void test_3d_convolution(Context* context) {
|
||||
Eigen::DSizes<int, 3> indices(0, 0, 0);
|
||||
Eigen::DSizes<int, 3> sizes(39, 49, 69);
|
||||
|
||||
Eigen::array<int, 3> dims(0, 1, 2);
|
||||
Eigen::array<int, 3> dims{0, 1, 2};
|
||||
context->out().slice(indices, sizes).device(context->device()) = context->in1().convolve(context->kernel3d(), dims);
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ void synchronize(Eigen::GpuDevice& device) {
|
||||
template <typename DataType, typename TensorDevice>
|
||||
void test_device_memory(const TensorDevice& device) {
|
||||
int count = 100;
|
||||
Eigen::array<int, 1> tensorRange = {{count}};
|
||||
Eigen::array<int, 1> tensorRange{count};
|
||||
Eigen::Tensor<DataType, 1> host(tensorRange);
|
||||
Eigen::Tensor<DataType, 1> expected(tensorRange);
|
||||
DataType* device_data = static_cast<DataType*>(device.allocate(count * sizeof(DataType)));
|
||||
|
@ -99,9 +99,9 @@ void test_gpu_nullary_max_size() {
|
||||
}
|
||||
|
||||
void test_gpu_elementwise_small() {
|
||||
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));
|
||||
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();
|
||||
|
||||
@ -122,9 +122,9 @@ void test_gpu_elementwise_small() {
|
||||
Eigen::GpuStreamDevice stream;
|
||||
Eigen::GpuDevice gpu_device(&stream);
|
||||
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_in1(d_in1, Eigen::array<Eigen::DenseIndex, 1>(2));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_in2(d_in2, Eigen::array<Eigen::DenseIndex, 1>(2));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_out(d_out, Eigen::array<Eigen::DenseIndex, 1>(2));
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_in1(d_in1, Eigen::array<Eigen::DenseIndex, 1>{2});
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_in2(d_in2, Eigen::array<Eigen::DenseIndex, 1>{2});
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_out(d_out, Eigen::array<Eigen::DenseIndex, 1>{2});
|
||||
|
||||
gpu_out.device(gpu_device) = gpu_in1 + gpu_in2;
|
||||
|
||||
@ -132,8 +132,8 @@ void test_gpu_elementwise_small() {
|
||||
assert(gpuStreamSynchronize(gpu_device.stream()) == gpuSuccess);
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
VERIFY_IS_APPROX(out(Eigen::array<Eigen::DenseIndex, 1>(i)),
|
||||
in1(Eigen::array<Eigen::DenseIndex, 1>(i)) + in2(Eigen::array<Eigen::DenseIndex, 1>(i)));
|
||||
VERIFY_IS_APPROX(out(Eigen::array<Eigen::DenseIndex, 1>{i}),
|
||||
in1(Eigen::array<Eigen::DenseIndex, 1>{i}) + in2(Eigen::array<Eigen::DenseIndex, 1>{i}));
|
||||
}
|
||||
|
||||
gpuFree(d_in1);
|
||||
@ -142,10 +142,10 @@ void test_gpu_elementwise_small() {
|
||||
}
|
||||
|
||||
void test_gpu_elementwise() {
|
||||
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));
|
||||
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();
|
||||
@ -171,10 +171,10 @@ void test_gpu_elementwise() {
|
||||
Eigen::GpuStreamDevice stream;
|
||||
Eigen::GpuDevice gpu_device(&stream);
|
||||
|
||||
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));
|
||||
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;
|
||||
|
||||
@ -185,9 +185,9 @@ void test_gpu_elementwise() {
|
||||
for (int j = 0; j < 53; ++j) {
|
||||
for (int k = 0; k < 97; ++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)));
|
||||
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}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -284,8 +284,8 @@ void test_gpu_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<Eigen::DenseIndex, 5>(3, 31, 7, 20, 1));
|
||||
Tensor<float, 5, DataLayout> t_result(Eigen::array<Eigen::DenseIndex, 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();
|
||||
@ -369,7 +369,7 @@ void test_gpu_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<Eigen::DenseIndex, 1> dims(1);
|
||||
Eigen::array<Eigen::DenseIndex, 1> dims{1};
|
||||
gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
|
||||
|
||||
assert(gpuMemcpyAsync(out.data(), d_out, out_bytes, gpuMemcpyDeviceToHost, gpu_device.stream()) == gpuSuccess);
|
||||
@ -421,7 +421,7 @@ void test_gpu_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<Eigen::DenseIndex, 1> dims(0);
|
||||
Eigen::array<Eigen::DenseIndex, 1> dims{0};
|
||||
gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
|
||||
|
||||
assert(gpuMemcpyAsync(out.data(), d_out, out_bytes, gpuMemcpyDeviceToHost, gpu_device.stream()) == gpuSuccess);
|
||||
@ -473,7 +473,7 @@ void test_gpu_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<Eigen::DenseIndex, 1> dims(3);
|
||||
Eigen::array<Eigen::DenseIndex, 1> dims{3};
|
||||
gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
|
||||
|
||||
assert(gpuMemcpyAsync(out.data(), d_out, out_bytes, gpuMemcpyDeviceToHost, gpu_device.stream()) == gpuSuccess);
|
||||
@ -526,7 +526,7 @@ void test_gpu_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<Eigen::DenseIndex, 2> dims(1, 2);
|
||||
Eigen::array<Eigen::DenseIndex, 2> dims{1, 2};
|
||||
gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims);
|
||||
|
||||
assert(gpuMemcpyAsync(out.data(), d_out, out_bytes, gpuMemcpyDeviceToHost, gpu_device.stream()) == gpuSuccess);
|
||||
@ -556,9 +556,9 @@ void test_gpu_convolution_2d() {
|
||||
|
||||
template <int DataLayout>
|
||||
void test_gpu_convolution_3d() {
|
||||
Tensor<float, 5, DataLayout> input(Eigen::array<Eigen::DenseIndex, 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<Eigen::DenseIndex, 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();
|
||||
|
||||
@ -583,7 +583,7 @@ void test_gpu_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<Eigen::DenseIndex, 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(gpuMemcpyAsync(out.data(), d_out, out_bytes, gpuMemcpyDeviceToHost, gpu_device.stream()) == gpuSuccess);
|
||||
|
@ -281,7 +281,7 @@ void test_gpu_contractions() {
|
||||
gpu_float2.device(gpu_device) = gpu_float2.random() - gpu_float2.constant(0.5f);
|
||||
|
||||
typedef Tensor<float, 2>::DimensionPair DimPair;
|
||||
Eigen::array<DimPair, 1> dims(DimPair(1, 0));
|
||||
Eigen::array<DimPair, 1> dims{DimPair(1, 0)};
|
||||
gpu_res_float.device(gpu_device) = gpu_float1.contract(gpu_float2, dims).cast<Eigen::half>();
|
||||
gpu_res_half.device(gpu_device) = gpu_float1.cast<Eigen::half>().contract(gpu_float2.cast<Eigen::half>(), dims);
|
||||
|
||||
|
@ -45,9 +45,9 @@ void test_gpu_cumsum(int m_size, int k_size, int n_size) {
|
||||
Eigen::GpuDevice gpu_device(&stream);
|
||||
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 3, DataLayout> > gpu_t_input(d_t_input,
|
||||
Eigen::array<int, 3>(m_size, k_size, n_size));
|
||||
Eigen::array<int, 3>{m_size, k_size, n_size});
|
||||
Eigen::TensorMap<Eigen::Tensor<float, 3, DataLayout> > gpu_t_result(d_t_result,
|
||||
Eigen::array<int, 3>(m_size, k_size, n_size));
|
||||
Eigen::array<int, 3>{m_size, k_size, n_size});
|
||||
|
||||
gpu_t_result.device(gpu_device) = gpu_t_input.cumsum(1);
|
||||
t_result = t_input.cumsum(1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user