/external/eigen/unsupported/test/ |
D | cxx11_tensor_argmax.cpp | 22 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_simple_index_tuples() local 23 tensor.setRandom(); in test_simple_index_tuples() 24 tensor = (tensor + tensor.constant(0.5)).log(); in test_simple_index_tuples() 27 index_tuples = tensor.index_tuples(); in test_simple_index_tuples() 32 VERIFY_IS_EQUAL(v.second, tensor.coeff(n)); in test_simple_index_tuples() 39 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_index_tuples_dim() local 40 tensor.setRandom(); in test_index_tuples_dim() 41 tensor = (tensor + tensor.constant(0.5)).log(); in test_index_tuples_dim() 45 index_tuples = tensor.index_tuples(); in test_index_tuples_dim() 47 for (Eigen::DenseIndex n = 0; n < tensor.size(); ++n) { in test_index_tuples_dim() [all …]
|
D | cxx11_tensor_custom_index.cpp | 24 Tensor<float, 4, DataLayout> tensor(2, 3, 5, 7); in test_map_as_index() local 25 tensor.setRandom(); in test_map_as_index() 36 VERIFY_IS_EQUAL(tensor.coeff(coeffC), tensor.coeff(coeff)); in test_map_as_index() 37 VERIFY_IS_EQUAL(tensor.coeffRef(coeffC), tensor.coeffRef(coeff)); in test_map_as_index() 46 Tensor<float, 4, DataLayout> tensor(2, 3, 5, 7); in test_matrix_as_index() local 47 tensor.setRandom(); in test_matrix_as_index() 54 VERIFY_IS_EQUAL(tensor.coeff(coeffC), tensor.coeff(coeff)); in test_matrix_as_index() 55 VERIFY_IS_EQUAL(tensor.coeffRef(coeffC), tensor.coeffRef(coeff)); in test_matrix_as_index() 64 Tensor<float, 4, DataLayout> tensor(2, 3, 5, 7); in test_varlist_as_index() local 65 tensor.setRandom(); in test_varlist_as_index() [all …]
|
D | cxx11_tensor_chipping.cpp | 19 Tensor<float, 5, DataLayout> tensor(2,3,5,7,11); in test_simple_chip() local 20 tensor.setRandom(); in test_simple_chip() 23 chip1 = tensor.template chip<0>(1); in test_simple_chip() 34 VERIFY_IS_EQUAL(chip1(i,j,k,l), tensor(1,i,j,k,l)); in test_simple_chip() 40 Tensor<float, 4, DataLayout> chip2 = tensor.template chip<1>(1); in test_simple_chip() 49 VERIFY_IS_EQUAL(chip2(i,j,k,l), tensor(i,1,j,k,l)); in test_simple_chip() 55 Tensor<float, 4, DataLayout> chip3 = tensor.template chip<2>(2); in test_simple_chip() 64 VERIFY_IS_EQUAL(chip3(i,j,k,l), tensor(i,j,2,k,l)); in test_simple_chip() 70 Tensor<float, 4, DataLayout> chip4(tensor.template chip<3>(5)); in test_simple_chip() 79 VERIFY_IS_EQUAL(chip4(i,j,k,l), tensor(i,j,k,5,l)); in test_simple_chip() [all …]
|
D | cxx11_tensor_scan.cpp | 21 Tensor<Type, 1, DataLayout> tensor(size); in test_1d_scan() local 22 tensor.setRandom(); in test_1d_scan() 23 Tensor<Type, 1, DataLayout> result = tensor.cumsum(0, Exclusive); in test_1d_scan() 25 VERIFY_IS_EQUAL(tensor.dimension(0), result.dimension(0)); in test_1d_scan() 31 accum += tensor(i); in test_1d_scan() 33 accum += tensor(i); in test_1d_scan() 39 result = tensor.cumprod(0, Exclusive); in test_1d_scan() 43 accum *= tensor(i); in test_1d_scan() 45 accum *= tensor(i); in test_1d_scan() 55 Tensor<Type, 4, DataLayout> tensor(size, size, size, size); in test_4d_scan() local [all …]
|
D | cxx11_tensor_layout_swap.cpp | 18 Tensor<float, 3, ColMajor> tensor(2,3,7); in test_simple_swap() local 19 tensor.setRandom(); in test_simple_swap() 21 Tensor<float, 3, RowMajor> tensor2 = tensor.swap_layout(); in test_simple_swap() 22 VERIFY_IS_EQUAL(tensor.dimension(0), tensor2.dimension(2)); in test_simple_swap() 23 VERIFY_IS_EQUAL(tensor.dimension(1), tensor2.dimension(1)); in test_simple_swap() 24 VERIFY_IS_EQUAL(tensor.dimension(2), tensor2.dimension(0)); in test_simple_swap() 29 VERIFY_IS_EQUAL(tensor(i,j,k), tensor2(k,j,i)); in test_simple_swap() 38 Tensor<float, 3, ColMajor> tensor(2,3,7); in test_swap_as_lvalue() local 39 tensor.setRandom(); in test_swap_as_lvalue() 42 tensor2.swap_layout() = tensor; in test_swap_as_lvalue() [all …]
|
D | cxx11_tensor_reduction.cpp | 20 Tensor<float, 0, DataLayout> tensor; in test_trivial_reductions() local 21 tensor.setRandom(); in test_trivial_reductions() 24 Tensor<float, 0, DataLayout> result = tensor.sum(reduction_axis); in test_trivial_reductions() 25 VERIFY_IS_EQUAL(result(), tensor()); in test_trivial_reductions() 29 Tensor<float, 1, DataLayout> tensor(7); in test_trivial_reductions() local 30 tensor.setRandom(); in test_trivial_reductions() 33 Tensor<float, 1, DataLayout> result = tensor.sum(reduction_axis); in test_trivial_reductions() 36 VERIFY_IS_EQUAL(result(i), tensor(i)); in test_trivial_reductions() 41 Tensor<float, 2, DataLayout> tensor(2, 3); in test_trivial_reductions() local 42 tensor.setRandom(); in test_trivial_reductions() [all …]
|
D | cxx11_tensor_morphing.cpp | 72 Tensor<float, 3> tensor(2,3,7); in test_reshape_as_lvalue() local 73 tensor.setRandom(); in test_reshape_as_lvalue() 77 tensor2d.reshape(dim) = tensor; in test_reshape_as_lvalue() 81 tensor5d.reshape(dim).device(Eigen::DefaultDevice()) = tensor; in test_reshape_as_lvalue() 86 VERIFY_IS_EQUAL(tensor2d(i+2*j,k), tensor(i,j,k)); in test_reshape_as_lvalue() 87 VERIFY_IS_EQUAL(tensor5d(i,j,0,k,0), tensor(i,j,k)); in test_reshape_as_lvalue() 96 Tensor<float, 5, DataLayout> tensor(2,3,5,7,11); in test_simple_slice() local 97 tensor.setRandom(); in test_simple_slice() 102 slice1 = tensor.slice(indices, sizes); in test_simple_slice() 103 VERIFY_IS_EQUAL(slice1(0,0,0,0,0), tensor(1,2,3,4,5)); in test_simple_slice() [all …]
|
D | cxx11_tensor_broadcasting.cpp | 19 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_simple_broadcasting() local 20 tensor.setRandom(); in test_simple_broadcasting() 28 no_broadcast = tensor.broadcast(broadcasts); in test_simple_broadcasting() 39 VERIFY_IS_EQUAL(tensor(i,j,k,l), no_broadcast(i,j,k,l)); in test_simple_broadcasting() 50 broadcast = tensor.broadcast(broadcasts); in test_simple_broadcasting() 61 VERIFY_IS_EQUAL(tensor(i%2,j%3,k%5,l%7), broadcast(i,j,k,l)); in test_simple_broadcasting() 72 Tensor<float, 3, DataLayout> tensor(8,3,5); in test_vectorized_broadcasting() local 73 tensor.setRandom(); in test_vectorized_broadcasting() 80 broadcast = tensor.broadcast(broadcasts); in test_vectorized_broadcasting() 89 VERIFY_IS_EQUAL(tensor(i%8,j%3,k%5), broadcast(i,j,k)); in test_vectorized_broadcasting() [all …]
|
D | cxx11_tensor_io.cpp | 19 Tensor<int, 0, DataLayout> tensor; in test_output_0d() local 20 tensor() = 123; in test_output_0d() 23 os << tensor; in test_output_0d() 33 Tensor<int, 1, DataLayout> tensor(5); in test_output_1d() local 35 tensor(i) = i; in test_output_1d() 39 os << tensor; in test_output_1d() 55 Tensor<int, 2, DataLayout> tensor(5, 3); in test_output_2d() local 58 tensor(i, j) = i*j; in test_output_2d() 63 os << tensor; in test_output_2d() 91 Tensor<std::string, 2, DataLayout> tensor(5, 3); in test_output_string() local [all …]
|
D | cxx11_tensor_image_patch.cpp | 18 Tensor<float, 4> tensor(2,3,5,7); in test_simple_patch() local 19 tensor.setRandom(); in test_simple_patch() 20 Tensor<float, 4, RowMajor> tensor_row_major = tensor.swap_layout(); in test_simple_patch() 21 VERIFY_IS_EQUAL(tensor.dimension(0), tensor_row_major.dimension(3)); in test_simple_patch() 22 VERIFY_IS_EQUAL(tensor.dimension(1), tensor_row_major.dimension(2)); in test_simple_patch() 23 VERIFY_IS_EQUAL(tensor.dimension(2), tensor_row_major.dimension(1)); in test_simple_patch() 24 VERIFY_IS_EQUAL(tensor.dimension(3), tensor_row_major.dimension(0)); in test_simple_patch() 28 single_pixel_patch = tensor.extract_image_patches(1, 1); in test_simple_patch() 44 for (int i = 0; i < tensor.size(); ++i) { in test_simple_patch() 46 if (tensor.data()[i] != single_pixel_patch.data()[i]) { in test_simple_patch() [all …]
|
D | cxx11_tensor_argmax_cuda.cu | 71 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_cuda_argmax_dim() local 76 tensor.setRandom(); in test_cuda_argmax_dim() 77 tensor = (tensor + tensor.constant(0.5)).log(); in test_cuda_argmax_dim() 92 tensor(ix) = 10.0; in test_cuda_argmax_dim() 98 std::size_t in_bytes = tensor.size() * sizeof(float); in test_cuda_argmax_dim() 106 cudaMemcpy(d_in, tensor.data(), in_bytes, cudaMemcpyHostToDevice); in test_cuda_argmax_dim() 120 size_t(2*3*5*7 / tensor.dimension(dim))); in test_cuda_argmax_dim() 132 if (ix[dim] != tensor.dimension(dim) - 1) continue; in test_cuda_argmax_dim() 134 tensor(ix) = 20.0; in test_cuda_argmax_dim() 140 cudaMemcpy(d_in, tensor.data(), in_bytes, cudaMemcpyHostToDevice); in test_cuda_argmax_dim() [all …]
|
D | cxx11_tensor_shuffling.cpp | 20 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_simple_shuffling() local 21 tensor.setRandom(); in test_simple_shuffling() 29 no_shuffle = tensor.shuffle(shuffles); in test_simple_shuffling() 40 VERIFY_IS_EQUAL(tensor(i,j,k,l), no_shuffle(i,j,k,l)); in test_simple_shuffling() 51 shuffle = tensor.shuffle(shuffles); in test_simple_shuffling() 62 VERIFY_IS_EQUAL(tensor(i,j,k,l), shuffle(k,l,j,i)); in test_simple_shuffling() 73 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_expr_shuffling() local 74 tensor.setRandom(); in test_expr_shuffling() 82 expected = tensor.shuffle(shuffles); in test_expr_shuffling() 93 tensor.slice(src_slice_start, src_slice_dim).shuffle(shuffles); in test_expr_shuffling() [all …]
|
D | cxx11_tensor_patch.cpp | 19 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_simple_patch() local 20 tensor.setRandom(); in test_simple_patch() 29 no_patch = tensor.extract_patches(patch_dims); in test_simple_patch() 36 VERIFY_IS_EQUAL(no_patch.dimension(4), tensor.size()); in test_simple_patch() 38 VERIFY_IS_EQUAL(no_patch.dimension(0), tensor.size()); in test_simple_patch() 45 for (int i = 0; i < tensor.size(); ++i) { in test_simple_patch() 46 VERIFY_IS_EQUAL(tensor.data()[i], no_patch.data()[i]); in test_simple_patch() 54 single_patch = tensor.extract_patches(patch_dims); in test_simple_patch() 70 for (int i = 0; i < tensor.size(); ++i) { in test_simple_patch() 71 VERIFY_IS_EQUAL(tensor.data()[i], single_patch.data()[i]); in test_simple_patch() [all …]
|
D | cxx11_tensor_reverse.cpp | 21 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_simple_reverse() local 22 tensor.setRandom(); in test_simple_reverse() 31 reversed_tensor = tensor.reverse(dim_rev); in test_simple_reverse() 42 VERIFY_IS_EQUAL(tensor(i,j,k,l), reversed_tensor(i,2-j,4-k,l)); in test_simple_reverse() 53 reversed_tensor = tensor.reverse(dim_rev); in test_simple_reverse() 65 VERIFY_IS_EQUAL(tensor(i,j,k,l), reversed_tensor(1-i,j,k,l)); in test_simple_reverse() 76 reversed_tensor = tensor.reverse(dim_rev); in test_simple_reverse() 88 VERIFY_IS_EQUAL(tensor(i,j,k,l), reversed_tensor(1-i,j,k,6-l)); in test_simple_reverse() 99 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_expr_reverse() local 100 tensor.setRandom(); in test_expr_reverse() [all …]
|
D | cxx11_tensor_ifft.cpp | 19 Tensor<double, 1, DataLayout> tensor(sequence_length); in test_1D_fft_ifft_invariant() local 20 tensor.setRandom(); in test_1D_fft_ifft_invariant() 28 tensor_after_fft = tensor.template fft<Eigen::BothParts, Eigen::FFT_FORWARD>(fft); in test_1D_fft_ifft_invariant() 35 …VERIFY_IS_APPROX(static_cast<float>(tensor(i)), static_cast<float>(std::real(tensor_after_fft_ifft… in test_1D_fft_ifft_invariant() 41 Tensor<double, 2, DataLayout> tensor(dim0, dim1); in test_2D_fft_ifft_invariant() local 42 tensor.setRandom(); in test_2D_fft_ifft_invariant() 51 tensor_after_fft = tensor.template fft<Eigen::BothParts, Eigen::FFT_FORWARD>(fft); in test_2D_fft_ifft_invariant() 62 …VERIFY_IS_APPROX(static_cast<float>(tensor(i,j)), static_cast<float>(std::real(tensor_after_fft_if… in test_2D_fft_ifft_invariant() 69 Tensor<double, 3, DataLayout> tensor(dim0, dim1, dim2); in test_3D_fft_ifft_invariant() local 70 tensor.setRandom(); in test_3D_fft_ifft_invariant() [all …]
|
D | cxx11_tensor_striding.cpp | 19 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_simple_striding() local 20 tensor.setRandom(); in test_simple_striding() 28 no_stride = tensor.stride(strides); in test_simple_striding() 39 VERIFY_IS_EQUAL(tensor(i,j,k,l), no_stride(i,j,k,l)); in test_simple_striding() 50 stride = tensor.stride(strides); in test_simple_striding() 61 VERIFY_IS_EQUAL(tensor(2*i,4*j,2*k,3*l), stride(i,j,k,l)); in test_simple_striding() 72 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_striding_as_lvalue() local 73 tensor.setRandom(); in test_striding_as_lvalue() 81 result.stride(strides) = tensor; in test_striding_as_lvalue() 87 VERIFY_IS_EQUAL(tensor(i,j,k,l), result(2*i,4*j,2*k,3*l)); in test_striding_as_lvalue() [all …]
|
D | cxx11_tensor_index_list.cpp | 18 Tensor<float, 4> tensor(2,3,5,7); in test_static_index_list() local 19 tensor.setRandom(); in test_static_index_list() 33 Tensor<float, 1> result = tensor.sum(reduction_axis); in test_static_index_list() 39 expected += tensor(j,k,l,i); in test_static_index_list() 50 Tensor<float, 5> tensor(2,3,5,7,11); in test_type2index_list() local 51 tensor.setRandom(); in test_type2index_list() 52 tensor += tensor.constant(10.0f); in test_type2index_list() 81 Tensor<float, 4> result0 = tensor.sum(reduction_axis0); in test_type2index_list() 88 expected += tensor(i,j,k,l,m); in test_type2index_list() 97 Tensor<float, 3> result1 = tensor.sum(reduction_axis1); in test_type2index_list() [all …]
|
D | cxx11_tensor_volume_patch.cpp | 9 Tensor<float, 5> tensor(4,2,3,5,7); in test_single_voxel_patch() local 10 tensor.setRandom(); in test_single_voxel_patch() 11 Tensor<float, 5, RowMajor> tensor_row_major = tensor.swap_layout(); in test_single_voxel_patch() 14 single_voxel_patch = tensor.extract_volume_patches(1, 1, 1); in test_single_voxel_patch() 31 for (int i = 0; i < tensor.size(); ++i) { in test_single_voxel_patch() 32 VERIFY_IS_EQUAL(tensor.data()[i], single_voxel_patch.data()[i]); in test_single_voxel_patch() 34 VERIFY_IS_EQUAL(tensor.data()[i], tensor_row_major.data()[i]); in test_single_voxel_patch() 47 Tensor<float, 5> tensor(depth, patch_z, patch_y, patch_x, batch); in test_entire_volume_patch() local 48 tensor.setRandom(); in test_entire_volume_patch() 49 Tensor<float, 5, RowMajor> tensor_row_major = tensor.swap_layout(); in test_entire_volume_patch() [all …]
|
D | cxx11_tensor_padding.cpp | 19 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_simple_padding() local 20 tensor.setRandom(); in test_simple_padding() 29 padded = tensor.pad(paddings); in test_simple_padding() 41 VERIFY_IS_EQUAL(padded(i,j,k,l), tensor(i,j-2,k-3,l)); in test_simple_padding() 54 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_padded_expr() local 55 tensor.setRandom(); in test_padded_expr() 68 result = tensor.pad(paddings).reshape(reshape_dims); in test_padded_expr() 77 VERIFY_IS_EQUAL(result_value, tensor(i,j-2,k-3,l)); in test_padded_expr()
|
D | cxx11_tensor_ref.cpp | 93 Tensor<float, 5> tensor(2,3,5,7,11); in test_slice() local 94 tensor.setRandom(); in test_slice() 98 TensorRef<Tensor<float, 5>> slice = tensor.slice(indices, sizes); in test_slice() 99 VERIFY_IS_EQUAL(slice(0,0,0,0,0), tensor(1,2,3,4,5)); in test_slice() 103 slice = tensor.slice(indices2, sizes2); in test_slice() 107 VERIFY_IS_EQUAL(slice(0,0,i,j,k), tensor(1,1,3+i,4+j,5+k)); in test_slice() 114 slice = tensor.slice(indices3, sizes3); in test_slice() 115 VERIFY_IS_EQUAL(slice.data(), tensor.data()); in test_slice() 186 Tensor<float, 5> tensor(2,3,5,7,11); in test_coeff_ref() local 187 tensor.setRandom(); in test_coeff_ref() [all …]
|
D | cxx11_tensor_inflation.cpp | 19 Tensor<float, 4, DataLayout> tensor(2,3,5,7); in test_simple_inflation() local 20 tensor.setRandom(); in test_simple_inflation() 29 no_stride = tensor.inflate(strides); in test_simple_inflation() 40 VERIFY_IS_EQUAL(tensor(i,j,k,l), no_stride(i,j,k,l)); in test_simple_inflation() 51 inflated = tensor.inflate(strides); in test_simple_inflation() 67 tensor(i/2, j/4, k/2, l/3)); in test_simple_inflation()
|
D | cxx11_tensor_assign.cpp | 263 Tensor<int, 1> tensor = start_tensor; in test_compound_assign() local 264 tensor += offset_tensor; in test_compound_assign() 266 VERIFY_IS_EQUAL(tensor(i), start_tensor(i) + offset_tensor(i)); in test_compound_assign() 269 tensor = start_tensor; in test_compound_assign() 270 tensor -= offset_tensor; in test_compound_assign() 272 VERIFY_IS_EQUAL(tensor(i), start_tensor(i) - offset_tensor(i)); in test_compound_assign() 275 tensor = start_tensor; in test_compound_assign() 276 tensor *= offset_tensor; in test_compound_assign() 278 VERIFY_IS_EQUAL(tensor(i), start_tensor(i) * offset_tensor(i)); in test_compound_assign() 281 tensor = start_tensor; in test_compound_assign() [all …]
|
/external/eigen/unsupported/Eigen/CXX11/src/Tensor/ |
D | TensorIO.h | 20 static void run (std::ostream& os, const Tensor& tensor) { in run() 23 const Index total_size = internal::array_prod(tensor.dimensions()); in run() 25 const Index first_dim = Eigen::internal::array_get<0>(tensor.dimensions()); in run() 27 …Map<const Array<Scalar, Dynamic, Dynamic, layout> > matrix(const_cast<Scalar*>(tensor.data()), fir… in run() 37 static void run (std::ostream& os, const Tensor& tensor) { 40 const Index total_size = internal::array_prod(tensor.dimensions()); 42 Map<const Array<Scalar, Dynamic, 1> > array(const_cast<Scalar*>(tensor.data()), total_size); 52 static void run (std::ostream& os, const Tensor& tensor) { 53 os << tensor.coeff(0); 65 Evaluator tensor(eval, DefaultDevice()); [all …]
|
D | README.md | 10 You can manipulate a tensor with one of the following classes. They all are in 16 This is the class to use to create a tensor and allocate memory for it. The 17 class is templatized with the tensor datatype, such as float or int, and the 18 tensor rank. The rank is the number of dimensions, for example rank 2 is a 21 Tensors of this class are resizable. For example, if you assign a tensor of a 22 different size to a Tensor, that tensor is resized to match its new value. 30 // Create a tensor of rank 3 of sizes 2, 3, 4. This tensor owns 34 // Resize t_3d by assigning a tensor of different sizes, but same rank. 44 // Create a tensor of strings of rank 2 with sizes 5, 7. 54 If the total number of elements in a fixed size tensor is small enough the [all …]
|
D | TensorInitializer.h | 31 static void run(TensorEvaluator<Derived, DefaultDevice>& tensor, in run() 37 Initializer<Derived, N - 1>::run(tensor, indices, v); in run() 46 static void run(TensorEvaluator<Derived, DefaultDevice>& tensor, 53 tensor.coeffRef(*indices) = v; 62 static void run(TensorEvaluator<Derived, DefaultDevice>& tensor, 65 tensor.coeffRef(0) = v; 71 void initialize_tensor(TensorEvaluator<Derived, DefaultDevice>& tensor, 74 Initializer<Derived, traits<Derived>::NumDimensions>::run(tensor, &indices, vals);
|