aboutsummaryrefslogtreecommitdiff
path: root/compute_kernel_writer/validation/tests
diff options
context:
space:
mode:
authorNikolaj Jensen <nikolaj.jensen@arm.com>2023-07-03 09:44:42 +0100
committerNikolaj Jensen <nikolaj.jensen@arm.com>2023-07-07 08:51:11 +0000
commitacea4071a7f457bab696dc3c895ba47d60345541 (patch)
tree66a5f659f995ea110bcb8e217dc6a94e1f7ac47d /compute_kernel_writer/validation/tests
parente86f992d26a79cad76244c4444d113e45afa9b88 (diff)
downloadComputeLibrary-acea4071a7f457bab696dc3c895ba47d60345541.tar.gz
Fix code formatting in CKW
Signed-off-by: Nikolaj Jensen <nikolaj.jensen@arm.com> Change-Id: I8064b345c1efd243f8bded12ed5d561afe7c339a Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9854 Benchmark: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Jakub Sujak <jakub.sujak@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'compute_kernel_writer/validation/tests')
-rw-r--r--compute_kernel_writer/validation/tests/CLConstantTileTest.hpp74
-rw-r--r--compute_kernel_writer/validation/tests/CLTileTest.hpp76
-rw-r--r--compute_kernel_writer/validation/tests/TensorBitMaskTest.hpp20
-rw-r--r--compute_kernel_writer/validation/tests/UtilsTest.hpp15
-rw-r--r--compute_kernel_writer/validation/tests/common/Common.h28
5 files changed, 110 insertions, 103 deletions
diff --git a/compute_kernel_writer/validation/tests/CLConstantTileTest.hpp b/compute_kernel_writer/validation/tests/CLConstantTileTest.hpp
index 33942c707d..23a75c4ca9 100644
--- a/compute_kernel_writer/validation/tests/CLConstantTileTest.hpp
+++ b/compute_kernel_writer/validation/tests/CLConstantTileTest.hpp
@@ -25,10 +25,10 @@
#ifndef COMPUTE_KERNEL_WRITER_TESTS_CLCONSTANTTILETEST_HPP
#define COMPUTE_KERNEL_WRITER_TESTS_CLCONSTANTTILETEST_HPP
+#include "common/Common.h"
#include "src/Helpers.h"
#include "src/cl/CLConstantTile.h"
#include "src/cl/CLHelpers.h"
-#include "common/Common.h"
#include <random>
#include <string>
@@ -41,9 +41,10 @@ class CLConstantTileInternalValuesTest : public ITest
public:
CLConstantTileInternalValuesTest()
{
- _values.push_back({{"1.2", "3.5"}, {"4.2", "1.3"}});
- _values.push_back({{"1.2"}});
- _values.push_back({{"1.2", "6.9"}});
+ _values.push_back({ { "1.2", "3.5" },
+ { "4.2", "1.3" } });
+ _values.push_back({ { "1.2" } });
+ _values.push_back({ { "1.2", "6.9" } });
}
bool run() override
@@ -55,19 +56,18 @@ public:
for(const auto &test : _values)
{
const CLConstantTile tile(test, DataType::Fp16);
- const auto vars = tile.all();
- const int32_t num_vars = vars.size();
- const int32_t width = tile.info().width();
+ const auto vars = tile.all();
+ const int32_t num_vars = vars.size();
+ const int32_t width = tile.info().width();
for(int32_t y = 0; y < num_vars; ++y)
{
- const int32_t col = y % width;
- const int32_t row = y / width;
+ const int32_t col = y % width;
+ const int32_t row = y / width;
const std::string expected_var_name = "((half)(" + test[row][col] + "))";
- const std::string actual_var_name = vars[y].str;
+ const std::string actual_var_name = vars[y].str;
VALIDATE_TEST(actual_var_name.compare(expected_var_name) == 0, all_tests_passed, test_idx++);
}
-
}
return all_tests_passed;
}
@@ -78,7 +78,7 @@ public:
}
private:
- std::vector<TileContainer> _values {};
+ std::vector<TileContainer> _values{};
};
class CLConstantTileAccessScalarVariableBroadcastXTest : public ITest
@@ -113,8 +113,8 @@ public:
const size_t num_coords = _x_coord.size();
- std::random_device rd;
- std::mt19937 gen(rd());
+ std::random_device rd;
+ std::mt19937 gen(rd());
std::uniform_real_distribution<> dist(-1, 1);
int32_t test_idx = 0;
@@ -140,7 +140,7 @@ public:
const TileVariable var = tile.scalar(y_coord, x_coord);
- const std::string actual_var_name = var.str;
+ const std::string actual_var_name = var.str;
const std::string expected_var_name = "((half)(" + container[y_coord][x_coord_clamped] + "))";
VALIDATE_TEST(actual_var_name.compare(expected_var_name) == 0, all_tests_passed, test_idx++);
@@ -154,9 +154,9 @@ public:
}
private:
- std::vector<int32_t> _width {};
- std::vector<int32_t> _x_coord {};
- std::vector<int32_t> _y_coord {};
+ std::vector<int32_t> _width{};
+ std::vector<int32_t> _x_coord{};
+ std::vector<int32_t> _y_coord{};
};
class CLConstantTileAccessScalarVariableBroadcastYTest : public ITest
@@ -189,8 +189,8 @@ public:
// The status of this variable can change in VALIDATE_TEST()
bool all_tests_passed = true;
- std::random_device rd;
- std::mt19937 gen(rd());
+ std::random_device rd;
+ std::mt19937 gen(rd());
std::uniform_real_distribution<> dist(-1, 1);
const size_t num_coords = _x_coord.size();
@@ -218,7 +218,7 @@ public:
const TileVariable var = tile.scalar(y_coord, x_coord);
- const std::string actual_var_name = var.str;
+ const std::string actual_var_name = var.str;
const std::string expected_var_name = "((half)(" + container[y_coord_clamped][x_coord] + "))";
VALIDATE_TEST(actual_var_name.compare(expected_var_name) == 0, all_tests_passed, test_idx++);
@@ -232,9 +232,9 @@ public:
}
private:
- std::vector<int32_t> _height {};
- std::vector<int32_t> _x_coord {};
- std::vector<int32_t> _y_coord {};
+ std::vector<int32_t> _height{};
+ std::vector<int32_t> _x_coord{};
+ std::vector<int32_t> _y_coord{};
};
class CLConstantTileAccessVectorVariablesTest : public ITest
@@ -244,10 +244,11 @@ public:
CLConstantTileAccessVectorVariablesTest()
{
- _values.push_back({{"1.2", "3.5"}, {"4.2", "1.3"}});
- _values.push_back({{"1.2"}});
+ _values.push_back({ { "1.2", "3.5" },
+ { "4.2", "1.3" } });
+ _values.push_back({ { "1.2" } });
// Mix variable names and values
- _values.push_back({{"1.2", "acc", "8.7", "9.3", "ratio", "2.9", "1.7", "0.3"}});
+ _values.push_back({ { "1.2", "acc", "8.7", "9.3", "ratio", "2.9", "1.7", "0.3" } });
}
bool run() override
@@ -260,8 +261,8 @@ public:
for(const auto &test : _values)
{
const CLConstantTile tile(test, dt);
- const int32_t width = tile.info().width();
- const int32_t height = tile.info().height();
+ const int32_t width = tile.info().width();
+ const int32_t height = tile.info().height();
for(int32_t row = 0; row < height; ++row)
{
@@ -292,7 +293,7 @@ public:
}
private:
- std::vector<TileContainer> _values {};
+ std::vector<TileContainer> _values{};
};
class CLConstantTileAccessSubVectorVariablesTest : public ITest
@@ -302,7 +303,7 @@ public:
CLConstantTileAccessSubVectorVariablesTest()
{
- _values.push_back({{"1.2", "acc", "8.7", "9.3", "ratio", "2.9", "1.7", "0.3"}});
+ _values.push_back({ { "1.2", "acc", "8.7", "9.3", "ratio", "2.9", "1.7", "0.3" } });
_subwidths.push_back(1);
_subwidths.push_back(2);
_subwidths.push_back(3);
@@ -326,7 +327,7 @@ public:
for(auto &subwidth : _subwidths)
{
const CLConstantTile tile(test, dt);
- const int32_t height = tile.info().height();
+ const int32_t height = tile.info().height();
for(int32_t row = 0; row < height; ++row)
{
@@ -345,7 +346,8 @@ public:
expected_var_name += "))";
const std::string actual_var_name = tile.vector(row, col_start, subwidth).str;
- VALIDATE_TEST(actual_var_name.compare(expected_var_name) == 0, all_tests_passed, test_idx++);
+ VALIDATE_TEST(actual_var_name.compare(expected_var_name) == 0, all_tests_passed,
+ test_idx++);
}
}
}
@@ -359,9 +361,9 @@ public:
}
private:
- std::vector<TileContainer> _values {};
- std::vector<int32_t> _subwidths {};
- std::vector<int32_t> _offsets {};
+ std::vector<TileContainer> _values{};
+ std::vector<int32_t> _subwidths{};
+ std::vector<int32_t> _offsets{};
};
} // namespace ckw
diff --git a/compute_kernel_writer/validation/tests/CLTileTest.hpp b/compute_kernel_writer/validation/tests/CLTileTest.hpp
index 7847f0e128..ecfe811267 100644
--- a/compute_kernel_writer/validation/tests/CLTileTest.hpp
+++ b/compute_kernel_writer/validation/tests/CLTileTest.hpp
@@ -25,9 +25,9 @@
#ifndef COMPUTE_KERNEL_WRITER_TESTS_CLTILETEST_HPP
#define COMPUTE_KERNEL_WRITER_TESTS_CLTILETEST_HPP
+#include "common/Common.h"
#include "src/Helpers.h"
#include "src/cl/CLTile.h"
-#include "common/Common.h"
#include <string>
#include <vector>
@@ -37,9 +37,9 @@ namespace ckw
class CLTileInternalVariableNamesTest : public ITest
{
public:
- const int32_t width = 4;
- const int32_t height = 4;
- const DataType dt = DataType::Fp32;
+ const int32_t width = 4;
+ const int32_t height = 4;
+ const DataType dt = DataType::Fp32;
CLTileInternalVariableNamesTest()
{
@@ -59,12 +59,12 @@ public:
for(const auto &tile_name : _tile_name)
{
const CLTile tile(tile_name, info);
- const auto vars = tile.all();
+ const auto vars = tile.all();
for(int32_t y = 0; y < height; ++y)
{
const std::string expected_var_name = tile_name + "_" + std::to_string(y);
- const std::string actual_var_name = vars[y].str;
+ const std::string actual_var_name = vars[y].str;
VALIDATE_TEST(actual_var_name.compare(expected_var_name) == 0, all_tests_passed, test_idx++);
}
}
@@ -77,7 +77,7 @@ public:
}
private:
- std::vector<std::string> _tile_name {};
+ std::vector<std::string> _tile_name{};
};
class CLTileInternalNumVariablesTest : public ITest
@@ -106,12 +106,12 @@ public:
int32_t test_idx = 0;
for(size_t i = 0; i < num_dims; ++i)
{
- const int32_t width = _width[i];
- const int32_t height = _height[i];
+ const int32_t width = _width[i];
+ const int32_t height = _height[i];
const TileInfo info(DataType::Fp32, height, width);
- const CLTile tile("src", info);
- const auto vars = tile.all();
- const int32_t num_vars = vars.size();
+ const CLTile tile("src", info);
+ const auto vars = tile.all();
+ const int32_t num_vars = vars.size();
// We expect the number of variables to match the heigth of the tile
VALIDATE_TEST(num_vars == height, all_tests_passed, test_idx++);
@@ -125,8 +125,8 @@ public:
}
private:
- std::vector<int32_t> _width {};
- std::vector<int32_t> _height {};
+ std::vector<int32_t> _width{};
+ std::vector<int32_t> _height{};
};
class CLTileAccessScalarVariableTest : public ITest
@@ -153,7 +153,7 @@ public:
bool run() override
{
const TileInfo info(dt, height, width);
- const CLTile tile(tile_name, info);
+ const CLTile tile(tile_name, info);
VALIDATE_ON_MSG(_x_coord.size() == _y_coord.size(), "The number of x-coords and y-coords does not match");
@@ -170,8 +170,8 @@ public:
const TileVariable var = tile.scalar(y_coord, x_coord);
- const std::string actual_var_name = var.str;
- std::string expected_var_name = tile_name;
+ const std::string actual_var_name = var.str;
+ std::string expected_var_name = tile_name;
expected_var_name += "_" + std::to_string(y_coord);
expected_var_name += ".s" + dec_to_hex_as_string(x_coord);
@@ -186,8 +186,8 @@ public:
}
private:
- std::vector<int32_t> _x_coord {};
- std::vector<int32_t> _y_coord {};
+ std::vector<int32_t> _x_coord{};
+ std::vector<int32_t> _y_coord{};
};
class CLTileAccessScalarVariableBroadcastXTest : public ITest
@@ -232,12 +232,12 @@ public:
const int32_t x_coord_clamped = clamp(x_coord, static_cast<int32_t>(0), width - 1);
const TileInfo info(dt, height, width);
- const CLTile tile(tile_name, info);
+ const CLTile tile(tile_name, info);
const TileVariable var = tile.scalar(y_coord, x_coord);
- const std::string actual_var_name = var.str;
- std::string expected_var_name = tile_name;
+ const std::string actual_var_name = var.str;
+ std::string expected_var_name = tile_name;
expected_var_name += "_" + std::to_string(y_coord);
if(width != 1)
{
@@ -255,9 +255,9 @@ public:
}
private:
- std::vector<int32_t> _width {};
- std::vector<int32_t> _x_coord {};
- std::vector<int32_t> _y_coord {};
+ std::vector<int32_t> _width{};
+ std::vector<int32_t> _x_coord{};
+ std::vector<int32_t> _y_coord{};
};
class CLTileAccessScalarVariableBroadcastYTest : public ITest
@@ -302,12 +302,12 @@ public:
const int32_t y_coord_clamped = clamp(y_coord, static_cast<int32_t>(0), height - 1);
const TileInfo info(dt, height, width);
- const CLTile tile(tile_name, info);
+ const CLTile tile(tile_name, info);
const TileVariable var = tile.scalar(y_coord, x_coord);
- const std::string actual_var_name = var.str;
- std::string expected_var_name = tile_name;
+ const std::string actual_var_name = var.str;
+ std::string expected_var_name = tile_name;
if(height != 1)
{
expected_var_name += "_" + std::to_string(y_coord_clamped);
@@ -329,9 +329,9 @@ public:
}
private:
- std::vector<int32_t> _height {};
- std::vector<int32_t> _x_coord {};
- std::vector<int32_t> _y_coord {};
+ std::vector<int32_t> _height{};
+ std::vector<int32_t> _x_coord{};
+ std::vector<int32_t> _y_coord{};
};
class CLTileAccessVectorVariablesTest : public ITest
@@ -357,14 +357,14 @@ public:
for(const auto &height : _heights)
{
const TileInfo info(dt, height, width);
- const CLTile tile(tile_name, info);
+ const CLTile tile(tile_name, info);
for(int32_t row = 0; row < height; ++row)
{
const TileVariable var = tile.vector(row);
- const std::string actual_var_name = var.str;
- std::string expected_var_name = tile_name;
+ const std::string actual_var_name = var.str;
+ std::string expected_var_name = tile_name;
if(height != 1)
{
expected_var_name += "_" + std::to_string(row);
@@ -382,7 +382,7 @@ public:
}
private:
- std::vector<int32_t> _heights {};
+ std::vector<int32_t> _heights{};
};
class CLTileAccessSubVectorVariablesTest : public ITest
@@ -416,7 +416,7 @@ public:
for(const auto &subwidth : _subwidths)
{
const TileInfo info(dt, height, width);
- const CLTile tile(tile_name, info);
+ const CLTile tile(tile_name, info);
for(int32_t row = 0; row < height; ++row)
{
@@ -459,8 +459,8 @@ public:
}
private:
- std::vector<int32_t> _subwidths {};
- std::vector<int32_t> _offsets {};
+ std::vector<int32_t> _subwidths{};
+ std::vector<int32_t> _offsets{};
};
} // namespace ckw
diff --git a/compute_kernel_writer/validation/tests/TensorBitMaskTest.hpp b/compute_kernel_writer/validation/tests/TensorBitMaskTest.hpp
index a1a3588394..1e7d003879 100644
--- a/compute_kernel_writer/validation/tests/TensorBitMaskTest.hpp
+++ b/compute_kernel_writer/validation/tests/TensorBitMaskTest.hpp
@@ -72,13 +72,14 @@ public:
// The status of this variable can change in VALIDATE_TEST()
bool all_tests_passed = true;
- VALIDATE_ON_MSG(_component.size() == _bitmask.size(), "The number of layouts and components does not match");
+ VALIDATE_ON_MSG(_component.size() == _bitmask.size(),
+ "The number of layouts and components does not match");
const size_t num_tests = _component.size();
for(size_t i = 0; i < num_tests; ++i)
{
const TensorComponent component = _component[i];
const TensorComponentBitmask bitmask = _bitmask[i];
- const bool out = static_cast<uint32_t>(component) & static_cast<uint32_t>(bitmask);
+ const bool out = static_cast<uint32_t>(component) & static_cast<uint32_t>(bitmask);
VALIDATE_TEST(out == true, all_tests_passed, i);
}
return all_tests_passed;
@@ -90,8 +91,8 @@ public:
}
private:
- std::vector<TensorComponent> _component {};
- std::vector<TensorComponentBitmask> _bitmask {};
+ std::vector<TensorComponent> _component{};
+ std::vector<TensorComponentBitmask> _bitmask{};
};
class TensorBitMaskFalseTest : public ITest
@@ -191,13 +192,14 @@ public:
// The status of this variable can change in VALIDATE_TEST()
bool all_tests_passed = true;
- VALIDATE_ON_MSG(_component.size() == _bitmask.size(), "The number of layouts and components does not match");
+ VALIDATE_ON_MSG(_component.size() == _bitmask.size(),
+ "The number of layouts and components does not match");
const size_t num_tests = _component.size();
for(size_t i = 0; i < num_tests; ++i)
{
const TensorComponent component = _component[i];
const TensorComponentBitmask bitmask = _bitmask[i];
- const bool out = static_cast<uint32_t>(component) & static_cast<uint32_t>(bitmask);
+ const bool out = static_cast<uint32_t>(component) & static_cast<uint32_t>(bitmask);
VALIDATE_TEST(out == false, all_tests_passed, i);
}
return all_tests_passed;
@@ -209,9 +211,9 @@ public:
}
private:
- std::vector<TensorComponent> _component {};
- std::vector<TensorComponentBitmask> _bitmask {};
+ std::vector<TensorComponent> _component{};
+ std::vector<TensorComponentBitmask> _bitmask{};
};
-}
+} // namespace ckw
#endif /* COMPUTE_KERNEL_WRITER_TESTS_TENSORBITMASK_HPP */
diff --git a/compute_kernel_writer/validation/tests/UtilsTest.hpp b/compute_kernel_writer/validation/tests/UtilsTest.hpp
index 4a09d53f73..db1c8fd4ae 100644
--- a/compute_kernel_writer/validation/tests/UtilsTest.hpp
+++ b/compute_kernel_writer/validation/tests/UtilsTest.hpp
@@ -25,8 +25,8 @@
#define COMPUTE_KERNEL_WRITER_TESTS_UTILSTEST_HPP
#include "ckw/TensorInfo.h"
-#include "src/TensorUtils.h"
#include "common/Common.h"
+#include "src/TensorUtils.h"
#include <vector>
@@ -74,14 +74,15 @@ public:
bool all_tests_passed = true;
VALIDATE_ON_MSG(_layout.size() == _component.size(), "The number of layouts and components does not match");
- VALIDATE_ON_MSG(_layout.size() == _expected.size(), "The number of layouts and expected outputs does not match");
+ VALIDATE_ON_MSG(_layout.size() == _expected.size(),
+ "The number of layouts and expected outputs does not match");
const size_t num_tests = _layout.size();
for(size_t i = 0; i < num_tests; ++i)
{
const TensorDataLayout layout = _layout[i];
const TensorDataLayoutComponent component = _component[i];
const TensorComponent expected = _expected[i];
- const TensorComponent out = get_tensor_dimension(layout, component);
+ const TensorComponent out = get_tensor_dimension(layout, component);
VALIDATE_TEST(out == expected, all_tests_passed, i);
}
return all_tests_passed;
@@ -93,10 +94,10 @@ public:
}
private:
- std::vector<TensorDataLayout> _layout {};
- std::vector<TensorDataLayoutComponent> _component {};
- std::vector<TensorComponent> _expected {};
+ std::vector<TensorDataLayout> _layout{};
+ std::vector<TensorDataLayoutComponent> _component{};
+ std::vector<TensorComponent> _expected{};
};
-}
+} // namespace ckw
#endif /* COMPUTE_KERNEL_WRITER_TESTS_UTILSTEST_HPP */
diff --git a/compute_kernel_writer/validation/tests/common/Common.h b/compute_kernel_writer/validation/tests/common/Common.h
index d33d7f6688..8573c42b88 100644
--- a/compute_kernel_writer/validation/tests/common/Common.h
+++ b/compute_kernel_writer/validation/tests/common/Common.h
@@ -32,32 +32,34 @@ namespace ckw
{
#define VALIDATE_ON_MSG(exp, msg) assert(((void)msg, exp))
-#define VALIDATE_TEST(exp, all_tests_passed, id_test) \
- do \
- { \
- if((exp) == true) \
- { \
- all_tests_passed &= true; \
+#define VALIDATE_TEST(exp, all_tests_passed, id_test) \
+ do \
+ { \
+ if((exp) == true) \
+ { \
+ all_tests_passed &= true; \
const std::string msg = "TEST " + std::to_string((id_test)) + ": [PASSED]"; \
- std::cout << msg << std::endl; \
- } \
- else \
- { \
- all_tests_passed &= false; \
+ std::cout << msg << std::endl; \
+ } \
+ else \
+ { \
+ all_tests_passed &= false; \
const std::string msg = "TEST " + std::to_string((id_test)) + ": [FAILED]"; \
- std::cout << msg << std::endl; \
- } \
+ std::cout << msg << std::endl; \
+ } \
} while(false)
class ITest
{
public:
virtual ~ITest() = default;
+
/** Method to run the test
*
* @return it returns true if all tests passed
*/
virtual bool run() = 0;
+
/** Name of the test
*
* @return it returns the name of the test