12 #include <Eigen/CXX11/Tensor>
27 tensor2 = tensor1.
reshape(dim1);
29 tensor3 = tensor1.
reshape(dim2);
31 tensor4 = tensor1.
reshape(dim1).reshape(dim3);
33 for (
int i = 0;
i < 2; ++
i) {
34 for (
int j = 0;
j < 3; ++
j) {
35 for (
int k = 0; k < 7; ++k) {
46 #if defined(EIGEN_HAS_INDEX_LIST)
47 using Eigen::type2index;
53 Eigen::IndexList<type2index<2>, type2index<3>, type2index<7>> dim;
56 for (
int i = 0;
i < 2; ++
i) {
57 for (
int j = 0;
j < 3; ++
j) {
58 for (
int k = 0; k < 7; ++k) {
68 MatrixXf
m1(2,3*5*7*11);
69 MatrixXf
m2(3*5*7*11,13);
81 tensor3 = tensor1.reshape(newDims1).contract(tensor2.reshape(newDims2), contract_along);
84 for (
int i = 0;
i < 2; ++
i) {
85 for (
int j = 0;
j < 13; ++
j) {
101 float scratch[2*3*1*7*1];
105 for (
int i = 0;
i < 2; ++
i) {
106 for (
int j = 0;
j < 3; ++
j) {
107 for (
int k = 0; k < 7; ++k) {
115 template<
typename T,
int DataLayout>
130 slice2 = tensor.
slice(indices2, sizes2);
131 for (
int i = 0;
i < 2; ++
i) {
132 for (
int j = 0;
j < 2; ++
j) {
133 for (
int k = 0; k < 3; ++k) {
151 template<
typename T,
int DataLayout>
159 Mtx
m3 =
m1.block(1, 2, 3, 3) *
m2.block(0, 2, 3, 1);
171 tensor3 = tensor1.slice(indices1, sizes1).contract(tensor2.slice(indices2, sizes2), contract_along);
174 for (
int i = 0;
i < 3; ++
i) {
175 for (
int j = 0;
j < 1; ++
j) {
183 for (
int i = 0;
i < 35; ++
i) {
188 template<
typename T,
int DataLayout>
205 result.slice(first_slice, sizes12) = tensor1;
211 result.slice(third_slice, sizes3) = tensor3;
215 result.slice(fourth_slice, sizes4) = tensor4;
217 for (
int j = 0;
j < 2; ++
j) {
218 for (
int k = 0; k < 7; ++k) {
219 for (
int i = 0;
i < 2; ++
i) {
225 for (
int i = 0;
i < 4; ++
i) {
226 for (
int j = 2;
j < 5; ++
j) {
227 for (
int k = 0; k < 5; ++k) {
230 for (
int k = 5; k < 7; ++k) {
238 result.slice(fifth_slice, sizes5) = tensor5.
slice(fifth_slice, sizes5);
239 for (
int i = 0;
i < 4; ++
i) {
240 for (
int j = 2;
j < 5; ++
j) {
241 for (
int k = 0; k < 7; ++k) {
248 template<
typename T,
int DataLayout>
285 for (
int i = 0;
i < 3; ++
i) {
286 for (
int j = 0;
j < 2; ++
j) {
295 for (
int l = 0;
l < 11; ++
l) {
296 for (
int k = 0; k < 2; ++k) {
307 for (
int i = 0;
i < 3; ++
i) {
308 for (
int j = 0;
j < 5; ++
j) {
309 for (
int k = 0; k < 7; ++k) {
310 for (
int l = 0;
l < 2; ++
l) {
311 int slice_index =
i + 3 * (
j + 5 * (k + 7 *
l));
322 for (
int l = 0;
l < 11; ++
l) {
323 for (
int k = 0; k < 7; ++k) {
324 for (
int j = 0;
j < 5; ++
j) {
325 for (
int i = 0;
i < 2; ++
i) {
326 int slice_index =
l + 11 * (k + 7 * (
j + 5 *
i));
343 template<
typename T,
int DataLayout>
358 Index2 indicesStart(5,7);
359 Index2 indicesStop(0,4);
361 for (
int j = 0;
j < 2; ++
j) {
362 for (
int k = 0; k < 3; ++k) {
371 Index2 indicesStart(5,4);
372 Index2 indicesStop(5,5);
377 Tensor2f
slice(7,11);
379 Index2 indicesStart(-3,20);
380 Index2 indicesStop(20,-11);
382 for (
int j = 0;
j < 7; ++
j) {
383 for (
int k = 0; k < 11; ++k) {
390 Tensor5f slice1(1,1,1,1,1);
399 Tensor5f
slice(1,1,2,2,3);
400 Index5 start(1, 1, 3, 4, 5);
401 Index5 stop(2, 2, 5, 6, 8);
404 for (
int i = 0;
i < 2; ++
i) {
405 for (
int j = 0;
j < 2; ++
j) {
406 for (
int k = 0; k < 3; ++k) {
414 Tensor5f
slice(1,1,2,2,3);
415 Index5 strides3(1, 1, -2, 1, -1);
416 Index5 indices3Start(1, 1, 4, 4, 7);
417 Index5 indices3Stop(2, 2, 0, 6, 4);
419 for (
int i = 0;
i < 2; ++
i) {
420 for (
int j = 0;
j < 2; ++
j) {
421 for (
int k = 0; k < 3; ++k) {
429 Tensor5f
slice(1,1,2,2,3);
430 Index5 strides3(1, 1, 2, 1, 1);
431 Index5 indices3Start(1, 1, 4, 4, 7);
432 Index5 indices3Stop(2, 2, 0, 6, 4);
437 template<
typename T,
int DataLayout>
451 Index2 indicesStart(3,4);
452 Index2 indicesStop(5,7);
455 tensor.slice(indicesStart,lengths)=
slice;
458 for(
int i=0;
i<7;
i++)
for(
int j=0;
j<11;
j++){
463 template<
typename T,
int DataLayout>
477 for (
int i = 0;
i < 11; ++
i) {
482 template<
typename T,
int DataLayout>
494 tensor.
slice(indices1, sizes1) = slice1;
501 tensor.
slice(indices2, sizes2) = slice2;
508 tensor.
slice(indices3, sizes3) = slice3;
515 tensor.
slice(indices4, sizes4) = slice4;
522 tensor.
slice(indices5, sizes5) = slice5;
529 tensor.
slice(indices6, sizes6) = slice6;
533 for (
int i = 0;
i < 2; ++
i) {
534 for (
int j = 0;
j < 3; ++
j) {
535 for (
int k = 0; k < 5; ++k) {
542 #define CALL_SUBTEST_PART(PART) \
545 #define CALL_SUBTESTS_TYPES_LAYOUTS(PART, NAME) \
546 CALL_SUBTEST_PART(PART)((NAME<float, ColMajor>())); \
547 CALL_SUBTEST_PART(PART)((NAME<float, RowMajor>())); \
548 CALL_SUBTEST_PART(PART)((NAME<bool, ColMajor>())); \
549 CALL_SUBTEST_PART(PART)((NAME<bool, RowMajor>()))