@@ -430,6 +430,60 @@ TEST_F(IR2VecTestFixture, GetFunctionVector_FlowAware) {
430
430
EXPECT_TRUE (FuncVec.approximatelyEquals (Embedding (2 , 58.1 )));
431
431
}
432
432
433
+ TEST_F (IR2VecTestFixture, MultipleComputeEmbeddingsConsistency_Symbolic) {
434
+ auto Emb = Embedder::create (IR2VecKind::Symbolic, *F, *V);
435
+ ASSERT_TRUE (static_cast <bool >(Emb));
436
+
437
+ // Get initial function vector
438
+ const auto &FuncVec1 = Emb->getFunctionVector ();
439
+
440
+ // Compute embeddings again by calling getFunctionVector multiple times
441
+ const auto &FuncVec2 = Emb->getFunctionVector ();
442
+ const auto &FuncVec3 = Emb->getFunctionVector ();
443
+
444
+ // All function vectors should be identical
445
+ EXPECT_TRUE (FuncVec1.approximatelyEquals (FuncVec2));
446
+ EXPECT_TRUE (FuncVec1.approximatelyEquals (FuncVec3));
447
+ EXPECT_TRUE (FuncVec2.approximatelyEquals (FuncVec3));
448
+
449
+ // Also check that instruction vectors remain consistent
450
+ const auto &InstMap1 = Emb->getInstVecMap ();
451
+ const auto &InstMap2 = Emb->getInstVecMap ();
452
+
453
+ EXPECT_EQ (InstMap1.size (), InstMap2.size ());
454
+ for (const auto &[Inst, Vec1] : InstMap1) {
455
+ ASSERT_TRUE (InstMap2.count (Inst));
456
+ EXPECT_TRUE (Vec1.approximatelyEquals (InstMap2.at (Inst)));
457
+ }
458
+ }
459
+
460
+ TEST_F (IR2VecTestFixture, MultipleComputeEmbeddingsConsistency_FlowAware) {
461
+ auto Emb = Embedder::create (IR2VecKind::FlowAware, *F, *V);
462
+ ASSERT_TRUE (static_cast <bool >(Emb));
463
+
464
+ // Get initial function vector
465
+ const auto &FuncVec1 = Emb->getFunctionVector ();
466
+
467
+ // Compute embeddings again by calling getFunctionVector multiple times
468
+ const auto &FuncVec2 = Emb->getFunctionVector ();
469
+ const auto &FuncVec3 = Emb->getFunctionVector ();
470
+
471
+ // All function vectors should be identical
472
+ EXPECT_TRUE (FuncVec1.approximatelyEquals (FuncVec2));
473
+ EXPECT_TRUE (FuncVec1.approximatelyEquals (FuncVec3));
474
+ EXPECT_TRUE (FuncVec2.approximatelyEquals (FuncVec3));
475
+
476
+ // Also check that instruction vectors remain consistent
477
+ const auto &InstMap1 = Emb->getInstVecMap ();
478
+ const auto &InstMap2 = Emb->getInstVecMap ();
479
+
480
+ EXPECT_EQ (InstMap1.size (), InstMap2.size ());
481
+ for (const auto &[Inst, Vec1] : InstMap1) {
482
+ ASSERT_TRUE (InstMap2.count (Inst));
483
+ EXPECT_TRUE (Vec1.approximatelyEquals (InstMap2.at (Inst)));
484
+ }
485
+ }
486
+
433
487
static constexpr unsigned MaxOpcodes = Vocabulary::MaxOpcodes;
434
488
[[maybe_unused]]
435
489
static constexpr unsigned MaxTypeIDs = Vocabulary::MaxTypeIDs;
0 commit comments