Skip to content
Snippets Groups Projects
Commit 00f7b075 authored by Grégoire Kubler's avatar Grégoire Kubler Committed by Olivier BICHLER
Browse files

feat : added padding benchmark

parent ede140a3
No related branches found
No related tags found
2 merge requests!1740.6.1,!160feat : support for conv3D forward
......@@ -14,6 +14,7 @@
#include <aidge/utils/Types.h>
#include <memory>
#include <catch2/benchmark/catch_benchmark.hpp>
#include <catch2/catch_test_macros.hpp>
#include "aidge/backend/cpu/data/TensorImpl.hpp"
......@@ -714,5 +715,74 @@ TEST_CASE("[cpu/operator] Pad(forward)", "[Pad][CPU]") {
{-2, 2, 2, -2, 2, 2, -2}}}}}}));
CHECK(approxEq<float>(*padOp->getOutput(0), expectedOutput));
}
SECTION("Benchmark test") {
Log::setConsoleLevel(Log::Level::Error);
constexpr DimSize_t batch = 1;
constexpr DimSize_t channel = 1;
constexpr std::array<DimSize_t, DIM> inDataSize = {3, 3, 3};
constexpr std::array<DimSize_t, 2 * DIM> beginEndBorder =
{1, 1, 1, 1, 1, 1};
constexpr std::array<DimSize_t, DIM> outDataSize = {
inDataSize[0] + beginEndBorder[0] + beginEndBorder[3],
inDataSize[1] + beginEndBorder[1] + beginEndBorder[4],
inDataSize[2] + beginEndBorder[2] + beginEndBorder[5]};
auto input = std::make_shared<Tensor>(Array5D<float,
batch,
channel,
inDataSize[0],
inDataSize[1],
inDataSize[2]>(
{{{{{{1., 2., 3.}, {4., 5., 6.}, {7., 8., 9.}},
{{10., 11., 12.}, {13., 14., 15.}, {16., 17., 18.}},
{{19., 20., 21.}, {22., 23., 24.}, {25., 26., 27.}}}}}}));
auto padOp = setupTestPad<DIM>(beginEndBorder,
input,
PadBorderType::Reflect,
0);
BENCHMARK("Padding 3D") {
REQUIRE_NOTHROW(padOp->forward());
return;
};
Tensor expectedOutput(
Array5D<float,
batch,
channel,
outDataSize[0],
outDataSize[1],
outDataSize[2]>({{{{{{14., 13., 14., 15., 14.},
{11., 10., 11., 12., 11.},
{14., 13., 14., 15., 14.},
{17., 16., 17., 18., 17.},
{14., 13., 14., 15., 14.}},
{{5., 4., 5., 6., 5.},
{2., 1., 2., 3., 2.},
{5., 4., 5., 6., 5.},
{8., 7., 8., 9., 8.},
{5., 4., 5., 6., 5.}},
{{14., 13., 14., 15., 14.},
{11., 10., 11., 12., 11.},
{14., 13., 14., 15., 14.},
{17., 16., 17., 18., 17.},
{14., 13., 14., 15., 14.}},
{{23., 22., 23., 24., 23.},
{20., 19., 20., 21., 20.},
{23., 22., 23., 24., 23.},
{26., 25., 26., 27., 26.},
{23., 22., 23., 24., 23.}},
{{14., 13., 14., 15., 14.},
{11., 10., 11., 12., 11.},
{14., 13., 14., 15., 14.},
{17., 16., 17., 18., 17.},
{14., 13., 14., 15., 14.}}}}}}));
CHECK(approxEq<float>(*padOp->getOutput(0), expectedOutput));
}
}
}
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