diff --git a/unit_tests/scheduler/Test_CastMove.cpp b/unit_tests/scheduler/Test_CastMove.cpp index 5ca2cd9de4dcc9dab2c78f7ae1e1bf3090db8f2b..b78e864fecab1fd103a2cb30924d10a25f5b8f10 100644 --- a/unit_tests/scheduler/Test_CastMove.cpp +++ b/unit_tests/scheduler/Test_CastMove.cpp @@ -13,15 +13,20 @@ #include <memory> #include <string> + +#include "aidge/backend/cpu/data/TensorImpl.hpp" +#include "aidge/backend/cpu/operator/ConvImpl.hpp" +#include "aidge/backend/cpu/operator/FCImpl.hpp" #include "aidge/data/Tensor.hpp" -#include "aidge/utils/TensorUtils.hpp" #include "aidge/graph/Node.hpp" #include "aidge/graph/GraphView.hpp" #include "aidge/graph/OpArgs.hpp" +#include "aidge/operator/Conv.hpp" +#include "aidge/operator/FC.hpp" #include "aidge/scheduler/SequentialScheduler.hpp" #include "aidge/recipes/Recipes.hpp" - -#include "aidge/backend/cpu.hpp" +#include "aidge/utils/ArrayHelpers.hpp" +#include "aidge/utils/TensorUtils.hpp" using namespace Aidge; @@ -205,15 +210,15 @@ TEST_CASE("[cpu/castmove] CastMove(forward)") { REQUIRE_NOTHROW(scheduler.forward()); scheduler.saveSchedulingDiagram("schedulingSequential"); - std::shared_ptr<Tensor> expectedOutput1 = std::make_shared<Tensor>(Array4D<int, 2, 3, 3, 3>{ + Tensor expectedOutput1 = Array4D<int, 2, 3, 3, 3>{ {{{{367, 412, 457}, {592, 637, 682}, {817, 862, 907}}, {{854, 980, 1106}, {1484, 1610, 1736}, {2114, 2240, 2366}}, {{1341, 1548, 1755}, {2376, 2583, 2790}, {3411, 3618, 3825}}}, {{{1492, 1537, 1582}, {1717, 1762, 1807}, {1942, 1987, 2032}}, {{4004, 4130, 4256}, {4634, 4760, 4886}, {5264, 5390, 5516}}, - {{6516, 6723, 6930}, {7551, 7758, 7965}, {8586, 8793, 9000}}}}}); + {{6516, 6723, 6930}, {7551, 7758, 7965}, {8586, 8793, 9000}}}}}; - std::shared_ptr<Tensor> expectedOutput2 = std::make_shared<Tensor>(Array4D<int, 2, 4, 3, 3>{ + Tensor expectedOutput2 = Array4D<int, 2, 4, 3, 3>{ {{{{6099, 7017, 7935}, {10689, 11607, 12525}, {15279, 16197, 17115}}, {{13786, 15838, 17890}, {24046, 26098, 28150}, {34306, 36358, 38410}}, {{21473, 24659, 27845}, {37403, 40589, 43775}, {53333, 56519, 59705}}, @@ -221,26 +226,26 @@ TEST_CASE("[cpu/castmove] CastMove(forward)") { {{{29049, 29967, 30885}, {33639, 34557, 35475}, {38229, 39147, 40065}}, {{65086, 67138, 69190}, {75346, 77398, 79450}, {85606, 87658, 89710}}, {{101123, 104309, 107495}, {117053, 120239, 123425}, {132983, 136169, 139355}}, - {{137160, 141480, 145800}, {158760, 163080, 167400}, {180360, 184680, 189000}}}}}); + {{137160, 141480, 145800}, {158760, 163080, 167400}, {180360, 184680, 189000}}}}}; - std::shared_ptr<Tensor> expectedOutput3 = std::make_shared<Tensor>(Array4D<int, 2, 3, 3, 3>{ + Tensor expectedOutput3 = Array4D<int, 2, 3, 3, 3>{ {{{{214731, 246591, 278451}, {374031, 405891, 437751}, {533331, 565191, 597051}}, {{496804, 570568, 644332}, {865624, 939388, 1013152}, {1234444, 1308208, 1381972}}, {{778877, 894545, 1010213}, {1357217, 1472885, 1588553}, {1935557, 2051225, 2166893}}}, {{{1011231, 1043091, 1074951}, {1170531, 1202391, 1234251}, {1329831, 1361691, 1393551}}, {{2340904, 2414668, 2488432}, {2709724, 2783488, 2857252}, {3078544, 3152308, 3226072}}, - {{3670577, 3786245, 3901913}, {4248917, 4364585, 4480253}, {4827257, 4942925, 5058593}}}}}); + {{3670577, 3786245, 3901913}, {4248917, 4364585, 4480253}, {4827257, 4942925, 5058593}}}}}; Tensor expectedOutput4 = Array2D<int, 2, 5>{ {{205050376, 198925904, 181355097, 196978090, 238868348}, {598467376, 561797804, 560823897, 593043790, 698672948}}}; - std::shared_ptr<Tensor> other1 = std::static_pointer_cast<OperatorTensor>(g->getNode("conv1")->getOperator())->getOutput(0); - REQUIRE(approxEq<float, int>(*other1, *expectedOutput1, 0.0, 1.0e-12)); - std::shared_ptr<Tensor> other2 = std::static_pointer_cast<OperatorTensor>(g->getNode("conv2")->getOperator())->getOutput(0); - REQUIRE(approxEq<int>(*other2, *expectedOutput2, 0.0, 1.0e-12)); - std::shared_ptr<Tensor> other3 = std::static_pointer_cast<OperatorTensor>(g->getNode("conv3")->getOperator())->getOutput(0); - REQUIRE(approxEq<double, int>(*other3, *expectedOutput3, 0.0, 1.0e-12)); - std::shared_ptr<Tensor> other4 = std::static_pointer_cast<OperatorTensor>(g->getNode("fc")->getOperator())->getOutput(0); - REQUIRE(approxEq<int>(*other4, expectedOutput4, 0.0, 1.0e-12)); + std::shared_ptr<Tensor> other1 = std::static_pointer_cast<Conv_Op<2>>(g->getNode("conv1")->getOperator())->getOutput(0); + REQUIRE(approxEq<float, int>(*other1, expectedOutput1, 0.0, 1.0e-12)); + std::shared_ptr<Tensor> other2 = std::static_pointer_cast<Conv_Op<2>>(g->getNode("conv2")->getOperator())->getOutput(0); + REQUIRE(*other2 == expectedOutput2); + std::shared_ptr<Tensor> other3 = std::static_pointer_cast<Conv_Op<2>>(g->getNode("conv3")->getOperator())->getOutput(0); + REQUIRE(approxEq<double, int>(*other3, expectedOutput3, 0.0, 1.0e-12)); + std::shared_ptr<Tensor> other4 = std::static_pointer_cast<FC_Op>(g->getNode("fc")->getOperator())->getOutput(0); + REQUIRE(*other4 == expectedOutput4); } }