Skip to content
Snippets Groups Projects
Commit 30ad9d11 authored by Grégoire Kubler's avatar Grégoire Kubler
Browse files

chore : cleanup test expand

header cleanup
removed "using namespace" in favor of "namespace{}" directive
parent e8ee7ac8
No related branches found
No related tags found
No related merge requests found
Pipeline #66697 passed
...@@ -13,20 +13,20 @@ ...@@ -13,20 +13,20 @@
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include "aidge/backend/cpu/data/TensorImpl.hpp"
#include "aidge/backend/cpu/operator/ExpandImpl.hpp"
#include "aidge/data/DataType.hpp" #include "aidge/data/DataType.hpp"
#include "aidge/data/Tensor.hpp" #include "aidge/data/Tensor.hpp"
#include "aidge/operator/Expand.hpp" #include "aidge/operator/Expand.hpp"
#include "aidge/utils/ArrayHelpers.hpp" #include "aidge/utils/ArrayHelpers.hpp"
using std::shared_ptr;
using namespace Aidge; namespace Aidge {
using std::shared_ptr;
static void setupTestExpand(shared_ptr<Tensor> inputData, static void setupTestExpand(shared_ptr<Tensor> inputData,
shared_ptr<Tensor> inputShape, shared_ptr<Tensor> inputShape,
shared_ptr<Expand_Op> &op) { shared_ptr<Expand_Op> &op,
Tensor &expectedOutput) {
op->getOutput(0)->setDataType(inputData->dataType()); op->getOutput(0)->setDataType(inputData->dataType());
...@@ -35,6 +35,9 @@ static void setupTestExpand(shared_ptr<Tensor> inputData, ...@@ -35,6 +35,9 @@ static void setupTestExpand(shared_ptr<Tensor> inputData,
inputShape->setBackend("cpu"); inputShape->setBackend("cpu");
op->associateInput(1, inputShape); op->associateInput(1, inputShape);
expectedOutput.setBackend("cpu");
expectedOutput.setDataType(DataType::Int32);
} }
TEST_CASE("[cpu/operator] Expand(forward)", "[Expand][CPU]") { TEST_CASE("[cpu/operator] Expand(forward)", "[Expand][CPU]") {
...@@ -49,7 +52,7 @@ TEST_CASE("[cpu/operator] Expand(forward)", "[Expand][CPU]") { ...@@ -49,7 +52,7 @@ TEST_CASE("[cpu/operator] Expand(forward)", "[Expand][CPU]") {
Array4D<cpptype_t<DataType::Int32>, 1, 3, 4, 2>({{{{{1, 3}, {1, 3}, {1, 3}, {1, 3}}, Array4D<cpptype_t<DataType::Int32>, 1, 3, 4, 2>({{{{{1, 3}, {1, 3}, {1, 3}, {1, 3}},
{{1, 3}, {1, 3}, {1, 3}, {1, 3}}, {{1, 3}, {1, 3}, {1, 3}, {1, 3}},
{{1, 3}, {1, 3}, {1, 3}, {1, 3}}}}}); {{1, 3}, {1, 3}, {1, 3}, {1, 3}}}}});
setupTestExpand(inputData, inputShape, op); setupTestExpand(inputData, inputShape, op, expectedOutput);
// forwardDims has already been tested in core // forwardDims has already been tested in core
CHECK(op->forwardDims(true)); CHECK(op->forwardDims(true));
...@@ -63,7 +66,7 @@ TEST_CASE("[cpu/operator] Expand(forward)", "[Expand][CPU]") { ...@@ -63,7 +66,7 @@ TEST_CASE("[cpu/operator] Expand(forward)", "[Expand][CPU]") {
std::make_shared<Tensor>(Array1D<std::int64_t, 2>({2, 3})); std::make_shared<Tensor>(Array1D<std::int64_t, 2>({2, 3}));
Tensor expectedOutput = Array3D<cpptype_t<DataType::Int32>, 2, 2, 3>( Tensor expectedOutput = Array3D<cpptype_t<DataType::Int32>, 2, 2, 3>(
{{{{2, 1, 3}, {2, 1, 3}}, {{2, 1, 3}, {2, 1, 3}}}}); {{{{2, 1, 3}, {2, 1, 3}}, {{2, 1, 3}, {2, 1, 3}}}});
setupTestExpand(inputData, inputShape, op); setupTestExpand(inputData, inputShape, op,expectedOutput);
// forwardDims has already been tested in core // forwardDims has already been tested in core
CHECK(op->forwardDims(true)); CHECK(op->forwardDims(true));
...@@ -77,7 +80,7 @@ TEST_CASE("[cpu/operator] Expand(forward)", "[Expand][CPU]") { ...@@ -77,7 +80,7 @@ TEST_CASE("[cpu/operator] Expand(forward)", "[Expand][CPU]") {
std::make_shared<Tensor>(Array1D<std::int64_t, 1>({1})); std::make_shared<Tensor>(Array1D<std::int64_t, 1>({1}));
Tensor expectedOutput = Tensor expectedOutput =
Array4D<cpptype_t<DataType::Int32>, 2, 1, 3, 1>({{{2, 1, 3}, {2, 1, 3}}}); Array4D<cpptype_t<DataType::Int32>, 2, 1, 3, 1>({{{2, 1, 3}, {2, 1, 3}}});
setupTestExpand(inputData, inputShape, op); setupTestExpand(inputData, inputShape, op, expectedOutput);
// forwardDims has already been tested in core // forwardDims has already been tested in core
CHECK(op->forwardDims(true)); CHECK(op->forwardDims(true));
...@@ -91,7 +94,7 @@ TEST_CASE("[cpu/operator] Expand(forward)", "[Expand][CPU]") { ...@@ -91,7 +94,7 @@ TEST_CASE("[cpu/operator] Expand(forward)", "[Expand][CPU]") {
std::make_shared<Tensor>(Array1D<std::int64_t, 3>({2, 1, 1})); std::make_shared<Tensor>(Array1D<std::int64_t, 3>({2, 1, 1}));
Tensor expectedOutput = Tensor expectedOutput =
Array4D<cpptype_t<DataType::Int32>, 1, 2, 3, 1>({{{{2, 1, 3}, {2, 1, 3}}}}); Array4D<cpptype_t<DataType::Int32>, 1, 2, 3, 1>({{{{2, 1, 3}, {2, 1, 3}}}});
setupTestExpand(inputData, inputShape, op); setupTestExpand(inputData, inputShape, op,expectedOutput);
// forwardDims has already been tested in core // forwardDims has already been tested in core
CHECK(op->forwardDims(true)); CHECK(op->forwardDims(true));
...@@ -101,3 +104,4 @@ TEST_CASE("[cpu/operator] Expand(forward)", "[Expand][CPU]") { ...@@ -101,3 +104,4 @@ TEST_CASE("[cpu/operator] Expand(forward)", "[Expand][CPU]") {
SECTION("N-Dim to N-Dim") {} SECTION("N-Dim to N-Dim") {}
auto inputData = std::shared_ptr<Tensor>(); auto inputData = std::shared_ptr<Tensor>();
} }
} // namespace Aidge
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment