diff --git a/test/TestLogisticRegression.cpp b/test/TestLogisticRegression.cpp index 9822c08d1..91dd1f430 100644 --- a/test/TestLogisticRegression.cpp +++ b/test/TestLogisticRegression.cpp @@ -32,14 +32,14 @@ TEST(TestLogisticRegressionAlgorithm, TestMainLogisticRegression) kp::Manager mgr; std::shared_ptr sqTensor = - mgr.createManagedSequence().lock(); + mgr.createManagedSequence(); sqTensor->begin(); sqTensor->record(params); sqTensor->end(); sqTensor->eval(); - std::shared_ptr sq = mgr.createManagedSequence().lock(); + std::shared_ptr sq = mgr.createManagedSequence(); // Record op algo base sq->begin(); @@ -115,14 +115,14 @@ TEST(TestLogisticRegressionAlgorithm, TestMainLogisticRegressionManualCopy) kp::Manager mgr; std::shared_ptr sqTensor = - mgr.createManagedSequence().lock(); + mgr.createManagedSequence(); sqTensor->begin(); sqTensor->record(params); sqTensor->end(); sqTensor->eval(); - std::shared_ptr sq = mgr.createManagedSequence().lock(); + std::shared_ptr sq = mgr.createManagedSequence(); // Record op algo base sq->begin(); diff --git a/test/TestManager.cpp b/test/TestManager.cpp index 0cb2a78fd..3076b2a62 100644 --- a/test/TestManager.cpp +++ b/test/TestManager.cpp @@ -35,9 +35,10 @@ TEST(TestManager, OpMultSequenceFlow) kp::Manager mgr; - std::weak_ptr sqWeakPtr = - mgr.getOrCreateManagedSequence("newSequence"); - if (std::shared_ptr sq = sqWeakPtr.lock()) { + { + std::shared_ptr sq = + mgr.getOrCreateManagedSequence("newSequence"); + sq->begin(); sq->record({ tensorLHS }); @@ -51,7 +52,6 @@ TEST(TestManager, OpMultSequenceFlow) sq->end(); sq->eval(); } - sqWeakPtr.reset(); EXPECT_EQ(tensorOutput->data(), std::vector({ 0, 4, 12 })); } @@ -60,22 +60,22 @@ TEST(TestManager, TestMultipleSequences) { kp::Manager mgr; - std::weak_ptr sqWeakPtrOne = + std::shared_ptr sqOne = mgr.getOrCreateManagedSequence("sqOne"); - std::weak_ptr sqWeakPtrTwo = + std::shared_ptr sqTwo = mgr.getOrCreateManagedSequence("sqTwo"); - std::weak_ptr sqWeakPtrOneRef = + std::shared_ptr sqOneRef = mgr.getOrCreateManagedSequence("sqOne"); - std::weak_ptr sqWeakPtrTwoRef = + std::shared_ptr sqTwoRef = mgr.getOrCreateManagedSequence("sqTwo"); - EXPECT_EQ(sqWeakPtrOne.lock(), sqWeakPtrOneRef.lock()); - EXPECT_NE(sqWeakPtrTwo.lock(), sqWeakPtrOneRef.lock()); - EXPECT_EQ(sqWeakPtrTwo.lock(), sqWeakPtrTwoRef.lock()); - EXPECT_NE(sqWeakPtrOneRef.lock(), sqWeakPtrTwoRef.lock()); + EXPECT_EQ(sqOne, sqOneRef); + EXPECT_NE(sqTwo, sqOneRef); + EXPECT_EQ(sqTwo, sqTwoRef); + EXPECT_NE(sqOneRef, sqTwoRef); } TEST(TestManager, TestMultipleTensorsAtOnce) @@ -89,9 +89,10 @@ TEST(TestManager, TestMultipleTensorsAtOnce) kp::Manager mgr; - std::weak_ptr sqWeakPtr = + std::shared_ptr sq = mgr.getOrCreateManagedSequence("newSequence"); - if (std::shared_ptr sq = sqWeakPtr.lock()) { + + { sq->begin(); sq->record({ tensorLHS, tensorRHS, tensorOutput }); @@ -107,7 +108,6 @@ TEST(TestManager, TestMultipleTensorsAtOnce) sq->end(); sq->eval(); } - sqWeakPtr.reset(); EXPECT_EQ(tensorOutput->data(), std::vector({ 0, 4, 12 })); } diff --git a/test/TestMultipleAlgoExecutions.cpp b/test/TestMultipleAlgoExecutions.cpp index a0355416c..f45367313 100644 --- a/test/TestMultipleAlgoExecutions.cpp +++ b/test/TestMultipleAlgoExecutions.cpp @@ -19,9 +19,10 @@ TEST(TestMultipleAlgoExecutions, SingleSequenceRecord) pa[index] = pa[index] + 1; })"); - std::weak_ptr sqWeakPtr = + std::shared_ptr sq = mgr.getOrCreateManagedSequence("newSequence"); - if (std::shared_ptr sq = sqWeakPtr.lock()) { + + { sq->begin(); sq->record({ tensorA }); @@ -38,7 +39,6 @@ TEST(TestMultipleAlgoExecutions, SingleSequenceRecord) sq->end(); sq->eval(); } - sqWeakPtr.reset(); EXPECT_EQ(tensorA->data(), std::vector({ 3, 3, 3 })); } @@ -58,9 +58,9 @@ TEST(TestMultipleAlgoExecutions, MultipleCmdBufRecords) pa[index] = pa[index] + 1; })"); - std::shared_ptr sqTensor = mgr.createManagedSequence().lock(); + std::shared_ptr sqTensor = mgr.createManagedSequence(); - std::shared_ptr sq = mgr.createManagedSequence().lock(); + std::shared_ptr sq = mgr.createManagedSequence(); // First create the tensor in a separate sequence sqTensor->begin(); @@ -111,9 +111,10 @@ TEST(TestMultipleAlgoExecutions, MultipleSequences) pa[index] = pa[index] + 1; })"); - std::weak_ptr sqWeakPtr = - mgr.getOrCreateManagedSequence("newSequence"); - if (std::shared_ptr sq = sqWeakPtr.lock()) { + { + std::shared_ptr sq = + mgr.getOrCreateManagedSequence("newSequence"); + sq->begin(); sq->record({ tensorA }); @@ -125,9 +126,10 @@ TEST(TestMultipleAlgoExecutions, MultipleSequences) sq->eval(); } - std::weak_ptr sqWeakPtr2 = - mgr.getOrCreateManagedSequence("newSequence2"); - if (std::shared_ptr sq = sqWeakPtr2.lock()) { + { + std::shared_ptr sq = + mgr.getOrCreateManagedSequence("newSequence2"); + sq->begin(); sq->record( @@ -137,9 +139,10 @@ TEST(TestMultipleAlgoExecutions, MultipleSequences) sq->eval(); } - std::weak_ptr sqWeakPtr3 = - mgr.getOrCreateManagedSequence("newSequence3"); - if (std::shared_ptr sq = sqWeakPtr3.lock()) { + { + std::shared_ptr sq = + mgr.getOrCreateManagedSequence("newSequence3"); + sq->begin(); sq->record( @@ -149,9 +152,10 @@ TEST(TestMultipleAlgoExecutions, MultipleSequences) sq->eval(); } - std::weak_ptr sqWeakPtr4 = - mgr.getOrCreateManagedSequence("newSequence5"); - if (std::shared_ptr sq = sqWeakPtr4.lock()) { + { + std::shared_ptr sq = + mgr.getOrCreateManagedSequence("newSequence5"); + sq->begin(); sq->record({ tensorA }); @@ -179,9 +183,10 @@ TEST(TestMultipleAlgoExecutions, SingleRecordMultipleEval) pa[index] = pa[index] + 1; })"); - std::weak_ptr sqWeakPtr = - mgr.getOrCreateManagedSequence("newSequence"); - if (std::shared_ptr sq = sqWeakPtr.lock()) { + { + std::shared_ptr sq = + mgr.getOrCreateManagedSequence("newSequence"); + sq->begin(); sq->record({ tensorA }); @@ -190,9 +195,10 @@ TEST(TestMultipleAlgoExecutions, SingleRecordMultipleEval) sq->eval(); } - std::weak_ptr sqWeakPtr2 = - mgr.getOrCreateManagedSequence("newSequence2"); - if (std::shared_ptr sq = sqWeakPtr2.lock()) { + { + std::shared_ptr sq = + mgr.getOrCreateManagedSequence("newSequence2"); + sq->begin(); sq->record( @@ -205,9 +211,11 @@ TEST(TestMultipleAlgoExecutions, SingleRecordMultipleEval) sq->eval(); } - std::weak_ptr sqWeakPtr3 = - mgr.getOrCreateManagedSequence("newSequence3"); - if (std::shared_ptr sq = sqWeakPtr2.lock()) { + + { + std::shared_ptr sq = + mgr.getOrCreateManagedSequence("newSequence3"); + sq->begin(); sq->record({ tensorA }); diff --git a/test/TestTensor.cpp b/test/TestTensor.cpp index 676b9f423..42731bcfe 100644 --- a/test/TestTensor.cpp +++ b/test/TestTensor.cpp @@ -24,7 +24,7 @@ TEST(TestTensor, CopyFromHostData) kp::Manager mgr; if (std::shared_ptr sq = - mgr.getOrCreateManagedSequence("new").lock()) { + mgr.getOrCreateManagedSequence("new")) { sq->begin(); sq->record({ tensorA, tensorB });