diff options
author | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2023-07-07 11:25:57 +0100 |
---|---|---|
committer | Viet-Hoa Do <viet-hoa.do@arm.com> | 2023-07-20 08:48:15 +0000 |
commit | ebfdb5a1ea73c2269eec5af492970c2174ab7d0f (patch) | |
tree | 5c60d083100118f0a40e629dfa69b7a7373dd7fd /compute_kernel_writer/validation | |
parent | 29dc9fc1d3d6e90746ba1173e3318b774dcf7bed (diff) | |
download | ComputeLibrary-ebfdb5a1ea73c2269eec5af492970c2174ab7d0f.tar.gz |
Integrate CLTensorArgument
- Add CLTensorArgument to query the components and storages as OpenCL
variables (or by values when possible)
- Add caching mechanism in CLTensorArgument to keep track of the components and storages used
- Add unit tests
Resolves COMPMID-5787
Signed-off-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Signed-off-by: Viet-Hoa Do <viet-hoa.do@arm.com>
Change-Id: Ib39e1f77b097e5b907a296fe6b0d41bb4bcd4ffc
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9908
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Reviewed-by: Jakub Sujak <jakub.sujak@arm.com>
Diffstat (limited to 'compute_kernel_writer/validation')
-rw-r--r-- | compute_kernel_writer/validation/Validation.cpp | 21 | ||||
-rw-r--r-- | compute_kernel_writer/validation/tests/CLTensorArgumentTest.h | 533 | ||||
-rw-r--r-- | compute_kernel_writer/validation/tests/TensorBitMaskTest.h (renamed from compute_kernel_writer/validation/tests/TensorBitMaskTest.hpp) | 128 | ||||
-rw-r--r-- | compute_kernel_writer/validation/tests/UtilsTest.h (renamed from compute_kernel_writer/validation/tests/UtilsTest.hpp) | 31 |
4 files changed, 632 insertions, 81 deletions
diff --git a/compute_kernel_writer/validation/Validation.cpp b/compute_kernel_writer/validation/Validation.cpp index e4884fa4aa..5d53a16eff 100644 --- a/compute_kernel_writer/validation/Validation.cpp +++ b/compute_kernel_writer/validation/Validation.cpp @@ -22,12 +22,13 @@ * SOFTWARE. */ +#include "tests/CLConstantTileTest.hpp" #include "tests/CLKernelWriterCommentTest.h" #include "tests/CLKernelWriterDeclareTileTest.h" -#include "tests/CLConstantTileTest.hpp" +#include "tests/CLTensorArgumentTest.h" #include "tests/CLTileTest.hpp" -#include "tests/TensorBitMaskTest.hpp" -#include "tests/UtilsTest.hpp" +#include "tests/TensorBitMaskTest.h" +#include "tests/UtilsTest.h" #include <memory> #include <vector> @@ -65,6 +66,13 @@ int32_t main() const auto test15 = std::make_unique<CLKernelWriterCommentTest>(); #endif /* COMPUTE_KERNEL_WRITER_DEBUG_ENABLED */ const auto test16 = std::make_unique<CLKernelWriterDeclareTileTest>(); + const auto test17 = std::make_unique<CLTensorArgumentComponentNamesTest>(); + const auto test18 = std::make_unique<CLTensorArgumentStorageNamesTest>(); + const auto test19 = std::make_unique<CLTensorArgumentComponentValuesTest>(); + const auto test20 = std::make_unique<CLTensorArgumentComponentsUsedPassByValueFalseTest>(); + const auto test21 = std::make_unique<CLTensorArgumentComponentsUsedPassByValueTrueTest>(); + const auto test22 = std::make_unique<CLTensorArgumentStoragesUsedTest>(); + const auto test23 = std::make_unique<CLTensorArgumentComponentsUsedPassByValueTrueDynamicDimTrueTest>(); tests.push_back(test3.get()); tests.push_back(test4.get()); @@ -82,6 +90,13 @@ int32_t main() tests.push_back(test15.get()); #endif /* COMPUTE_KERNEL_WRITER_DEBUG_ENABLED */ tests.push_back(test16.get()); + tests.push_back(test17.get()); + tests.push_back(test18.get()); + tests.push_back(test19.get()); + tests.push_back(test20.get()); + tests.push_back(test21.get()); + tests.push_back(test22.get()); + tests.push_back(test23.get()); #endif /* COMPUTE_KERNEL_WRITER_OPENCL_ENABLED */ bool all_test_passed = true; diff --git a/compute_kernel_writer/validation/tests/CLTensorArgumentTest.h b/compute_kernel_writer/validation/tests/CLTensorArgumentTest.h new file mode 100644 index 0000000000..6db1384247 --- /dev/null +++ b/compute_kernel_writer/validation/tests/CLTensorArgumentTest.h @@ -0,0 +1,533 @@ +/* + * Copyright (c) 2023 Arm Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef CKW_TESTS_CLTENSORARGUMENTTEST_H +#define CKW_TESTS_CLTENSORARGUMENTTEST_H + +#include "common/Common.h" +#include "src/cl/CLHelpers.h" +#include "src/cl/CLTensorArgument.h" + +#include <string> +#include <vector> + +namespace ckw +{ +class CLTensorArgumentComponentNamesTest : public ITest +{ +public: + const DataType dt = DataType::Fp32; + const TensorShape shape = TensorShape({ { 12, 14, 3, 1, 2 } }); + const std::string tensor_name = "src"; + + CLTensorArgumentComponentNamesTest() + { + _components.push_back(TensorComponentType::Dim0); + _components.push_back(TensorComponentType::Dim1); + _components.push_back(TensorComponentType::Dim2); + _components.push_back(TensorComponentType::Dim3); + _components.push_back(TensorComponentType::Dim4); + _components.push_back(TensorComponentType::Dim1xDim2); + _components.push_back(TensorComponentType::Dim2xDim3); + _components.push_back(TensorComponentType::OffsetFirstElement); + _components.push_back(TensorComponentType::Stride0); + _components.push_back(TensorComponentType::Stride1); + _components.push_back(TensorComponentType::Stride2); + _components.push_back(TensorComponentType::Stride3); + _components.push_back(TensorComponentType::Stride4); + + _expected_vars.push_back("src_dim0"); + _expected_vars.push_back("src_dim1"); + _expected_vars.push_back("src_dim2"); + _expected_vars.push_back("src_dim3"); + _expected_vars.push_back("src_dim4"); + _expected_vars.push_back("src_dim1xdim2"); + _expected_vars.push_back("src_dim2xdim3"); + _expected_vars.push_back("src_offset_first_element"); + _expected_vars.push_back("src_stride0"); + _expected_vars.push_back("src_stride1"); + _expected_vars.push_back("src_stride2"); + _expected_vars.push_back("src_stride3"); + _expected_vars.push_back("src_stride4"); + } + + bool run() override + { + VALIDATE_ON_MSG(_components.size() == _expected_vars.size(), "The number of components and variables does not match"); + + // The status of this variable can change in VALIDATE_TEST() + bool all_tests_passed = true; + + const TensorInfo info(dt, shape, TensorDataLayout::Nhwc, 1); + + const size_t num_tests = _expected_vars.size(); + + int32_t test_idx = 0; + for(size_t i = 0; i < num_tests; ++i) + { + CLTensorArgument arg(tensor_name, info, false /* return_dims_by_value */); + + const std::string expected_var_name = _expected_vars[i]; + const std::string actual_var_name = arg.component(_components[i]).str; + + VALIDATE_TEST(actual_var_name.compare(expected_var_name) == 0, all_tests_passed, test_idx++); + } + return all_tests_passed; + } + + std::string name() override + { + return "CLTensorArgumentVariableNamesTest"; + } + +private: + std::vector<TensorComponentType> _components{}; + std::vector<std::string> _expected_vars{}; +}; + +class CLTensorArgumentStorageNamesTest : public ITest +{ +public: + const DataType dt = DataType::Fp32; + const TensorShape shape = TensorShape({ { 12, 14, 3, 1, 2 } }); + const std::string tensor_name = "src"; + + CLTensorArgumentStorageNamesTest() + { + _storages.push_back(TensorStorageType::BufferUint8Ptr); + _storages.push_back(TensorStorageType::Texture2dReadOnly); + _storages.push_back(TensorStorageType::Texture2dWriteOnly); + + _expected_vars.push_back("src_ptr"); + _expected_vars.push_back("src_img2d"); + _expected_vars.push_back("src_img2d"); + } + + bool run() override + { + VALIDATE_ON_MSG(_storages.size() == _expected_vars.size(), "The number of storages and variables does not match"); + + // The status of this variable can change in VALIDATE_TEST() + bool all_tests_passed = true; + + const TensorInfo info(dt, shape, TensorDataLayout::Nhwc, 1); + + const size_t num_tests = _expected_vars.size(); + + int32_t test_idx = 0; + for(size_t i = 0; i < num_tests; ++i) + { + CLTensorArgument arg(tensor_name, info, false /* return_dims_by_value */); + + const std::string expected_var_name = _expected_vars[i]; + const std::string actual_var_name = arg.storage(_storages[i]).val; + + VALIDATE_TEST(actual_var_name.compare(expected_var_name) == 0, all_tests_passed, test_idx++); + } + return all_tests_passed; + } + + std::string name() override + { + return "CLTensorArgumentStorageNamesTest"; + } + +private: + std::vector<TensorStorageType> _storages{}; + std::vector<std::string> _expected_vars{}; +}; + +class CLTensorArgumentComponentValuesTest : public ITest +{ +public: + const DataType dt = DataType::Fp32; + const TensorShape shape = TensorShape({ { 12, 14, 3, 1, 2 } }); + const std::string tensor_name = "src"; + + CLTensorArgumentComponentValuesTest() + { + _components.push_back(TensorComponentType::Dim0); + _components.push_back(TensorComponentType::Dim1); + _components.push_back(TensorComponentType::Dim2); + _components.push_back(TensorComponentType::Dim3); + _components.push_back(TensorComponentType::Dim4); + _components.push_back(TensorComponentType::Dim1xDim2); + _components.push_back(TensorComponentType::Dim2xDim3); + + _expected_vals.push_back(std::to_string(shape[0])); + _expected_vals.push_back(std::to_string(shape[1])); + _expected_vals.push_back(std::to_string(shape[2])); + _expected_vals.push_back(std::to_string(shape[3])); + _expected_vals.push_back(std::to_string(shape[4])); + _expected_vals.push_back(std::to_string(shape[1] * shape[2])); + _expected_vals.push_back(std::to_string(shape[2] * shape[3])); + } + + bool run() override + { + VALIDATE_ON_MSG(_components.size() == _expected_vals.size(), "The number of components and values does not match"); + + // The status of this variable can change in VALIDATE_TEST() + bool all_tests_passed = true; + + const TensorInfo info(dt, shape, TensorDataLayout::Nhwc, 1); + + const size_t num_tests = _expected_vals.size(); + + int32_t test_idx = 0; + for(size_t i = 0; i < num_tests; ++i) + { + CLTensorArgument arg(tensor_name, info, true /* return_dims_by_value */); + + const std::string expected_var_val = _expected_vals[i]; + const std::string actual_var_val = arg.component(_components[i]).str; + + VALIDATE_TEST(actual_var_val.compare(expected_var_val) == 0, all_tests_passed, test_idx++); + } + return all_tests_passed; + } + + std::string name() override + { + return "CLTensorArgumentComponentValuesTest"; + } + +private: + std::vector<TensorComponentType> _components{}; + std::vector<std::string> _expected_vals{}; +}; + +class CLTensorArgumentComponentsUsedPassByValueFalseTest : public ITest +{ +public: + const DataType dt = DataType::Fp32; + const TensorShape shape = TensorShape({ { 12, 14, 3, 1, 2 } }); + const std::string tensor_name = "src"; + + CLTensorArgumentComponentsUsedPassByValueFalseTest() + { + _components.push_back(TensorComponentType::Dim0); + _components.push_back(TensorComponentType::Dim2); + _components.push_back(TensorComponentType::Dim3); + _components.push_back(TensorComponentType::Dim1xDim2); + _components.push_back(TensorComponentType::OffsetFirstElement); + _components.push_back(TensorComponentType::Stride1); + _components.push_back(TensorComponentType::Stride2); + _components.push_back(TensorComponentType::Stride3); + _components.push_back(TensorComponentType::Dim0); // Repeat the query. The TensorArgument should not create a new variable + _components.push_back(TensorComponentType::Dim2); // Repeat the query. The TensorArgument should not create a new variable + _components.push_back(TensorComponentType::Dim3); // Repeat the query. The TensorArgument should not create a new variable + + _expected_vars.push_back("src_dim0"); + _expected_vars.push_back("src_dim2"); + _expected_vars.push_back("src_dim3"); + _expected_vars.push_back("src_dim1xdim2"); + _expected_vars.push_back("src_offset_first_element"); + _expected_vars.push_back("src_stride1"); + _expected_vars.push_back("src_stride2"); + _expected_vars.push_back("src_stride3"); + } + + bool run() override + { + // The status of this variable can change in VALIDATE_TEST() + bool all_tests_passed = true; + + const TensorInfo info(dt, shape, TensorDataLayout::Nhwc, 1); + + const size_t num_components = _components.size(); + + int32_t test_idx = 0; + + CLTensorArgument arg(tensor_name, info, false /* return_dims_by_value */); + for(size_t i = 0; i < num_components; ++i) + { + arg.component(_components[i]); + } + + const auto actual_vars = arg.components(); + + const size_t num_vars = _expected_vars.size(); + + VALIDATE_ON_MSG(actual_vars.size() == num_vars, "The number of variables must match the number of expected variables"); + + for(size_t i = 0; i < num_vars; ++i) + { + // Validate variable name + const std::string expected_var_name = _expected_vars[i]; + const std::string actual_var_name = actual_vars[i].str; + VALIDATE_TEST(actual_var_name.compare(expected_var_name) == 0, all_tests_passed, test_idx++); + + // Validate data type + const DataType expected_var_type = DataType::Int32; + const DataType actual_var_type = actual_vars[i].desc.dt; + VALIDATE_TEST(actual_var_type == expected_var_type, all_tests_passed, test_idx++); + + // Validate data type length + const int32_t expected_var_len = 1; + const int32_t actual_var_len = actual_vars[i].desc.len; + VALIDATE_TEST(actual_var_len == expected_var_len, all_tests_passed, test_idx++); + } + return all_tests_passed; + } + + std::string name() override + { + return "CLTensorArgumentComponentsUsedPassByValueFalseTest"; + } + +private: + std::vector<TensorComponentType> _components{}; + std::vector<std::string> _expected_vars{}; +}; + +class CLTensorArgumentComponentsUsedPassByValueTrueTest : public ITest +{ +public: + const DataType dt = DataType::Fp32; + const TensorShape shape = TensorShape({ { 12, 14, 3, 1, 2 } }); + const std::string tensor_name = "src"; + + CLTensorArgumentComponentsUsedPassByValueTrueTest() + { + _components.push_back(TensorComponentType::Dim0); + _components.push_back(TensorComponentType::Dim2); + _components.push_back(TensorComponentType::Dim3); + _components.push_back(TensorComponentType::Dim1xDim2); + _components.push_back(TensorComponentType::OffsetFirstElement); + _components.push_back(TensorComponentType::Stride1); + _components.push_back(TensorComponentType::Stride2); + _components.push_back(TensorComponentType::Stride3); + _components.push_back(TensorComponentType::OffsetFirstElement); // Repeat the query. The TensorArgument should not create a new variable + _components.push_back(TensorComponentType::Stride1); // Repeat the query. The TensorArgument should not create a new variable + + _expected_vars.push_back("src_offset_first_element"); + _expected_vars.push_back("src_stride1"); + _expected_vars.push_back("src_stride2"); + _expected_vars.push_back("src_stride3"); + } + + bool run() override + { + // The status of this variable can change in VALIDATE_TEST() + bool all_tests_passed = true; + + const TensorInfo info(dt, shape, TensorDataLayout::Nhwc, 1); + + const size_t num_components = _components.size(); + + int32_t test_idx = 0; + + CLTensorArgument arg(tensor_name, info, true /* return_dims_by_value */); + for(size_t i = 0; i < num_components; ++i) + { + arg.component(_components[i]); + } + + const auto actual_vars = arg.components(); + + const size_t num_vars = _expected_vars.size(); + + VALIDATE_ON_MSG(actual_vars.size() == num_vars, "The number of variables must match the number of expected variables"); + + // Since the dimensions are passed by value, we expect only the variables for the strides + for(size_t i = 0; i < num_vars; ++i) + { + // Validate variable name + const std::string expected_var_name = _expected_vars[i]; + const std::string actual_var_name = actual_vars[i].str; + VALIDATE_TEST(actual_var_name.compare(expected_var_name) == 0, all_tests_passed, test_idx++); + + // Validate data type + const DataType expected_var_type = DataType::Int32; + const DataType actual_var_type = actual_vars[i].desc.dt; + VALIDATE_TEST(actual_var_type == expected_var_type, all_tests_passed, test_idx++); + + // Validate data type length + const int32_t expected_var_len = 1; + const int32_t actual_var_len = actual_vars[i].desc.len; + VALIDATE_TEST(actual_var_len == expected_var_len, all_tests_passed, test_idx++); + } + return all_tests_passed; + } + + std::string name() override + { + return "CLTensorArgumentComponentsUsedPassByValueTrueTest"; + } + +private: + std::vector<TensorComponentType> _components{}; + std::vector<std::string> _expected_vars{}; +}; + +class CLTensorArgumentStoragesUsedTest : public ITest +{ +public: + const DataType dt = DataType::Fp32; + const TensorShape shape = TensorShape({ { 12, 14, 3, 1, 2 } }); + const std::string tensor_name = "src"; + + CLTensorArgumentStoragesUsedTest() + { + _storages.push_back(TensorStorageType::BufferUint8Ptr); + _storages.push_back(TensorStorageType::Texture2dReadOnly); + _storages.push_back(TensorStorageType::BufferUint8Ptr); // Repeat the query. The TensorArgument should not create a new variable + + _expected_vars.push_back("src_ptr"); + _expected_vars.push_back("src_img2d"); + } + + bool run() override + { + // The status of this variable can change in VALIDATE_TEST() + bool all_tests_passed = true; + + const TensorInfo info(dt, shape, TensorDataLayout::Nhwc, 1); + + const size_t num_storages = _storages.size(); + + int32_t test_idx = 0; + + CLTensorArgument arg(tensor_name, info, true /* return_dims_by_value */); + for(size_t i = 0; i < num_storages; ++i) + { + arg.storage(_storages[i]); + } + + const auto actual_vars = arg.storages(); + + const size_t num_vars = _expected_vars.size(); + + VALIDATE_ON_MSG(actual_vars.size() == num_vars, "The number of variables must match the number of expected variables"); + + for(size_t i = 0; i < num_vars; ++i) + { + // Validate variable name + const std::string expected_var_name = _expected_vars[i]; + const std::string actual_var_name = actual_vars[i].val; + VALIDATE_TEST(actual_var_name.compare(expected_var_name) == 0, all_tests_passed, test_idx++); + + // Validate storage type + const std::string expected_var_type = cl_get_variable_storagetype_as_string(_storages[i]); + const std::string actual_var_type = actual_vars[i].type; + VALIDATE_TEST(actual_var_type == expected_var_type, all_tests_passed, test_idx++); + } + return all_tests_passed; + } + + std::string name() override + { + return "CLTensorArgumentStoragesUsedTest"; + } + +private: + std::vector<TensorStorageType> _storages{}; + std::vector<std::string> _expected_vars{}; +}; + +class CLTensorArgumentComponentsUsedPassByValueTrueDynamicDimTrueTest : public ITest +{ +public: + const DataType dt = DataType::Fp32; + const TensorShape shape = TensorShape({ { -1, -1, 3, 1, 2 } }); + const std::string tensor_name = "src"; + + CLTensorArgumentComponentsUsedPassByValueTrueDynamicDimTrueTest() + { + _components.push_back(TensorComponentType::Dim0); + _components.push_back(TensorComponentType::Dim2); + _components.push_back(TensorComponentType::Dim3); + _components.push_back(TensorComponentType::Dim1xDim2); + _components.push_back(TensorComponentType::OffsetFirstElement); + _components.push_back(TensorComponentType::Stride1); + _components.push_back(TensorComponentType::Stride2); + _components.push_back(TensorComponentType::Stride3); + _components.push_back(TensorComponentType::OffsetFirstElement); // Repeat the query. The TensorArgument should not create a new variable + _components.push_back(TensorComponentType::Stride1); // Repeat the query. The TensorArgument should not create a new variable + + _expected_vars.push_back("src_dim0"); + _expected_vars.push_back("src_dim1xdim2"); + _expected_vars.push_back("src_offset_first_element"); + _expected_vars.push_back("src_stride1"); + _expected_vars.push_back("src_stride2"); + _expected_vars.push_back("src_stride3"); + } + + bool run() override + { + // The status of this variable can change in VALIDATE_TEST() + bool all_tests_passed = true; + + const TensorInfo info(dt, shape, TensorDataLayout::Nhwc, 1); + + const size_t num_components = _components.size(); + + int32_t test_idx = 0; + + CLTensorArgument arg(tensor_name, info, true /* return_dims_by_value */); + for(size_t i = 0; i < num_components; ++i) + { + arg.component(_components[i]); + } + + const auto actual_vars = arg.components(); + + const size_t num_vars = _expected_vars.size(); + + VALIDATE_ON_MSG(actual_vars.size() == num_vars, "The number of variables must match the number of expected variables"); + + // Since the dimensions are passed by value, we expect only the variables for the strides + for(size_t i = 0; i < num_vars; ++i) + { + // Validate variable name + const std::string expected_var_name = _expected_vars[i]; + const std::string actual_var_name = actual_vars[i].str; + VALIDATE_TEST(actual_var_name.compare(expected_var_name) == 0, all_tests_passed, test_idx++); + + // Validate data type + const DataType expected_var_type = DataType::Int32; + const DataType actual_var_type = actual_vars[i].desc.dt; + VALIDATE_TEST(actual_var_type == expected_var_type, all_tests_passed, test_idx++); + + // Validate data type length + const int32_t expected_var_len = 1; + const int32_t actual_var_len = actual_vars[i].desc.len; + VALIDATE_TEST(actual_var_len == expected_var_len, all_tests_passed, test_idx++); + } + return all_tests_passed; + } + + std::string name() override + { + return "CLTensorArgumentComponentsUsedPassByValueTrueDynamicDimTrueTest"; + } + +private: + std::vector<TensorComponentType> _components{}; + std::vector<std::string> _expected_vars{}; +}; +} // namespace ckw + +#endif // CKW_TESTS_CLTENSORARGUMENTTEST_H diff --git a/compute_kernel_writer/validation/tests/TensorBitMaskTest.hpp b/compute_kernel_writer/validation/tests/TensorBitMaskTest.h index 1e7d003879..759d926d18 100644 --- a/compute_kernel_writer/validation/tests/TensorBitMaskTest.hpp +++ b/compute_kernel_writer/validation/tests/TensorBitMaskTest.h @@ -21,11 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef COMPUTE_KERNEL_WRITER_TESTS_TENSORBITMASK_HPP -#define COMPUTE_KERNEL_WRITER_TESTS_TENSORBITMASK_HPP +#ifndef CKW_TESTS_TENSORBITMASKTEST_H +#define CKW_TESTS_TENSORBITMASKTEST_H #include "ckw/TensorInfo.h" +#include "ckw/types/TensorComponentType.h" #include "common/Common.h" +#include "src/types/TensorComponentType.h" #include <vector> @@ -36,20 +38,20 @@ class TensorBitMaskTrueTest : public ITest public: TensorBitMaskTrueTest() { - _component.push_back(TensorComponent::Dim0); - _component.push_back(TensorComponent::Dim1); - _component.push_back(TensorComponent::Dim2); - _component.push_back(TensorComponent::Dim3); - _component.push_back(TensorComponent::Dim4); - _component.push_back(TensorComponent::Stride0); - _component.push_back(TensorComponent::Stride1); - _component.push_back(TensorComponent::Stride2); - _component.push_back(TensorComponent::Stride3); - _component.push_back(TensorComponent::Stride4); - _component.push_back(TensorComponent::Dim1xDim2); - _component.push_back(TensorComponent::Dim1xDim2xDim3); - _component.push_back(TensorComponent::Dim2xDim3); - _component.push_back(TensorComponent::OffsetFirstElement); + _component.push_back(TensorComponentType::Dim0); + _component.push_back(TensorComponentType::Dim1); + _component.push_back(TensorComponentType::Dim2); + _component.push_back(TensorComponentType::Dim3); + _component.push_back(TensorComponentType::Dim4); + _component.push_back(TensorComponentType::Stride0); + _component.push_back(TensorComponentType::Stride1); + _component.push_back(TensorComponentType::Stride2); + _component.push_back(TensorComponentType::Stride3); + _component.push_back(TensorComponentType::Stride4); + _component.push_back(TensorComponentType::Dim1xDim2); + _component.push_back(TensorComponentType::Dim1xDim2xDim3); + _component.push_back(TensorComponentType::Dim2xDim3); + _component.push_back(TensorComponentType::OffsetFirstElement); _bitmask.push_back(TensorComponentBitmask::Dimension); _bitmask.push_back(TensorComponentBitmask::Dimension); @@ -77,7 +79,7 @@ public: const size_t num_tests = _component.size(); for(size_t i = 0; i < num_tests; ++i) { - const TensorComponent component = _component[i]; + const TensorComponentType component = _component[i]; const TensorComponentBitmask bitmask = _bitmask[i]; const bool out = static_cast<uint32_t>(component) & static_cast<uint32_t>(bitmask); VALIDATE_TEST(out == true, all_tests_passed, i); @@ -91,7 +93,7 @@ public: } private: - std::vector<TensorComponent> _component{}; + std::vector<TensorComponentType> _component{}; std::vector<TensorComponentBitmask> _bitmask{}; }; @@ -100,48 +102,48 @@ class TensorBitMaskFalseTest : public ITest public: TensorBitMaskFalseTest() { - _component.push_back(TensorComponent::Dim0); - _component.push_back(TensorComponent::Dim1); - _component.push_back(TensorComponent::Dim2); - _component.push_back(TensorComponent::Dim3); - _component.push_back(TensorComponent::Dim4); - _component.push_back(TensorComponent::Dim0); - _component.push_back(TensorComponent::Dim1); - _component.push_back(TensorComponent::Dim2); - _component.push_back(TensorComponent::Dim3); - _component.push_back(TensorComponent::Dim4); - _component.push_back(TensorComponent::Dim0); - _component.push_back(TensorComponent::Dim1); - _component.push_back(TensorComponent::Dim2); - _component.push_back(TensorComponent::Dim3); - _component.push_back(TensorComponent::Dim4); - _component.push_back(TensorComponent::Stride0); - _component.push_back(TensorComponent::Stride1); - _component.push_back(TensorComponent::Stride2); - _component.push_back(TensorComponent::Stride3); - _component.push_back(TensorComponent::Stride4); - _component.push_back(TensorComponent::Stride0); - _component.push_back(TensorComponent::Stride1); - _component.push_back(TensorComponent::Stride2); - _component.push_back(TensorComponent::Stride3); - _component.push_back(TensorComponent::Stride4); - _component.push_back(TensorComponent::Stride0); - _component.push_back(TensorComponent::Stride1); - _component.push_back(TensorComponent::Stride2); - _component.push_back(TensorComponent::Stride3); - _component.push_back(TensorComponent::Stride4); - _component.push_back(TensorComponent::Dim1xDim2); - _component.push_back(TensorComponent::Dim1xDim2xDim3); - _component.push_back(TensorComponent::Dim2xDim3); - _component.push_back(TensorComponent::Dim1xDim2); - _component.push_back(TensorComponent::Dim1xDim2xDim3); - _component.push_back(TensorComponent::Dim2xDim3); - _component.push_back(TensorComponent::Dim1xDim2); - _component.push_back(TensorComponent::Dim1xDim2xDim3); - _component.push_back(TensorComponent::Dim2xDim3); - _component.push_back(TensorComponent::OffsetFirstElement); - _component.push_back(TensorComponent::OffsetFirstElement); - _component.push_back(TensorComponent::OffsetFirstElement); + _component.push_back(TensorComponentType::Dim0); + _component.push_back(TensorComponentType::Dim1); + _component.push_back(TensorComponentType::Dim2); + _component.push_back(TensorComponentType::Dim3); + _component.push_back(TensorComponentType::Dim4); + _component.push_back(TensorComponentType::Dim0); + _component.push_back(TensorComponentType::Dim1); + _component.push_back(TensorComponentType::Dim2); + _component.push_back(TensorComponentType::Dim3); + _component.push_back(TensorComponentType::Dim4); + _component.push_back(TensorComponentType::Dim0); + _component.push_back(TensorComponentType::Dim1); + _component.push_back(TensorComponentType::Dim2); + _component.push_back(TensorComponentType::Dim3); + _component.push_back(TensorComponentType::Dim4); + _component.push_back(TensorComponentType::Stride0); + _component.push_back(TensorComponentType::Stride1); + _component.push_back(TensorComponentType::Stride2); + _component.push_back(TensorComponentType::Stride3); + _component.push_back(TensorComponentType::Stride4); + _component.push_back(TensorComponentType::Stride0); + _component.push_back(TensorComponentType::Stride1); + _component.push_back(TensorComponentType::Stride2); + _component.push_back(TensorComponentType::Stride3); + _component.push_back(TensorComponentType::Stride4); + _component.push_back(TensorComponentType::Stride0); + _component.push_back(TensorComponentType::Stride1); + _component.push_back(TensorComponentType::Stride2); + _component.push_back(TensorComponentType::Stride3); + _component.push_back(TensorComponentType::Stride4); + _component.push_back(TensorComponentType::Dim1xDim2); + _component.push_back(TensorComponentType::Dim1xDim2xDim3); + _component.push_back(TensorComponentType::Dim2xDim3); + _component.push_back(TensorComponentType::Dim1xDim2); + _component.push_back(TensorComponentType::Dim1xDim2xDim3); + _component.push_back(TensorComponentType::Dim2xDim3); + _component.push_back(TensorComponentType::Dim1xDim2); + _component.push_back(TensorComponentType::Dim1xDim2xDim3); + _component.push_back(TensorComponentType::Dim2xDim3); + _component.push_back(TensorComponentType::OffsetFirstElement); + _component.push_back(TensorComponentType::OffsetFirstElement); + _component.push_back(TensorComponentType::OffsetFirstElement); _bitmask.push_back(TensorComponentBitmask::Stride); _bitmask.push_back(TensorComponentBitmask::Stride); @@ -197,7 +199,7 @@ public: const size_t num_tests = _component.size(); for(size_t i = 0; i < num_tests; ++i) { - const TensorComponent component = _component[i]; + const TensorComponentType component = _component[i]; const TensorComponentBitmask bitmask = _bitmask[i]; const bool out = static_cast<uint32_t>(component) & static_cast<uint32_t>(bitmask); VALIDATE_TEST(out == false, all_tests_passed, i); @@ -211,9 +213,9 @@ public: } private: - std::vector<TensorComponent> _component{}; + std::vector<TensorComponentType> _component{}; std::vector<TensorComponentBitmask> _bitmask{}; }; } // namespace ckw -#endif /* COMPUTE_KERNEL_WRITER_TESTS_TENSORBITMASK_HPP */ +#endif // CKW_TESTS_TENSORBITMASKTEST_H diff --git a/compute_kernel_writer/validation/tests/UtilsTest.hpp b/compute_kernel_writer/validation/tests/UtilsTest.h index db1c8fd4ae..a335a48f81 100644 --- a/compute_kernel_writer/validation/tests/UtilsTest.hpp +++ b/compute_kernel_writer/validation/tests/UtilsTest.h @@ -21,10 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef COMPUTE_KERNEL_WRITER_TESTS_UTILSTEST_HPP -#define COMPUTE_KERNEL_WRITER_TESTS_UTILSTEST_HPP +#ifndef CKW_TESTS_UTILSTEST_H +#define CKW_TESTS_UTILSTEST_H #include "ckw/TensorInfo.h" +#include "ckw/types/TensorDataLayout.h" #include "common/Common.h" #include "src/TensorUtils.h" @@ -57,15 +58,15 @@ public: _component.push_back(TensorDataLayoutComponent::W); _component.push_back(TensorDataLayoutComponent::C); - _expected.push_back(TensorComponent::Dim3); - _expected.push_back(TensorComponent::Dim2); - _expected.push_back(TensorComponent::Dim1); - _expected.push_back(TensorComponent::Dim0); - _expected.push_back(TensorComponent::Dim4); - _expected.push_back(TensorComponent::Dim3); - _expected.push_back(TensorComponent::Dim2); - _expected.push_back(TensorComponent::Dim1); - _expected.push_back(TensorComponent::Dim0); + _expected.push_back(TensorComponentType::Dim3); + _expected.push_back(TensorComponentType::Dim2); + _expected.push_back(TensorComponentType::Dim1); + _expected.push_back(TensorComponentType::Dim0); + _expected.push_back(TensorComponentType::Dim4); + _expected.push_back(TensorComponentType::Dim3); + _expected.push_back(TensorComponentType::Dim2); + _expected.push_back(TensorComponentType::Dim1); + _expected.push_back(TensorComponentType::Dim0); } bool run() override @@ -81,8 +82,8 @@ public: { const TensorDataLayout layout = _layout[i]; const TensorDataLayoutComponent component = _component[i]; - const TensorComponent expected = _expected[i]; - const TensorComponent out = get_tensor_dimension(layout, component); + const TensorComponentType expected = _expected[i]; + const TensorComponentType out = get_tensor_dimension(layout, component); VALIDATE_TEST(out == expected, all_tests_passed, i); } return all_tests_passed; @@ -96,8 +97,8 @@ public: private: std::vector<TensorDataLayout> _layout{}; std::vector<TensorDataLayoutComponent> _component{}; - std::vector<TensorComponent> _expected{}; + std::vector<TensorComponentType> _expected{}; }; } // namespace ckw -#endif /* COMPUTE_KERNEL_WRITER_TESTS_UTILSTEST_HPP */ +#endif // CKW_TESTS_UTILSTEST_H |