@@ -120,7 +120,8 @@ static Match synZeroMatch() { return Match(); }
120
120
FOREVERY_BINOP (IMPL_BINOP_PATTERN)
121
121
#undef IMPL_BINOP_PATTERN
122
122
123
- class MergerTestBase : public ::testing::Test {
123
+ // Parameterize LevelFormat to test both Dense and Batch LevelFormat.
124
+ class MergerTestBase : public ::testing::TestWithParam<LevelFormat> {
124
125
protected:
125
126
MergerTestBase (unsigned numTensors, unsigned numLoops)
126
127
: merger(numTensors, numLoops, /* maxRank=*/ numLoops) {
@@ -317,10 +318,14 @@ class MergerTest3T1L : public MergerTestBase {
317
318
// Tensor 1: sparse input vector.
318
319
merger.setLevelAndType (tid (1 ), lid (0 ), 0 , LevelFormat::Compressed);
319
320
// Tensor 2: dense output vector.
320
- merger.setLevelAndType (tid (2 ), lid (0 ), 0 , LevelFormat::Dense );
321
+ merger.setLevelAndType (tid (2 ), lid (0 ), 0 , GetParam () );
321
322
}
322
323
};
323
324
325
+ INSTANTIATE_TEST_SUITE_P (Test3T1L, MergerTest3T1L,
326
+ ::testing::Values (LevelFormat::Dense,
327
+ LevelFormat::Batch));
328
+
324
329
// / Four tensors (three inputs, one output); and a single loop.
325
330
class MergerTest4T1L : public MergerTestBase {
326
331
protected:
@@ -333,10 +338,14 @@ class MergerTest4T1L : public MergerTestBase {
333
338
// Tensor 2: sparse input vector
334
339
merger.setLevelAndType (tid (2 ), lid (0 ), 0 , LevelFormat::Compressed);
335
340
// Tensor 3: dense output vector
336
- merger.setLevelAndType (tid (3 ), lid (0 ), 0 , LevelFormat::Dense );
341
+ merger.setLevelAndType (tid (3 ), lid (0 ), 0 , GetParam () );
337
342
}
338
343
};
339
344
345
+ INSTANTIATE_TEST_SUITE_P (Test4T1L, MergerTest4T1L,
346
+ ::testing::Values (LevelFormat::Dense,
347
+ LevelFormat::Batch));
348
+
340
349
// /
341
350
// / Tests with both sparse and dense input.
342
351
// /
@@ -349,12 +358,16 @@ class MergerTest3T1LD : public MergerTestBase {
349
358
// Tensor 0: sparse input vector.
350
359
merger.setLevelAndType (tid (0 ), lid (0 ), 0 , LevelFormat::Compressed);
351
360
// Tensor 1: dense input vector.
352
- merger.setLevelAndType (tid (1 ), lid (0 ), 0 , LevelFormat::Dense );
361
+ merger.setLevelAndType (tid (1 ), lid (0 ), 0 , GetParam () );
353
362
// Tensor 2: dense output vector.
354
- merger.setLevelAndType (tid (2 ), lid (0 ), 0 , LevelFormat::Dense );
363
+ merger.setLevelAndType (tid (2 ), lid (0 ), 0 , GetParam () );
355
364
}
356
365
};
357
366
367
+ INSTANTIATE_TEST_SUITE_P (Test3T1LD, MergerTest3T1LD,
368
+ ::testing::Values (LevelFormat::Dense,
369
+ LevelFormat::Batch));
370
+
358
371
// /
359
372
// / Tests with both undef and dense input.
360
373
// /
@@ -367,14 +380,18 @@ class MergerTest4T1LU : public MergerTestBase {
367
380
// Tensor 0: undef input vector.
368
381
merger.setLevelAndType (tid (0 ), lid (0 ), 0 , LevelFormat::Undef);
369
382
// Tensor 1: dense input vector.
370
- merger.setLevelAndType (tid (1 ), lid (0 ), 0 , LevelFormat::Dense );
383
+ merger.setLevelAndType (tid (1 ), lid (0 ), 0 , GetParam () );
371
384
// Tensor 2: undef input vector.
372
385
merger.setLevelAndType (tid (2 ), lid (0 ), 0 , LevelFormat::Undef);
373
386
// Tensor 3: dense output vector.
374
- merger.setLevelAndType (tid (3 ), lid (0 ), 0 , LevelFormat::Dense );
387
+ merger.setLevelAndType (tid (3 ), lid (0 ), 0 , GetParam () );
375
388
}
376
389
};
377
390
391
+ INSTANTIATE_TEST_SUITE_P (Test4T1LU, MergerTest4T1LU,
392
+ ::testing::Values (LevelFormat::Dense,
393
+ LevelFormat::Batch));
394
+
378
395
// /
379
396
// / Tests with operation on sparse output.
380
397
// /
@@ -395,6 +412,11 @@ class MergerTest3T1LSo : public MergerTestBase {
395
412
}
396
413
};
397
414
415
+ // This testsuite does not use any dense-like format, just one of {Dense, Batch}
416
+ // is enough.
417
+ INSTANTIATE_TEST_SUITE_P (Test3T1LSo, MergerTest3T1LSo,
418
+ ::testing::Values (LevelFormat::Dense));
419
+
398
420
} // namespace
399
421
400
422
// / Vector multiplication (conjunction) of 3 vectors, i.e.;
@@ -409,7 +431,7 @@ class MergerTest3T1LSo : public MergerTestBase {
409
431
// / lat( i_01_D / (tensor_0 * tensor_1 * tensor2) )
410
432
// / }
411
433
#define IMPL_MERGER_TEST_CONJ_CONJ_UNDEF (CONJ1, CONJ2 ) \
412
- TEST_F (MergerTest4T1LU, vector_##CONJ1##_##CONJ2) { \
434
+ TEST_P (MergerTest4T1LU, vector_##CONJ1##_##CONJ2) { \
413
435
const auto em = CONJ1##Expr (tensor (0 ), tensor (1 )); \
414
436
const auto e = CONJ2##Expr (em, tensor (2 )); \
415
437
const auto l0 = lid (0 ); \
@@ -443,7 +465,7 @@ FOREVERY_PAIR_OF_COMMON_CONJ_CONJ_BINOP(IMPL_MERGER_TEST_CONJ_CONJ_UNDEF)
443
465
// / lat( i_03_U / (tensor_0 * tensor_1 * output_tensor2) )
444
466
// / }
445
467
#define IMPL_MERGER_TEST_CONJ_CONJ_SPARSE_OUT (CONJ1, CONJ2 ) \
446
- TEST_F (MergerTest3T1LSo, vector_##CONJ1##_##CONJ2) { \
468
+ TEST_P (MergerTest3T1LSo, vector_##CONJ1##_##CONJ2) { \
447
469
const auto em = CONJ1##Expr (tensor (0 ), tensor (1 )); \
448
470
const auto e = CONJ2##Expr (em, tensor (2 )); \
449
471
const auto l0 = lid (0 ); \
@@ -482,7 +504,7 @@ FOREVERY_PAIR_OF_COMMON_CONJ_CONJ_BINOP(IMPL_MERGER_TEST_CONJ_CONJ_SPARSE_OUT)
482
504
// / lat( i_01 / tensor_1 )
483
505
// / }
484
506
#define IMPL_MERGER_TEST_DISJ (OP, UNUSED ) \
485
- TEST_F (MergerTest3T1L, vector_##OP) { \
507
+ TEST_P (MergerTest3T1L, vector_##OP) { \
486
508
const auto e = OP##Expr (tensor (0 ), tensor (1 )); \
487
509
const auto l0 = lid (0 ); \
488
510
const auto t0 = tid (0 ); \
@@ -514,7 +536,7 @@ FOREVERY_COMMON_DISJ_BINOP(IMPL_MERGER_TEST_DISJ)
514
536
// / lat( i_00 i_01 / (tensor_0 * tensor_1) )
515
537
// / }
516
538
#define IMPL_MERGER_TEST_CONJ (OP, UNUSED ) \
517
- TEST_F (MergerTest3T1L, vector_##OP) { \
539
+ TEST_P (MergerTest3T1L, vector_##OP) { \
518
540
const auto e = OP##Expr (tensor (0 ), tensor (1 )); \
519
541
const auto l0 = lid (0 ); \
520
542
const auto t0 = tid (0 ); \
@@ -544,7 +566,7 @@ FOREVERY_COMMON_CONJ_BINOP(IMPL_MERGER_TEST_CONJ)
544
566
// / lat( i_02 / tensor_2 )
545
567
// / }
546
568
#define IMPL_MERGER_TEST_CONJ_DISJ (CONJ, DISJ ) \
547
- TEST_F (MergerTest4T1L, vector_##CONJ##_##DISJ) { \
569
+ TEST_P (MergerTest4T1L, vector_##CONJ##_##DISJ) { \
548
570
const auto em = CONJ##Expr (tensor (0 ), tensor (1 )); \
549
571
const auto e = DISJ##Expr (em, tensor (2 )); \
550
572
const auto l0 = lid (0 ); \
@@ -587,7 +609,7 @@ FOREVERY_PAIR_OF_COMMON_CONJ_DISJ_BINOP(IMPL_MERGER_TEST_CONJ_DISJ)
587
609
// / lat( i_00 / tensor_0 )
588
610
// / }
589
611
#define IMPL_MERGER_TEST_DISJ_DISJ (DISJ1, DISJ2 ) \
590
- TEST_F (MergerTest4T1L, Vector_##DISJ1##_##DISJ2) { \
612
+ TEST_P (MergerTest4T1L, Vector_##DISJ1##_##DISJ2) { \
591
613
const auto em = DISJ1##Expr (tensor (0 ), tensor (1 )); \
592
614
const auto e = DISJ2##Expr (em, tensor (2 )); \
593
615
const auto l0 = lid (0 ); \
@@ -636,7 +658,7 @@ FOREVERY_PAIR_OF_COMMON_DISJ_DISJ_BINOP(IMPL_MERGER_TEST_DISJ_DISJ)
636
658
// / lat( i_00 i_01 i_02 / tensor_0 * tensor_1 * tensor_2 )
637
659
// / }
638
660
#define IMPL_MERGER_TEST_CONJ_CONJ (CONJ1, CONJ2 ) \
639
- TEST_F (MergerTest4T1L, vector_##CONJ1##_##CONJ2) { \
661
+ TEST_P (MergerTest4T1L, vector_##CONJ1##_##CONJ2) { \
640
662
const auto em = CONJ1##Expr (tensor (0 ), tensor (1 )); \
641
663
const auto e = CONJ2##Expr (em, tensor (2 )); \
642
664
const auto l0 = lid (0 ); \
@@ -675,7 +697,7 @@ FOREVERY_PAIR_OF_COMMON_CONJ_CONJ_BINOP(IMPL_MERGER_TEST_CONJ_CONJ)
675
697
// / lat( i_00 / sparse_tensor_0 ) should be opted out as it only has dense diff
676
698
// / with lat( i_00 i_01 / (sparse_tensor_0 + dense_tensor_1) ).
677
699
#define IMPL_MERGER_TEST_OPTIMIZED_DISJ (OP, UNUSED ) \
678
- TEST_F (MergerTest3T1LD, vector_opted_##OP) { \
700
+ TEST_P (MergerTest3T1LD, vector_opted_##OP) { \
679
701
const auto e = OP##Expr (tensor (0 ), tensor (1 )); \
680
702
const auto l0 = lid (0 ); \
681
703
const auto t0 = tid (0 ); \
@@ -711,7 +733,7 @@ FOREVERY_COMMON_DISJ_BINOP(IMPL_MERGER_TEST_OPTIMIZED_DISJ)
711
733
// / }
712
734
// / since i_01 is a dense dimension.
713
735
#define IMPL_MERGER_TEST_OPTIMIZED_CONJ (OP, UNUSED ) \
714
- TEST_F (MergerTest3T1LD, vector_opted_##OP) { \
736
+ TEST_P (MergerTest3T1LD, vector_opted_##OP) { \
715
737
const auto e = OP##Expr (tensor (0 ), tensor (1 )); \
716
738
const auto l0 = lid (0 ); \
717
739
const auto t0 = tid (0 ); \
@@ -746,7 +768,7 @@ FOREVERY_COMMON_CONJ_BINOP(IMPL_MERGER_TEST_OPTIMIZED_CONJ)
746
768
// / lat( i_00 / tensor_0 cmp 0 )
747
769
// / lat( i_01 / 0 cmp tensor_1 )
748
770
// / }
749
- TEST_F (MergerTest3T1L, vector_cmp) {
771
+ TEST_P (MergerTest3T1L, vector_cmp) {
750
772
const auto e = cmpiExpr (tensor (0 ), tensor (1 ));
751
773
const auto l0 = lid (0 );
752
774
const auto t0 = tid (0 );
@@ -784,7 +806,7 @@ TEST_F(MergerTest3T1L, vector_cmp) {
784
806
// /
785
807
// / lat( i_00 / sparse_tensor_0 ) should be opted out as it only has dense diff
786
808
// / with lat( i_00 i_01 / (sparse_tensor_0 cmp dense_tensor_1) ).
787
- TEST_F (MergerTest3T1LD, vector_cmp) {
809
+ TEST_P (MergerTest3T1LD, vector_cmp) {
788
810
const auto e = cmpiExpr (tensor (0 ), tensor (1 ));
789
811
const auto l0 = lid (0 );
790
812
const auto t0 = tid (0 );
0 commit comments