From f6fc1f6a7a8d38a9709b9764e92ae97e63461020 Mon Sep 17 00:00:00 2001 From: Alejandro Saucedo Date: Sun, 30 Aug 2020 16:13:29 +0100 Subject: [PATCH] ADded tests for opcreatetensors multiple array --- test/TestManager.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/TestManager.cpp b/test/TestManager.cpp index ff06342b8..1e59dfcf4 100755 --- a/test/TestManager.cpp +++ b/test/TestManager.cpp @@ -113,3 +113,53 @@ TEST_CASE("Test manager get create functionality for sequences") { REQUIRE(sqWeakPtrTwo.lock() == sqWeakPtrTwoRef.lock()); REQUIRE(sqWeakPtrOneRef.lock() != sqWeakPtrTwoRef.lock()); } + +TEST_CASE("End to end OpMult Flow with OpCreateTensor called with multiple tensors") { + spdlog::info("TEST CASE STARTING"); + + spdlog::info("Creating manager"); + + spdlog::info("Creating first tensor"); + std::shared_ptr tensorLHS{ new kp::Tensor( + { 0, 1, 2 }) }; + + spdlog::info("Creating second tensor"); + std::shared_ptr tensorRHS{ new kp::Tensor( + { 2, 4, 6 }) }; + + // TODO: Add capabilities for just output tensor types + spdlog::info("Creating output tensor"); + std::shared_ptr tensorOutput{ new kp::Tensor( + { 0, 0, 0 }) }; + + kp::Manager mgr; + + std::weak_ptr sqWeakPtr = mgr.getOrCreateManagedSequence("newSequence"); + if (std::shared_ptr sq = sqWeakPtr.lock()) { + sq->begin(); + + sq->record({ tensorLHS, tensorRHS, tensorOutput }); + + spdlog::info("OpCreateTensor success for tensors"); + spdlog::info("Tensor one: {}", tensorLHS->data()); + spdlog::info("Tensor two: {}", tensorRHS->data()); + spdlog::info("Tensor output: {}", tensorOutput->data()); + REQUIRE(tensorLHS->isInit()); + REQUIRE(tensorRHS->isInit()); + REQUIRE(tensorOutput->isInit()); + + spdlog::info("Calling op mult"); + sq->record>({ tensorLHS, tensorRHS, tensorOutput }); + + sq->end(); + sq->eval(); + } + sqWeakPtr.reset(); + + spdlog::info("OpMult call success"); + spdlog::info("Tensor output: {}", tensorOutput->data()); + + REQUIRE(tensorOutput->data() == std::vector{0, 4, 12}); + + spdlog::info("Called manager eval success END PROGRAM"); +}