diff --git a/docs/template_plugin/tests/functional/op_reference/batch_to_space.cpp b/docs/template_plugin/tests/functional/op_reference/batch_to_space.cpp new file mode 100644 index 00000000000..600a5448d58 --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/batch_to_space.cpp @@ -0,0 +1,222 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "openvino/opsets/opset1.hpp" +#include "openvino/opsets/opset2.hpp" +#include "base_reference_test.hpp" + +using namespace reference_tests; +using namespace ov; + +namespace { +struct BatchToSpaceParams { + BatchToSpaceParams(const Tensor& dataTensor, const Tensor& blockShapeTensor, + const Tensor& cropsBeginTensor, const Tensor& cropsEndTensor, + const Tensor& expectedTensor, const std::string& testcaseName = "") : + dataTensor(dataTensor), blockShapeTensor(blockShapeTensor), + cropsBeginTensor(cropsBeginTensor), cropsEndTensor(cropsEndTensor), + expectedTensor(expectedTensor), testcaseName(testcaseName) {} + + Tensor dataTensor; + Tensor blockShapeTensor; + Tensor cropsBeginTensor; + Tensor cropsEndTensor; + Tensor expectedTensor; + std::string testcaseName; +}; + +class ReferenceBatchToSpaceLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params); + inputData = {params.dataTensor.data}; + refOutData = {params.expectedTensor.data}; + } + + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "dType=" << param.dataTensor.type; + result << "_dShape=" << param.dataTensor.shape; + result << "_bsType=" << param.blockShapeTensor.type; + result << "_bsShape=" << param.blockShapeTensor.shape; + result << "_cbType=" << param.cropsBeginTensor.type; + result << "_cbShape=" << param.cropsBeginTensor.shape; + result << "_ceType=" << param.cropsEndTensor.type; + result << "_ceShape=" << param.cropsEndTensor.shape; + result << "_eType=" << param.expectedTensor.type; + if (param.testcaseName != "") { + result << "_eShape=" << param.expectedTensor.shape; + result << "_" << param.testcaseName; + } else { + result << "_eShape=" << param.expectedTensor.shape; + } + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(const BatchToSpaceParams& params) { + const auto data = std::make_shared(params.dataTensor.type, params.dataTensor.shape); + const auto blockShape = std::make_shared(element::i64, params.blockShapeTensor.shape, params.blockShapeTensor.data.data()); + const auto cropsBegin = std::make_shared(element::i64, params.cropsBeginTensor.shape, params.cropsBeginTensor.data.data()); + const auto cropsEnd = std::make_shared(element::i64, params.cropsEndTensor.shape, params.cropsEndTensor.data.data()); + const auto batchToSpace = std::make_shared(data, blockShape, cropsBegin, cropsEnd); + return std::make_shared(NodeVector {batchToSpace}, ParameterVector {data}); + } +}; + +TEST_P(ReferenceBatchToSpaceLayerTest, CompareWithRefs) { + Exec(); +} + +template +std::vector generateBatchToSpaceParams() { + using T = typename element_type_traits::value_type; + std::vector batchToSpaceParams { + // input_with_shape_4x3 + BatchToSpaceParams( + Tensor({4, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}), + Tensor({2}, element::i64, std::vector{1, 2}), + Tensor({2}, element::i64, std::vector{0, 0}), + Tensor({2}, element::i64, std::vector{0, 0}), + Tensor({2, 6}, IN_ET, std::vector{1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12}), + "input_with_shape_4x3"), + + // input_with_shape_4x1x1x3 + BatchToSpaceParams( + Tensor({4, 1, 1, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}), + Tensor({4}, element::i64, std::vector{1, 1, 1, 2}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({2, 1, 1, 6}, IN_ET, std::vector{1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12}), + "input_with_shape_4x1x1x3"), + // input_with_shape_4x1x1x3_1 + BatchToSpaceParams( + Tensor({4, 1, 1, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}), + Tensor({4}, element::i64, std::vector{1, 1, 2, 1}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({2, 1, 2, 3}, IN_ET, std::vector{1, 2, 3, 7, 8, 9, 4, 5, 6, 10, 11, 12}), + "input_with_shape_4x1x1x3_1"), + // input_with_shape_4x1x1x3_2 + BatchToSpaceParams( + Tensor({4, 1, 1, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}), + Tensor({4}, element::i64, std::vector{1, 1, 2, 2}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({2, 1, 1, 6}, IN_ET, std::vector{1, 4, 2, 5, 3, 6, 7, 10, 8, 11, 9, 12}), + "input_with_shape_4x1x1x3_2"), + + // input_with_shape_4x1x2x3 + BatchToSpaceParams( + Tensor({4, 1, 2, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24}), + Tensor({4}, element::i64, std::vector{1, 1, 1, 2}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({2, 1, 2, 6}, IN_ET, std::vector{1, 13, 2, 14, 3, 15, + 4, 16, 5, 17, 6, 18, + 7, 19, 8, 20, 9, 21, + 10, 22, 11, 23, 12, 24}), + "input_with_shape_4x1x2x3"), + // input_with_shape_4x1x2x3_1 + BatchToSpaceParams( + Tensor({4, 1, 2, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24}), + Tensor({4}, element::i64, std::vector{1, 1, 2, 1}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({2, 1, 4, 3}, IN_ET, std::vector{1, 2, 3, 13, 14, 15, + 4, 5, 6, 16, 17, 18, + 7, 8, 9, 19, 20, 21, + 10, 11, 12, 22, 23, 24}), + "input_with_shape_4x1x2x3_1"), + // input_with_shape_4x1x2x3_2 + BatchToSpaceParams( + Tensor({4, 1, 2, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24}), + Tensor({4}, element::i64, std::vector{1, 1, 2, 2}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({1, 1, 4, 6}, IN_ET, std::vector{1, 7, 2, 8, 3, 9, + 13, 19, 14, 20, 15, 21, + 4, 10, 5, 11, 6, 12, + 16, 22, 17, 23, 18, 24}), + "input_with_shape_4x1x2x3_2"), + + // input_with_shape_with_crop_4x1x2x3 + BatchToSpaceParams( + Tensor({4, 1, 2, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24}), + Tensor({4}, element::i64, std::vector{1, 1, 2, 2}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 2}), + Tensor({1, 1, 4, 4}, IN_ET, std::vector{1, 7, 2, 8, 13, 19, 14, 20, + 4, 10, 5, 11, 16, 22, 17, 23}), + "input_with_shape_with_crop_4x1x2x3"), + // input_with_shape_with_crop_4x1x2x3_1 + BatchToSpaceParams( + Tensor({4, 1, 2, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24}), + Tensor({4}, element::i64, std::vector{1, 1, 2, 2}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 2}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({1, 1, 4, 4}, IN_ET, std::vector{2, 8, 3, 9, 14, 20, 15, 21, + 5, 11, 6, 12, 17, 23, 18, 24}), + "input_with_shape_with_crop_4x1x2x3_1"), + // input_with_shape_with_crop_4x1x2x3_2 + BatchToSpaceParams( + Tensor({4, 1, 2, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24}), + Tensor({4}, element::i64, std::vector{1, 1, 2, 2}), + Tensor({4}, element::i64, std::vector{0, 0, 1, 0}), + Tensor({4}, element::i64, std::vector{0, 0, 1, 0}), + Tensor({1, 1, 2, 6}, IN_ET, std::vector{13, 19, 14, 20, 15, 21, + 4, 10, 5, 11, 6, 12}), + "input_with_shape_with_crop_4x1x2x3_2"), + }; + return batchToSpaceParams; +} + +std::vector generateBatchToSpaceCombinedParams() { + const std::vector> batchToSpaceTypeParams { + generateBatchToSpaceParams(), + generateBatchToSpaceParams(), + generateBatchToSpaceParams(), + generateBatchToSpaceParams(), + generateBatchToSpaceParams(), + generateBatchToSpaceParams(), + generateBatchToSpaceParams(), + generateBatchToSpaceParams(), + generateBatchToSpaceParams(), + generateBatchToSpaceParams(), + generateBatchToSpaceParams(), + generateBatchToSpaceParams(), + }; + std::vector combinedParams; + + for (const auto& params : batchToSpaceTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_BatchToSpace_With_Hardcoded_Refs, ReferenceBatchToSpaceLayerTest, + testing::ValuesIn(generateBatchToSpaceCombinedParams()), ReferenceBatchToSpaceLayerTest::getTestCaseName); +} // namespace \ No newline at end of file diff --git a/docs/template_plugin/tests/functional/op_reference/depth_to_space.cpp b/docs/template_plugin/tests/functional/op_reference/depth_to_space.cpp new file mode 100644 index 00000000000..b317ece708f --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/depth_to_space.cpp @@ -0,0 +1,157 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "openvino/opsets/opset1.hpp" +#include "base_reference_test.hpp" + +using namespace reference_tests; +using namespace ov; + +namespace { +struct DepthToSpaceParams { + DepthToSpaceParams(const Tensor& dataTensor, const std::string mode, const int32_t blockSize, + const Tensor& expectedTensor, const std::string& testcaseName = "") : + dataTensor(dataTensor), mode(mode), blockSize(blockSize), expectedTensor(expectedTensor), + testcaseName(testcaseName) {} + + Tensor dataTensor; + std::string mode; + int32_t blockSize; + Tensor expectedTensor; + std::string testcaseName; +}; + +class ReferenceDepthToSpaceLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params); + inputData = {params.dataTensor.data}; + refOutData = {params.expectedTensor.data}; + } + + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "dType=" << param.dataTensor.type; + result << "_dShape=" << param.dataTensor.shape; + result << "_eType=" << param.expectedTensor.type; + if (param.testcaseName != "") { + result << "_eShape=" << param.expectedTensor.shape; + result << "_" << param.testcaseName; + } else { + result << "_eShape=" << param.expectedTensor.shape; + } + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(const DepthToSpaceParams& params) { + opset1::DepthToSpace::DepthToSpaceMode mode = params.mode == "DEPTH_FIRST" ? + opset1::DepthToSpace::DepthToSpaceMode::DEPTH_FIRST : opset1::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST; + const auto data = std::make_shared(params.dataTensor.type, params.dataTensor.shape); + const auto depthToSpace = std::make_shared(data, mode, params.blockSize); + return std::make_shared(NodeVector {depthToSpace}, ParameterVector {data}); + } +}; + +TEST_P(ReferenceDepthToSpaceLayerTest, CompareWithRefs) { + Exec(); +} + +template +std::vector generateDepthToSpaceParams() { + using T = typename element_type_traits::value_type; + std::vector depthToSpaceParams { + // depth_to_space_block_first_K1_BS2 + DepthToSpaceParams( + Tensor({1, 8, 2}, IN_ET, std::vector{0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9, 11, 17, 19, 25, 27}), + "BLOCKS_FIRST", + 2, + Tensor({1, 4, 4}, IN_ET, std::vector{0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27}), + "depth_to_space_block_first_K1_BS2"), + + // depth_to_space_block_first_K2_BS2 + DepthToSpaceParams( + Tensor({1, 8, 2, 2}, IN_ET, std::vector{0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9, + 11, 17, 19, 25, 27, 4, 6, 12, 14, 20, 22, + 28, 30, 5, 7, 13, 15, 21, 23, 29, 31}), + "BLOCKS_FIRST", + 2, + Tensor({1, 2, 4, 4}, IN_ET, std::vector{0, 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, 28, 29, 30, 31}), + "depth_to_space_block_first_K2_BS2"), + + // depth_to_space_block_first_K2_BS4 + DepthToSpaceParams( + Tensor({1, 16, 2, 1}, IN_ET, std::vector{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, + 21, 6, 22, 7, 23, 8, 24, 9, 25, 10, 26, + 11, 27, 12, 28, 13, 29, 14, 30, 15, 31}), + "BLOCKS_FIRST", + 4, + Tensor({1, 1, 8, 4}, IN_ET, std::vector{0, 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, 28, 29, 30, 31}), + "depth_to_space_block_first_K2_BS4"), + + // depth_to_space_depth_first_1K_BS2 + DepthToSpaceParams( + Tensor({1, 8, 2}, IN_ET, std::vector{0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11, 12, 14, 13, 15}), + "DEPTH_FIRST", + 2, + Tensor({1, 4, 4}, IN_ET, std::vector{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}), + "depth_to_space_depth_first_1K_BS2"), + + // depth_to_space_depth_first_2K_BS2 + DepthToSpaceParams( + Tensor({1, 8, 2, 2}, IN_ET, std::vector{0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9, + 11, 17, 19, 25, 27, 4, 6, 12, 14, 20, 22, + 28, 30, 5, 7, 13, 15, 21, 23, 29, 31}), + "DEPTH_FIRST", + 2, + Tensor({1, 2, 4, 4}, IN_ET, std::vector{0, 16, 2, 18, 1, 17, 3, 19, 8, 24, 10, 26, 9, 25, 11, 27, + 4, 20, 6, 22, 5, 21, 7, 23, 12, 28, 14, 30, 13, 29, 15, 31}), + "depth_to_space_depth_first_2K_BS2"), + + // depth_to_space_depth_first_2K_BS4 + DepthToSpaceParams( + Tensor({1, 16, 2, 1}, IN_ET, std::vector{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, + 21, 6, 22, 7, 23, 8, 24, 9, 25, 10, 26, + 11, 27, 12, 28, 13, 29, 14, 30, 15, 31}), + "DEPTH_FIRST", + 4, + Tensor({1, 1, 8, 4}, IN_ET, std::vector{0, 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, 28, 29, 30, 31}), + "depth_to_space_depth_first_2K_BS4"), + }; + return depthToSpaceParams; +} + +std::vector generateDepthToSpaceCombinedParams() { + const std::vector> depthToSpaceTypeParams { + generateDepthToSpaceParams(), + generateDepthToSpaceParams(), + generateDepthToSpaceParams(), + generateDepthToSpaceParams(), + generateDepthToSpaceParams(), + generateDepthToSpaceParams(), + generateDepthToSpaceParams(), + generateDepthToSpaceParams(), + generateDepthToSpaceParams(), + generateDepthToSpaceParams(), + generateDepthToSpaceParams(), + generateDepthToSpaceParams(), + }; + std::vector combinedParams; + + for (const auto& params : depthToSpaceTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_DepthToSpace_With_Hardcoded_Refs, ReferenceDepthToSpaceLayerTest, + testing::ValuesIn(generateDepthToSpaceCombinedParams()), ReferenceDepthToSpaceLayerTest::getTestCaseName); +} // namespace \ No newline at end of file diff --git a/docs/template_plugin/tests/functional/op_reference/roll.cpp b/docs/template_plugin/tests/functional/op_reference/roll.cpp new file mode 100644 index 00000000000..3fdb1f4e217 --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/roll.cpp @@ -0,0 +1,212 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "openvino/opsets/opset1.hpp" +#include "openvino/opsets/opset7.hpp" +#include "base_reference_test.hpp" + +using namespace reference_tests; +using namespace ov; + +namespace { +struct RollParams { + RollParams(const Tensor& dataTensor, const Tensor& shiftTensor, const Tensor& axesTensor, + const Tensor& expectedTensor, const std::string& testcaseName = "") : + dataTensor(dataTensor), shiftTensor(shiftTensor), axesTensor(axesTensor), + expectedTensor(expectedTensor), testcaseName(testcaseName) {} + + Tensor dataTensor; + Tensor shiftTensor; + Tensor axesTensor; + Tensor expectedTensor; + std::string testcaseName; +}; + +class ReferenceRollLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params); + inputData = {params.dataTensor.data}; + refOutData = {params.expectedTensor.data}; + } + + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "dType=" << param.dataTensor.type; + result << "_dShape=" << param.dataTensor.shape; + result << "_sType=" << param.shiftTensor.type; + result << "_sShape=" << param.shiftTensor.shape; + result << "_aType=" << param.axesTensor.type; + result << "_aShape=" << param.axesTensor.shape; + result << "_eType=" << param.expectedTensor.type; + if (param.testcaseName != "") { + result << "_eShape=" << param.expectedTensor.shape; + result << "_=" << param.testcaseName; + } else { + result << "_eShape=" << param.expectedTensor.shape; + } + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(const RollParams& params) { + const auto data = std::make_shared(params.dataTensor.type, params.dataTensor.shape); + const auto shift = std::make_shared(params.shiftTensor.type, + params.shiftTensor.shape, + params.shiftTensor.data.data()); + const auto axes = std::make_shared(params.axesTensor.type, + params.axesTensor.shape, + params.axesTensor.data.data()); + const auto roll = std::make_shared(data, shift, axes); + return std::make_shared(NodeVector {roll}, ParameterVector {data}); + } +}; + +TEST_P(ReferenceRollLayerTest, CompareWithRefs) { + Exec(); +} + +template +std::vector generateRollParams() { + using T = typename element_type_traits::value_type; + std::vector rollParams { + // roll_repeated_axes + RollParams( + Tensor({4, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}), + Tensor({3}, element::i64, std::vector{1, 2, 1}), + Tensor({3}, element::i64, std::vector{0, 1, 0}), + Tensor({4, 3}, IN_ET, std::vector{8, 9, 7, 11, 12, 10, 2, 3, 1, 5, 6, 4}), + "roll_repeated_axes"), + + // roll_negative_axes + RollParams( + Tensor({4, 2, 3}, IN_ET, std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}), + Tensor({3}, element::i64, std::vector{2, -1, -7}), + Tensor({3}, element::i64, std::vector{-1, -1, -2}), + Tensor({4, 2, 3}, IN_ET, std::vector{6, 4, 5, 3, 1, 2, 12, 10, 11, 9, 7, 8, 18, 16, 17, 15, 13, 14, 24, 22, 23, 21, 19, 20}), + "roll_negative_axes"), + }; + return rollParams; +} + +std::vector generateRollFloatingPointParams() { + std::vector rollParams { + // roll_2d_input + RollParams( + Tensor({4, 3}, element::f32, std::vector{50.2907, + 70.8054, + -68.3403, + 62.6444, + 4.9748, + -18.5551, + 40.5383, + -15.3859, + -4.5881, + -43.3479, + 94.1676, + -95.7097}), + Tensor({1}, element::i64, std::vector{1}), + Tensor({1}, element::i64, std::vector{0}), + Tensor({4, 3}, element::f32, std::vector{-43.3479, + 94.1676, + -95.7097, + 50.2907, + 70.8054, + -68.3403, + 62.6444, + 4.9748, + -18.5551, + 40.5383, + -15.3859, + -4.5881}), + "roll_2d_input"), + + // roll_2d_input_negative_shift + RollParams( + Tensor({4, 3}, element::f32, std::vector{50.2907, + 70.8054, + -68.3403, + 62.6444, + 4.9748, + -18.5551, + 40.5383, + -15.3859, + -4.5881, + -43.3479, + 94.1676, + -95.7097}), + Tensor({2}, element::i64, std::vector{-1, 2}), + Tensor({2}, element::i64, std::vector{0, 1}), + Tensor({4, 3}, element::f32, std::vector{4.9748, + -18.5551, + 62.6444, + -15.3859, + -4.5881, + 40.5383, + 94.1676, + -95.7097, + -43.3479, + 70.8054, + -68.3403, + 50.2907}), + "roll_2d_input_negative_shift"), + + // roll_3d_input + RollParams( + Tensor({4, 2, 3}, element::f32, std::vector{94.0773, 33.0599, 58.1724, -20.3640, 54.5372, -54.3023, 10.4662, 11.7532, + -11.7692, 56.4223, -95.3774, 8.8978, 1.9305, 13.8025, 12.0827, 81.4669, + 19.5321, -8.9553, -75.3226, 20.8033, 20.7660, 62.7361, 14.9372, -33.0825}), + Tensor({3}, element::i64, std::vector{2, 1, 3}), + Tensor({3}, element::i64, std::vector{0, 1, 2}), + Tensor({4, 2, 3}, element::f32, std::vector{81.4669, 19.5321, -8.9553, 1.9305, 13.8025, 12.0827, 62.7361, 14.9372, + -33.0825, -75.3226, 20.8033, 20.7660, -20.3640, 54.5372, -54.3023, 94.0773, + 33.0599, 58.1724, 56.4223, -95.3774, 8.8978, 10.4662, 11.7532, -11.7692}), + "roll_3d_input"), + + // roll_3d_input_negative_shift + RollParams( + Tensor({4, 2, 3}, element::f32, std::vector{94.0773, 33.0599, 58.1724, -20.3640, 54.5372, -54.3023, 10.4662, 11.7532, + -11.7692, 56.4223, -95.3774, 8.8978, 1.9305, 13.8025, 12.0827, 81.4669, + 19.5321, -8.9553, -75.3226, 20.8033, 20.7660, 62.7361, 14.9372, -33.0825}), + Tensor({3}, element::i64, std::vector{-5, 1, 3}), + Tensor({3}, element::i64, std::vector{0, 1, 1}), + Tensor({4, 2, 3}, element::f32, std::vector{10.4662, 11.7532, -11.7692, 56.4223, -95.3774, 8.8978, 1.9305, 13.8025, + 12.0827, 81.4669, 19.5321, -8.9553, -75.3226, 20.8033, 20.7660, 62.7361, + 14.9372, -33.0825, 94.0773, 33.0599, 58.1724, -20.3640, 54.5372, -54.3023}), + "roll_3d_input_negative_shift"), + }; + return rollParams; +} + +std::vector generateRollCombinedParams() { + const std::vector> rollTypeParams { + generateRollParams(), + generateRollParams(), + generateRollParams(), + generateRollParams(), + generateRollParams(), + generateRollParams(), + generateRollParams(), + generateRollParams(), + generateRollParams(), + generateRollParams(), + generateRollParams(), + generateRollParams(), + generateRollFloatingPointParams(), + }; + std::vector combinedParams; + + for (const auto& params : rollTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_Roll_With_Hardcoded_Refs, ReferenceRollLayerTest, + testing::ValuesIn(generateRollCombinedParams()), ReferenceRollLayerTest::getTestCaseName); +} // namespace \ No newline at end of file diff --git a/docs/template_plugin/tests/functional/op_reference/shuffle_channels.cpp b/docs/template_plugin/tests/functional/op_reference/shuffle_channels.cpp new file mode 100644 index 00000000000..1c6c613dba7 --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/shuffle_channels.cpp @@ -0,0 +1,209 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "openvino/opsets/opset1.hpp" +#include "base_reference_test.hpp" + +using namespace reference_tests; +using namespace ov; + +namespace { +struct ShuffleChannelsParams { + ShuffleChannelsParams(const Tensor& dataTensor, const int32_t axis, const int32_t group, + const Tensor& expectedTensor, const std::string& testcaseName = "") : + dataTensor(dataTensor), axis(axis), group(group), + expectedTensor(expectedTensor), testcaseName(testcaseName) {} + + Tensor dataTensor; + int32_t axis; + int32_t group; + Tensor expectedTensor; + std::string testcaseName; +}; + +class ReferenceShuffleChannelsLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params); + inputData = {params.dataTensor.data}; + refOutData = {params.expectedTensor.data}; + } + + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "dType=" << param.dataTensor.type; + result << "_dShape=" << param.dataTensor.shape; + result << "_axis=" << param.axis; + result << "_group=" << param.group; + result << "_eType=" << param.expectedTensor.type; + if (param.testcaseName != "") { + result << "_eShape=" << param.expectedTensor.shape; + result << "_=" << param.testcaseName; + } else { + result << "_eShape=" << param.expectedTensor.shape; + } + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(const ShuffleChannelsParams& params) { + const auto data = std::make_shared(params.dataTensor.type, params.dataTensor.shape); + const auto function = std::make_shared(data, params.axis, params.group); + return std::make_shared(NodeVector {function}, ParameterVector {data}); + } +}; + +TEST_P(ReferenceShuffleChannelsLayerTest, CompareWithRefs) { + Exec(); +} + +template +std::vector generateParams() { + using T = typename element_type_traits::value_type; + std::vector params { + // shuffle_channels_simple + ShuffleChannelsParams( + Tensor({1, 15, 2, 2}, IN_ET, std::vector{ + 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}), + 1, + 5, + Tensor({1, 15, 2, 2}, IN_ET, std::vector{ + 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}), + "shuffle_channels_simple"), + + // shuffle_channels_negative_axis + ShuffleChannelsParams( + Tensor({15, 2, 1, 2}, IN_ET, std::vector{ + 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}), + -4, + 5, + Tensor({15, 2, 1, 2}, IN_ET, std::vector{ + 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}), + "shuffle_channels_negative_axis"), + + // shuffle_channels_float + ShuffleChannelsParams( + Tensor({6, 1, 1, 1}, IN_ET, std::vector{0, 1, 2, 3, 4, 5}), + 0, + 2, + Tensor({6, 1, 1, 1}, IN_ET, std::vector{0, 3, 1, 4, 2, 5}), + "shuffle_channels_float"), + + // shuffle_channels_1d + ShuffleChannelsParams( + Tensor({15}, IN_ET, std::vector{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}), + 0, + 5, + Tensor({15}, IN_ET, std::vector{0, 3, 6, 9, 12, 1, 4, 7, 10, 13, 2, 5, 8, 11, 14}), + "shuffle_channels_1d"), + + // shuffle_channels_2d + ShuffleChannelsParams( + Tensor({15, 4}, IN_ET, std::vector{ + 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}), + 0, + 5, + Tensor({15, 4}, IN_ET, std::vector{ + 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, + 39, 48, 49, 50, 51, 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, + 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, 8, 9, 10, 11, 20, + 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}), + "shuffle_channels_2d"), + + // shuffle_channels_3d + ShuffleChannelsParams( + Tensor({15, 2, 2}, IN_ET, std::vector{ + 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}), + 0, + 5, + Tensor({15, 2, 2}, IN_ET, std::vector{ + 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, + 39, 48, 49, 50, 51, 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, + 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, 8, 9, 10, 11, 20, + 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}), + "shuffle_channels_3d"), + + // shuffle_channels_5d + ShuffleChannelsParams( + Tensor({2, 2, 15, 2, 2}, IN_ET, std::vector{ + 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + + 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + + 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + + 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}), + 2, + 5, + Tensor({2, 2, 15, 2, 2}, IN_ET, std::vector{ + 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59, + + 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59, + + 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59, + + 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, + 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, + 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}), + "shuffle_channels_5d"), + }; + return params; +} + +std::vector generateShuffleChannelsCombinedParams() { + const std::vector> generatedParams { + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + }; + std::vector combinedParams; + + for (const auto& params : generatedParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels_With_Hardcoded_Refs, ReferenceShuffleChannelsLayerTest, + testing::ValuesIn(generateShuffleChannelsCombinedParams()), ReferenceShuffleChannelsLayerTest::getTestCaseName); +} // namespace \ No newline at end of file diff --git a/docs/template_plugin/tests/functional/op_reference/space_to_batch.cpp b/docs/template_plugin/tests/functional/op_reference/space_to_batch.cpp new file mode 100644 index 00000000000..42a5c950648 --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/space_to_batch.cpp @@ -0,0 +1,143 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "openvino/opsets/opset1.hpp" +#include "openvino/opsets/opset2.hpp" +#include "openvino/op/constant.hpp" +#include "base_reference_test.hpp" + +using namespace reference_tests; +using namespace ov; + +namespace { +struct SpaceToBatchParams { + SpaceToBatchParams(const Tensor& dataTensor, const Tensor& blockShapeTensor, + const Tensor& padsBeginTensor, const Tensor& padsEndTensor, + const Tensor& expectedTensor, const std::string& testcaseName = "") : + dataTensor(dataTensor), blockShapeTensor(blockShapeTensor), + padsBeginTensor(padsBeginTensor), padsEndTensor(padsEndTensor), + expectedTensor(expectedTensor), testcaseName(testcaseName) {} + + Tensor dataTensor; + Tensor blockShapeTensor; + Tensor padsBeginTensor; + Tensor padsEndTensor; + Tensor expectedTensor; + std::string testcaseName; +}; + +class ReferenceSpaceToBatchLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params); + inputData = {params.dataTensor.data}; + refOutData = {params.expectedTensor.data}; + } + + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "dType=" << param.dataTensor.type; + result << "_dShape=" << param.dataTensor.shape; + result << "_bsType=" << param.blockShapeTensor.type; + result << "_bsShape=" << param.blockShapeTensor.shape; + result << "_pbType=" << param.padsBeginTensor.type; + result << "_pbShape=" << param.padsBeginTensor.shape; + result << "_peType=" << param.padsEndTensor.type; + result << "_peShape=" << param.padsEndTensor.shape; + result << "_eType=" << param.expectedTensor.type; + if (param.testcaseName != "") { + result << "_eShape=" << param.expectedTensor.shape; + result << "_" << param.testcaseName; + } else { + result << "_eShape=" << param.expectedTensor.shape; + } + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(const SpaceToBatchParams& params) { + const auto data = std::make_shared(params.dataTensor.type, params.dataTensor.shape); + const auto blockShape = std::make_shared(element::i64, params.blockShapeTensor.shape, params.blockShapeTensor.data.data()); + const auto padsBegin = std::make_shared(element::i64, params.padsBeginTensor.shape, params.padsBeginTensor.data.data()); + const auto padsEnd = std::make_shared(element::i64, params.padsEndTensor.shape, params.padsEndTensor.data.data()); + const auto batchToSpace = std::make_shared(data, blockShape, padsBegin, padsEnd); + return std::make_shared(NodeVector {batchToSpace}, ParameterVector {data}); + } +}; + +TEST_P(ReferenceSpaceToBatchLayerTest, CompareWithRefs) { + Exec(); +} + +template +std::vector generateParams() { + using T = typename element_type_traits::value_type; + std::vector batchToSpaceParams { + // space_to_batch_4D + SpaceToBatchParams( + Tensor({1, 1, 2, 2}, IN_ET, std::vector{1, 1, 1, 1}), + Tensor({4}, element::i64, std::vector{1, 1, 1, 1}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({1, 1, 2, 2}, IN_ET, std::vector{1, 1, 1, 1}), + "space_to_batch_4D"), + + // space_to_batch_5D + SpaceToBatchParams( + Tensor({1, 1, 3, 2, 1}, IN_ET, std::vector{1, 1, 1, 1, 1, 1}), + Tensor({5}, element::i64, std::vector{1, 1, 3, 2, 2}), + Tensor({5}, element::i64, std::vector{0, 0, 1, 0, 3}), + Tensor({5}, element::i64, std::vector{0, 0, 2, 0, 0}), + Tensor({12, 1, 2, 1, 2}, IN_ET, std::vector{ + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}), + "space_to_batch_5D"), + + // space_to_batch_4x4 + SpaceToBatchParams( + Tensor({1, 1, 4, 4}, IN_ET, std::vector{ + 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}), + Tensor({4}, element::i64, std::vector{1, 1, 1, 1}), + Tensor({4}, element::i64, std::vector{0, 0, 1, 0}), + Tensor({4}, element::i64, std::vector{0, 0, 0, 0}), + Tensor({1, 1, 5, 4}, IN_ET, std::vector{ + 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}), + "space_to_batch_4x4"), + }; + return batchToSpaceParams; +} + +std::vector generateCombinedParams() { + const std::vector> batchToSpaceTypeParams { + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + }; + std::vector combinedParams; + + for (const auto& params : batchToSpaceTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_SpaceToBatch_With_Hardcoded_Refs, ReferenceSpaceToBatchLayerTest, + testing::ValuesIn(generateCombinedParams()), ReferenceSpaceToBatchLayerTest::getTestCaseName); +} // namespace \ No newline at end of file diff --git a/docs/template_plugin/tests/functional/op_reference/space_to_depth.cpp b/docs/template_plugin/tests/functional/op_reference/space_to_depth.cpp new file mode 100644 index 00000000000..b834fbeee7d --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/space_to_depth.cpp @@ -0,0 +1,169 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "openvino/opsets/opset1.hpp" +#include "base_reference_test.hpp" + +using namespace reference_tests; +using namespace ov; + +namespace { +struct SpaceToDepthParams { + SpaceToDepthParams(const Tensor& dataTensor, const std::string mode, const int32_t blockSize, + const Tensor& expectedTensor, const std::string& testcaseName = "") : + dataTensor(dataTensor), mode(mode), blockSize(blockSize), expectedTensor(expectedTensor), + testcaseName(testcaseName) {} + + Tensor dataTensor; + std::string mode; + int32_t blockSize; + Tensor expectedTensor; + std::string testcaseName; +}; + +class ReferenceSpaceToDepthLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params); + inputData = {params.dataTensor.data}; + refOutData = {params.expectedTensor.data}; + } + + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "dType=" << param.dataTensor.type; + result << "_dShape=" << param.dataTensor.shape; + result << "_eType=" << param.expectedTensor.type; + if (param.testcaseName != "") { + result << "_eShape=" << param.expectedTensor.shape; + result << "_" << param.testcaseName; + } else { + result << "_eShape=" << param.expectedTensor.shape; + } + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(const SpaceToDepthParams& params) { + opset1::SpaceToDepth::SpaceToDepthMode mode = params.mode == "DEPTH_FIRST" ? + opset1::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST : opset1::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST; + const auto data = std::make_shared(params.dataTensor.type, params.dataTensor.shape); + const auto SpaceToDepth = std::make_shared(data, mode, params.blockSize); + return std::make_shared(NodeVector {SpaceToDepth}, ParameterVector {data}); + } +}; + +TEST_P(ReferenceSpaceToDepthLayerTest, CompareWithRefs) { + Exec(); +} + +template +std::vector generateParams() { + using T = typename element_type_traits::value_type; + std::vector params { + // space_to_depth_block_first_K2_BS2 + SpaceToDepthParams( + Tensor({1, 2, 4, 4}, IN_ET, std::vector{ + 0, 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, 28, 29, 30, 31}), + "BLOCKS_FIRST", + 2, + Tensor({1, 8, 2, 2}, IN_ET, std::vector{ + 0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9, 11, 17, 19, 25, 27, + 4, 6, 12, 14, 20, 22, 28, 30, 5, 7, 13, 15, 21, 23, 29, 31}), + "space_to_depth_block_first_K2_BS2"), + + // space_to_depth_block_first_K2_BS3 + SpaceToDepthParams( + Tensor({1, 2, 6, 3}, IN_ET, std::vector{ + 0, 4, 8, 12, 16, 20, 24, 28, 32, 1, 5, 9, + 13, 17, 21, 25, 29, 33, 2, 6, 10, 14, 18, 22, + 26, 30, 34, 3, 7, 11, 15, 19, 23, 27, 31, 35}), + "BLOCKS_FIRST", + 3, + Tensor({1, 18, 2, 1}, IN_ET, std::vector{ + 0, 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, 28, 29, 30, 31, 32, 33, 34, 35}), + "space_to_depth_block_first_K2_BS3"), + + // space_to_depth_block_first_K1_BS3 + SpaceToDepthParams( + Tensor({1, 2, 6}, IN_ET, std::vector{ + 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11}), + "BLOCKS_FIRST", + 3, + Tensor({1, 6, 2}, IN_ET, std::vector{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}), + "space_to_depth_block_first_K1_BS3"), + + // space_to_depth_depth_first_K2_BS2 + SpaceToDepthParams( + Tensor({1, 2, 4, 4}, IN_ET, std::vector{ + 0, 16, 2, 18, 1, 17, 3, 19, 8, 24, 10, + 26, 9, 25, 11, 27, 4, 20, 6, 22, 5, 21, + 7, 23, 12, 28, 14, 30, 13, 29, 15, 31}), + "DEPTH_FIRST", + 2, + Tensor({1, 8, 2, 2}, IN_ET, std::vector{ + 0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9, 11, 17, 19, 25, 27, + 4, 6, 12, 14, 20, 22, 28, 30, 5, 7, 13, 15, 21, 23, 29, 31}), + "space_to_depth_depth_first_K2_BS2"), + + // space_to_depth_depth_first_K2_BS3 + SpaceToDepthParams( + Tensor({1, 2, 6, 3}, IN_ET, std::vector{ + 0, 2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, + 7, 9, 11, 13, 15, 17, 18, 20, 22, 24, 26, 28, + 30, 32, 34, 19, 21, 23, 25, 27, 29, 31, 33, 35}), + "DEPTH_FIRST", + 3, + Tensor({1, 18, 2, 1}, IN_ET, std::vector{ + 0, 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, 28, 29, 30, 31, 32, 33, 34, 35}), + "space_to_depth_depth_first_K2_BS3"), + + // space_to_depth_depth_first_K1_BS3 + SpaceToDepthParams( + Tensor({1, 2, 6}, IN_ET, std::vector{ + 0, 2, 4, 1, 3, 5, 6, 8, 10, 7, 9, 11}), + "DEPTH_FIRST", + 3, + Tensor({1, 6, 2}, IN_ET, std::vector{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}), + "space_to_depth_depth_first_K1_BS3"), + }; + return params; +} + +std::vector generateCombinedParams() { + const std::vector> generatedParams { + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + generateParams(), + }; + std::vector combinedParams; + + for (const auto& params : generatedParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_SpaceToDepth_With_Hardcoded_Refs, ReferenceSpaceToDepthLayerTest, + testing::ValuesIn(generateCombinedParams()), ReferenceSpaceToDepthLayerTest::getTestCaseName); +} // namespace \ No newline at end of file diff --git a/docs/template_plugin/tests/functional/skip_tests_config.cpp b/docs/template_plugin/tests/functional/skip_tests_config.cpp index b3b78f0263b..b393666f320 100644 --- a/docs/template_plugin/tests/functional/skip_tests_config.cpp +++ b/docs/template_plugin/tests/functional/skip_tests_config.cpp @@ -77,6 +77,15 @@ std::vector disabledTestPatterns() { R"(.*ReferencePadTest.*pad_exterior_2d_3x0)", // CVS-70975 R"(.*ReferencePadTestParamsTooLarge.*)", + // CVS-64006 + R"(.*ReferenceBatchToSpaceLayerTest.*dType=i4.*)", + R"(.*ReferenceBatchToSpaceLayerTest.*dType=u4.*)", + // CVS-64113 + R"(.*ReferenceRollLayerTest.*dType=i4.*)", + R"(.*ReferenceRollLayerTest.*dType=u4.*)", + // CVS-64050 + R"(.*ReferenceSpaceToBatchLayerTest.*dType=i4.*)", + R"(.*ReferenceSpaceToBatchLayerTest.*dType=u4.*)", }; #ifdef _WIN32 diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index edc3eaef038..8c30d765cbd 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -380,6 +380,7 @@ set(SRC visitors/op/rnn_cell.cpp visitors/op/rnn_sequence.cpp visitors/op/roi_pooling.cpp + visitors/op/roll.cpp visitors/op/round.cpp visitors/op/scatter_elements_update.cpp visitors/op/scatter_update.cpp @@ -478,13 +479,11 @@ set(MULTI_TEST_SRC backend/aliased_output.in.cpp backend/api.in.cpp backend/auto_broadcast.in.cpp - backend/batch_to_space.in.cpp backend/broadcast.in.cpp backend/builder_reduce_ops_opset1.in.cpp backend/concat.in.cpp backend/ctc_greedy_decoder.in.cpp backend/ctc_greedy_decoder_seq_len.in.cpp - backend/depth_to_space.in.cpp backend/dyn_reshape.in.cpp backend/experimental_detectron_topk_rois.in.cpp backend/dynamic.in.cpp @@ -500,10 +499,6 @@ set(MULTI_TEST_SRC backend/one_hot.in.cpp backend/recurrent_cells.in.cpp backend/region_yolo.in.cpp - backend/roll.in.cpp - backend/space_to_depth.in.cpp - backend/shuffle_channels.in.cpp - backend/space_to_batch.in.cpp backend/sqrt.in.cpp backend/tile.in.cpp backend/topk.in.cpp diff --git a/ngraph/test/backend/batch_to_space.in.cpp b/ngraph/test/backend/batch_to_space.in.cpp deleted file mode 100644 index dfa748fc153..00000000000 --- a/ngraph/test/backend/batch_to_space.in.cpp +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (C) 2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "engines_util/test_case.hpp" -#include "engines_util/test_engines.hpp" -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "util/ndarray.hpp" -#include "util/test_control.hpp" - -using namespace std; -using namespace ngraph; - -static string s_manifest = "${MANIFEST}"; -using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); - -namespace { -template -struct BatchToSpaceParams { - using Data = test::NDArrayBase; - using BlockShape = test::NDArrayBase; - using Crops = test::NDArrayBase; - - BatchToSpaceParams(Data in_data, BlockShape block_shape, Crops crops_begin, Crops crops_end, Data expected_output) - : m_data{std::move(in_data)}, - m_block_shape{std::move(block_shape)}, - m_crops_begin{std::move(crops_begin)}, - m_crops_end{std::move(crops_end)}, - m_expected_output{std::move(expected_output)} {} - - Data m_data; - BlockShape m_block_shape; - Crops m_crops_begin; - Crops m_crops_end; - Data m_expected_output; -}; - -template -static void BatchToSpaceTestExecute(const BatchToSpaceParams& params) { - const auto data = make_shared(element::from(), params.m_data.get_shape()); - - const auto block_shape = - op::Constant::create(element::i64, params.m_block_shape.get_shape(), params.m_block_shape.get_vector()); - - const auto crops_begin = - op::Constant::create(element::i64, params.m_crops_begin.get_shape(), params.m_crops_begin.get_vector()); - - const auto crops_end = - op::Constant::create(element::i64, params.m_crops_end.get_shape(), params.m_crops_end.get_vector()); - - const auto batch_to_space = make_shared(data, block_shape, crops_begin, crops_end); - - auto f = make_shared(batch_to_space, ParameterVector{data}); - auto test_case = test::TestCase(f); - test_case.add_input(params.m_data.get_vector()); - test_case.add_expected_output(params.m_expected_output.get_vector()); - test_case.run_with_tolerance_as_fp(1e-4f); -} - -class BatchToSpaceTestFloat : public testing::TestWithParam> {}; -} // namespace - -NGRAPH_TEST_P(${BACKEND_NAME}, BatchToSpaceTestFloat, BatchToSpaceTestFloatCases) { - BatchToSpaceTestExecute(GetParam()); -} - -const test::NDArray input_with_shape_4x3( - {{1.0f, 2.0f, 3.0f}, {4.0f, 5.0f, 6.0f}, {7.0f, 8.0f, 9.0f}, {10.0f, 11.0f, 12.0f}}); - -const test::NDArray zero_crops_2d({0, 0}); - -NGRAPH_INSTANTIATE_TEST_SUITE_P(${BACKEND_NAME}, - batch_to_space_2d_without_crops, - BatchToSpaceTestFloat, - testing::Values(BatchToSpaceParams{ - input_with_shape_4x3, - test::NDArray({1, 2}), - zero_crops_2d, - zero_crops_2d, - test::NDArray({{1.0f, 7.0f, 2.0f, 8.0f, 3.0f, 9.0f}, - {4.0f, 10.0f, 5.0f, 11.0f, 6.0f, 12.0f}})})); - -const test::NDArray input_with_shape_4x1x1x3( - {{{{1.0f, 2.0f, 3.0f}}}, {{{4.0f, 5.0f, 6.0f}}}, {{{7.0f, 8.0f, 9.0f}}}, {{{10.0f, 11.0f, 12.0f}}}}); - -const test::NDArray input_with_shape_4x1x2x3({{{{1.0f, 2.0f, 3.0f}, {4.0f, 5.0f, 6.0f}}}, - {{{7.0f, 8.0f, 9.0f}, {10.0f, 11.0f, 12.0f}}}, - {{{13.0f, 14.0f, 15.0f}, {16.0f, 17.0f, 18.0f}}}, - {{{19.0f, 20.0f, 21.0f}, {22.0f, 23.0f, 24.0f}}}}); - -const test::NDArray zero_crops_4d({0, 0, 0, 0}); - -NGRAPH_INSTANTIATE_TEST_SUITE_P( - ${BACKEND_NAME}, - batch_to_space_4d_without_crops, - BatchToSpaceTestFloat, - testing::Values( - BatchToSpaceParams{input_with_shape_4x1x1x3, - test::NDArray({1, 1, 1, 2}), - zero_crops_4d, - zero_crops_4d, - test::NDArray({{{{1.0f, 7.0f, 2.0f, 8.0f, 3.0f, 9.0f}}}, - {{{4.0f, 10.0f, 5.0f, 11.0f, 6.0f, 12.0f}}}})}, - BatchToSpaceParams{input_with_shape_4x1x1x3, - test::NDArray({1, 1, 2, 1}), - zero_crops_4d, - zero_crops_4d, - test::NDArray({{{{1.0f, 2.0f, 3.0f}, {7.0f, 8.0f, 9.0f}}}, - {{{4.0f, 5.0f, 6.0f}, {10.0f, 11.0f, 12.0f}}}})}, - BatchToSpaceParams{input_with_shape_4x1x1x3, - test::NDArray({1, 1, 2, 2}), - zero_crops_4d, - zero_crops_4d, - test::NDArray({{{{1.0f, 4.0f, 2.0f, 5.0f, 3.0f, 6.0f}, - {7.0f, 10.0f, 8.0f, 11.0f, 9.0f, 12.0f}}}})}, - BatchToSpaceParams{ - input_with_shape_4x1x2x3, - test::NDArray({1, 1, 1, 2}), - zero_crops_4d, - zero_crops_4d, - test::NDArray( - {{{{1.0f, 13.0f, 2.0f, 14.0f, 3.0f, 15.0f}, {4.0f, 16.0f, 5.0f, 17.0f, 6.0f, 18.0f}}}, - {{{7.0f, 19.0f, 8.0f, 20.0f, 9.0f, 21.0f}, {10.0f, 22.0f, 11.0f, 23.0f, 12.0f, 24.0f}}}})}, - BatchToSpaceParams{ - input_with_shape_4x1x2x3, - test::NDArray({1, 1, 2, 1}), - zero_crops_4d, - zero_crops_4d, - test::NDArray( - {{{{1.0f, 2.0f, 3.0f}, {13.0f, 14.0f, 15.0f}, {4.0f, 5.0f, 6.0f}, {16.0f, 17.0f, 18.0f}}}, - {{{7.0f, 8.0f, 9.0f}, {19.0f, 20.0f, 21.0f}, {10.0f, 11.0f, 12.0f}, {22.0f, 23.0f, 24.0f}}}})}, - BatchToSpaceParams{input_with_shape_4x1x2x3, - test::NDArray({1, 1, 2, 2}), - zero_crops_4d, - zero_crops_4d, - test::NDArray({{{{1.0f, 7.0f, 2.0f, 8.0f, 3.0f, 9.0f}, - {13.0f, 19.0f, 14.0f, 20.0f, 15.0f, 21.0f}, - {4.0f, 10.0f, 5.0f, 11.0f, 6.0f, 12.0f}, - {16.0f, 22.0f, 17.0f, 23.0f, 18.0f, 24.0f}}}})})); - -NGRAPH_INSTANTIATE_TEST_SUITE_P( - ${BACKEND_NAME}, - batch_to_space_4d_crops, - BatchToSpaceTestFloat, - testing::Values(BatchToSpaceParams{input_with_shape_4x1x2x3, - test::NDArray({1, 1, 2, 2}), - test::NDArray({0, 0, 0, 0}), - test::NDArray({0, 0, 0, 2}), - test::NDArray({{{{1.0f, 7.0f, 2.0f, 8.0f}, - {13.0f, 19.0f, 14.0f, 20.0f}, - {4.0f, 10.0f, 5.0f, 11.0f}, - {16.0f, 22.0f, 17.0f, 23.0f}}}})}, - BatchToSpaceParams{input_with_shape_4x1x2x3, - test::NDArray({1, 1, 2, 2}), - test::NDArray({0, 0, 0, 2}), - test::NDArray({0, 0, 0, 0}), - test::NDArray({{{{2.0f, 8.0f, 3.0f, 9.0f}, - {14.0f, 20.0f, 15.0f, 21.0f}, - {5.0f, 11.0f, 6.0f, 12.0f}, - {17.0f, 23.0f, 18.0f, 24.0f}}}})}, - BatchToSpaceParams{input_with_shape_4x1x2x3, - test::NDArray({1, 1, 2, 2}), - test::NDArray({0, 0, 1, 0}), - test::NDArray({0, 0, 1, 0}), - test::NDArray({{{{13.0f, 19.0f, 14.0f, 20.0f, 15.0f, 21.0f}, - {4.0f, 10.0f, 5.0f, 11.0f, 6.0f, 12.0f}}}})})); diff --git a/ngraph/test/backend/depth_to_space.in.cpp b/ngraph/test/backend/depth_to_space.in.cpp deleted file mode 100644 index 85053d3b6e9..00000000000 --- a/ngraph/test/backend/depth_to_space.in.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "engines_util/test_case.hpp" -#include "engines_util/test_engines.hpp" -#include "gtest/gtest.h" -#include "ngraph/op/depth_to_space.hpp" -#include "util/test_control.hpp" - -using namespace ngraph; - -static std::string s_manifest = "${MANIFEST}"; - -using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); - -NGRAPH_TEST(${BACKEND_NAME}, depth_to_space_block_first_K1_BS2) { - auto A = std::make_shared(element::f32, Shape{1, 8, 2}); - auto depth_to_space = std::make_shared(A, op::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST, 2); - auto function = std::make_shared(NodeVector{depth_to_space}, ParameterVector{A}); - - auto test_case = test::TestCase(function); - test_case.add_input( - {0.f, 2.f, 8.f, 10.f, 16.f, 18.f, 24.f, 26.f, 1.f, 3.f, 9.f, 11.f, 17.f, 19.f, 25.f, 27.f}); - test_case.add_expected_output( - Shape{1, 4, 4}, - {0.f, 1.f, 2.f, 3.f, 8.f, 9.f, 10.f, 11.f, 16.f, 17.f, 18.f, 19.f, 24.f, 25.f, 26.f, 27.f}); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, depth_to_space_block_first_K2_BS2) { - auto A = std::make_shared(element::f32, Shape{1, 8, 2, 2}); - auto depth_to_space = std::make_shared(A, op::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST, 2); - auto function = std::make_shared(NodeVector{depth_to_space}, ParameterVector{A}); - - auto test_case = test::TestCase(function); - test_case.add_input({0.f, 2.f, 8.f, 10.f, 16.f, 18.f, 24.f, 26.f, 1.f, 3.f, 9.f, - 11.f, 17.f, 19.f, 25.f, 27.f, 4.f, 6.f, 12.f, 14.f, 20.f, 22.f, - 28.f, 30.f, 5.f, 7.f, 13.f, 15.f, 21.f, 23.f, 29.f, 31.f}); - test_case.add_expected_output( - Shape{1, 2, 4, 4}, - {0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, - 16.f, 17.f, 18.f, 19.f, 20.f, 21.f, 22.f, 23.f, 24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.f}); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, depth_to_space_block_first_K2_BS4) { - auto A = std::make_shared(element::f32, Shape{1, 16, 2, 1}); - auto depth_to_space = std::make_shared(A, op::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST, 4); - auto function = std::make_shared(NodeVector{depth_to_space}, ParameterVector{A}); - - auto test_case = test::TestCase(function); - test_case.add_input({0.f, 16.f, 1.f, 17.f, 2.f, 18.f, 3.f, 19.f, 4.f, 20.f, 5.f, - 21.f, 6.f, 22.f, 7.f, 23.f, 8.f, 24.f, 9.f, 25.f, 10.f, 26.f, - 11.f, 27.f, 12.f, 28.f, 13.f, 29.f, 14.f, 30.f, 15.f, 31.f}); - test_case.add_expected_output( - Shape{1, 1, 8, 4}, - {0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, - 16.f, 17.f, 18.f, 19.f, 20.f, 21.f, 22.f, 23.f, 24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.f}); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, depth_to_space_depth_first_1K_BS2) { - auto A = std::make_shared(element::f32, Shape{1, 8, 2}); - auto depth_to_space = std::make_shared(A, op::DepthToSpace::DepthToSpaceMode::DEPTH_FIRST, 2); - auto function = std::make_shared(NodeVector{depth_to_space}, ParameterVector{A}); - - auto test_case = test::TestCase(function); - test_case.add_input({0.f, 2.f, 1.f, 3.f, 4.f, 6.f, 5.f, 7.f, 8.f, 10.f, 9.f, 11.f, 12.f, 14.f, 13.f, 15.f}); - test_case.add_expected_output( - Shape{1, 4, 4}, - {0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f}); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, depth_to_space_depth_first_2K_BS2) { - auto A = std::make_shared(element::f32, Shape{1, 8, 2, 2}); - auto depth_to_space = std::make_shared(A, op::DepthToSpace::DepthToSpaceMode::DEPTH_FIRST, 2); - auto function = std::make_shared(NodeVector{depth_to_space}, ParameterVector{A}); - - auto test_case = test::TestCase(function); - test_case.add_input({0.f, 2.f, 8.f, 10.f, 16.f, 18.f, 24.f, 26.f, 1.f, 3.f, 9.f, - 11.f, 17.f, 19.f, 25.f, 27.f, 4.f, 6.f, 12.f, 14.f, 20.f, 22.f, - 28.f, 30.f, 5.f, 7.f, 13.f, 15.f, 21.f, 23.f, 29.f, 31.f}); - test_case.add_expected_output( - Shape{1, 2, 4, 4}, - {0.f, 16.f, 2.f, 18.f, 1.f, 17.f, 3.f, 19.f, 8.f, 24.f, 10.f, 26.f, 9.f, 25.f, 11.f, 27.f, - 4.f, 20.f, 6.f, 22.f, 5.f, 21.f, 7.f, 23.f, 12.f, 28.f, 14.f, 30.f, 13.f, 29.f, 15.f, 31.f}); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, depth_to_space_depth_first_2K_BS4) { - auto A = std::make_shared(element::f32, Shape{1, 16, 2, 1}); - auto depth_to_space = std::make_shared(A, op::DepthToSpace::DepthToSpaceMode::DEPTH_FIRST, 4); - auto function = std::make_shared(NodeVector{depth_to_space}, ParameterVector{A}); - - auto test_case = test::TestCase(function); - test_case.add_input({0.f, 16.f, 1.f, 17.f, 2.f, 18.f, 3.f, 19.f, 4.f, 20.f, 5.f, - 21.f, 6.f, 22.f, 7.f, 23.f, 8.f, 24.f, 9.f, 25.f, 10.f, 26.f, - 11.f, 27.f, 12.f, 28.f, 13.f, 29.f, 14.f, 30.f, 15.f, 31.f}); - test_case.add_expected_output( - Shape{1, 1, 8, 4}, - {0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, - 16.f, 17.f, 18.f, 19.f, 20.f, 21.f, 22.f, 23.f, 24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.f}); - test_case.run(); -} diff --git a/ngraph/test/backend/roll.in.cpp b/ngraph/test/backend/roll.in.cpp deleted file mode 100644 index 1024e591c13..00000000000 --- a/ngraph/test/backend/roll.in.cpp +++ /dev/null @@ -1,197 +0,0 @@ -//***************************************************************************** -// Copyright 2017-2021 Intel Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -//***************************************************************************** - -#include "engines_util/execute_tools.hpp" -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "ngraph/opsets/opset7.hpp" -#include "ngraph/runtime/tensor.hpp" -#include "ngraph/shape.hpp" -#include "runtime/backend.hpp" -#include "util/all_close.hpp" -#include "util/all_close_f.hpp" -#include "util/test_control.hpp" - -using namespace std; -using namespace ngraph; - -static string s_manifest = "${MANIFEST}"; - -NGRAPH_TEST(${BACKEND_NAME}, roll_2d_input) { - Shape shape{4, 3}; - auto x = make_shared(element::f32, shape); - auto shift = make_shared(element::i64, Shape{1}, vector{1}); - auto axes = make_shared(element::i64, Shape{1}, vector{0}); - auto f = make_shared(make_shared(x, shift, axes), ParameterVector{x}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - auto x_tensor = backend->create_tensor(element::f32, shape); - copy_data(x_tensor, - vector{50.2907, - 70.8054, - -68.3403, - 62.6444, - 4.9748, - -18.5551, - 40.5383, - -15.3859, - -4.5881, - -43.3479, - 94.1676, - -95.7097}); - auto result = backend->create_tensor(element::f32, shape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {x_tensor}); - EXPECT_TRUE(test::all_close_f((vector{-43.3479, - 94.1676, - -95.7097, - 50.2907, - 70.8054, - -68.3403, - 62.6444, - 4.9748, - -18.5551, - 40.5383, - -15.3859, - -4.5881}), - read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, roll_2d_input_negative_shift) { - Shape shape{4, 3}; - auto x = make_shared(element::f32, shape); - auto shift = make_shared(element::i32, Shape{2}, vector{-1, 2}); - auto axes = make_shared(element::i32, Shape{2}, vector{0, 1}); - auto f = make_shared(make_shared(x, shift, axes), ParameterVector{x}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - auto x_tensor = backend->create_tensor(element::f32, shape); - copy_data(x_tensor, - vector{50.2907, - 70.8054, - -68.3403, - 62.6444, - 4.9748, - -18.5551, - 40.5383, - -15.3859, - -4.5881, - -43.3479, - 94.1676, - -95.7097}); - auto result = backend->create_tensor(element::f32, shape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {x_tensor}); - EXPECT_TRUE(test::all_close_f((vector{4.9748, - -18.5551, - 62.6444, - -15.3859, - -4.5881, - 40.5383, - 94.1676, - -95.7097, - -43.3479, - 70.8054, - -68.3403, - 50.2907}), - read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, roll_repeated_axes) { - Shape shape{4, 3}; - auto x = make_shared(element::i64, shape); - auto shift = make_shared(element::i64, Shape{3}, vector{1, 2, 1}); - auto axes = make_shared(element::i64, Shape{3}, vector{0, 1, 0}); - auto f = make_shared(make_shared(x, shift, axes), ParameterVector{x}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - auto x_tensor = backend->create_tensor(element::i64, shape); - copy_data(x_tensor, vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}); - auto result = backend->create_tensor(element::i64, shape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {x_tensor}); - EXPECT_TRUE( - test::all_close((vector{8, 9, 7, 11, 12, 10, 2, 3, 1, 5, 6, 4}), read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, roll_3d_input) { - Shape shape{4, 2, 3}; - auto x = make_shared(element::f32, shape); - auto shift = make_shared(element::i64, Shape{3}, vector{2, 1, 3}); - auto axes = make_shared(element::i64, Shape{3}, vector{0, 1, 2}); - auto f = make_shared(make_shared(x, shift, axes), ParameterVector{x}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto x_tensor = backend->create_tensor(element::f32, shape); - copy_data(x_tensor, vector{94.0773, 33.0599, 58.1724, -20.3640, 54.5372, -54.3023, 10.4662, 11.7532, - -11.7692, 56.4223, -95.3774, 8.8978, 1.9305, 13.8025, 12.0827, 81.4669, - 19.5321, -8.9553, -75.3226, 20.8033, 20.7660, 62.7361, 14.9372, -33.0825}); - auto result = backend->create_tensor(element::f32, shape); - auto handle = backend->compile(f); - handle->call_with_validate({result}, {x_tensor}); - EXPECT_TRUE( - test::all_close_f((vector{81.4669, 19.5321, -8.9553, 1.9305, 13.8025, 12.0827, 62.7361, 14.9372, - -33.0825, -75.3226, 20.8033, 20.7660, -20.3640, 54.5372, -54.3023, 94.0773, - 33.0599, 58.1724, 56.4223, -95.3774, 8.8978, 10.4662, 11.7532, -11.7692}), - read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, roll_3d_input_negative_shift) { - Shape shape{4, 2, 3}; - auto x = make_shared(element::f32, shape); - auto shift = make_shared(element::i32, Shape{3}, vector{-5, 1, 3}); - auto axes = make_shared(element::i64, Shape{3}, vector{0, 1, 1}); - auto f = make_shared(make_shared(x, shift, axes), ParameterVector{x}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto x_tensor = backend->create_tensor(element::f32, shape); - copy_data(x_tensor, vector{94.0773, 33.0599, 58.1724, -20.3640, 54.5372, -54.3023, 10.4662, 11.7532, - -11.7692, 56.4223, -95.3774, 8.8978, 1.9305, 13.8025, 12.0827, 81.4669, - 19.5321, -8.9553, -75.3226, 20.8033, 20.7660, 62.7361, 14.9372, -33.0825}); - auto result = backend->create_tensor(element::f32, shape); - auto handle = backend->compile(f); - handle->call_with_validate({result}, {x_tensor}); - EXPECT_TRUE( - test::all_close_f((vector{10.4662, 11.7532, -11.7692, 56.4223, -95.3774, 8.8978, 1.9305, 13.8025, - 12.0827, 81.4669, 19.5321, -8.9553, -75.3226, 20.8033, 20.7660, 62.7361, - 14.9372, -33.0825, 94.0773, 33.0599, 58.1724, -20.3640, 54.5372, -54.3023}), - read_vector(result))); -} - -NGRAPH_TEST(${BACKEND_NAME}, roll_negative_axes) { - Shape shape{4, 2, 3}; - auto x = make_shared(element::i32, shape); - auto shift = make_shared(element::i64, Shape{3}, vector{2, -1, -7}); - auto axes = make_shared(element::i32, Shape{3}, vector{-1, -1, -2}); - auto f = make_shared(make_shared(x, shift, axes), ParameterVector{x}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto x_tensor = backend->create_tensor(element::i32, shape); - copy_data(x_tensor, - vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}); - auto result = backend->create_tensor(element::i32, shape); - auto handle = backend->compile(f); - handle->call_with_validate({result}, {x_tensor}); - EXPECT_TRUE(test::all_close( - (vector{6, 4, 5, 3, 1, 2, 12, 10, 11, 9, 7, 8, 18, 16, 17, 15, 13, 14, 24, 22, 23, 21, 19, 20}), - read_vector(result))); -} diff --git a/ngraph/test/backend/shuffle_channels.in.cpp b/ngraph/test/backend/shuffle_channels.in.cpp deleted file mode 100644 index 7b1296b3cef..00000000000 --- a/ngraph/test/backend/shuffle_channels.in.cpp +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (C) 2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "engines_util/execute_tools.hpp" -#include "engines_util/test_case.hpp" -#include "engines_util/test_engines.hpp" -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "runtime/backend.hpp" -#include "util/all_close.hpp" -#include "util/all_close_f.hpp" -#include "util/test_control.hpp" - -using namespace std; -using namespace ngraph; - -static string s_manifest = "${MANIFEST}"; -using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); - -NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_simple) { - const auto data = make_shared(element::i32, Shape{1, 15, 2, 2}); - auto tested_op = make_shared(data, 1, 5); - auto function = make_shared(tested_op, ParameterVector{data}); - auto test_case = test::TestCase(function); - - std::vector input_data(60); - std::iota(std::begin(input_data), std::end(input_data), 0); - test_case.add_input(input_data); - - test_case.add_expected_output( - Shape{1, 15, 2, 2}, - {0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, - 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, - 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}); - - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_negative_axis) { - // In this test the output is the same as in shuffle_channels_simple but - // the axis value is negative and the C(channels) value is in a different dimension(0) of the - // shape - const auto data = make_shared(element::i32, Shape{15, 2, 1, 2}); - auto tested_op = make_shared(data, -4, 5); - auto function = make_shared(tested_op, ParameterVector{data}); - - auto test_case = test::TestCase(function); - - std::vector input_data(60); - std::iota(std::begin(input_data), std::end(input_data), 0); - test_case.add_input(input_data); - - test_case.add_expected_output( - Shape{15, 2, 1, 2}, - {0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, - 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, - 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}); - - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_float) { - const auto data = make_shared(element::f32, Shape{6, 1, 1, 1}); - auto tested_op = make_shared(data, 0, 2); - auto function = make_shared(tested_op, ParameterVector{data}); - - auto test_case = test::TestCase(function); - - test_case.add_input({0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}); - test_case.add_expected_output(Shape{6, 1, 1, 1}, {0.0f, 3.0f, 1.0f, 4.0f, 2.0f, 5.0f}); - - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_1d) { - Shape data_shape{15}; - const auto data = make_shared(element::i32, data_shape); - auto tested_op = make_shared(data, 0, 5); - auto function = make_shared(tested_op, ParameterVector{data}); - auto test_case = test::TestCase(function); - - std::vector input_data{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; - - test_case.add_input(input_data); - test_case.add_expected_output(data_shape, {0, 3, 6, 9, 12, 1, 4, 7, 10, 13, 2, 5, 8, 11, 14}); - - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_2d) { - Shape data_shape{15, 4}; - const auto data = make_shared(element::i32, data_shape); - auto tested_op = make_shared(data, 0, 5); - auto function = make_shared(tested_op, ParameterVector{data}); - auto test_case = test::TestCase(function); - - std::vector input_data{0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}; - - test_case.add_input(input_data); - test_case.add_expected_output(data_shape, {0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, - 39, 48, 49, 50, 51, 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, - 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, 8, 9, 10, 11, 20, - 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}); - - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_3d) { - Shape data_shape{15, 2, 2}; - const auto data = make_shared(element::i32, data_shape); - auto tested_op = make_shared(data, 0, 5); - auto function = make_shared(tested_op, ParameterVector{data}); - auto test_case = test::TestCase(function); - - std::vector input_data{0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}; - - test_case.add_input(input_data); - test_case.add_expected_output(data_shape, {0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, - 39, 48, 49, 50, 51, 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, - 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, 8, 9, 10, 11, 20, - 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}); - - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, shuffle_channels_5d) { - Shape data_shape{2, 2, 15, 2, 2}; - const auto data = make_shared(element::i32, data_shape); - auto tested_op = make_shared(data, 2, 5); - auto function = make_shared(tested_op, ParameterVector{data}); - auto test_case = test::TestCase(function); - - std::vector input_data{0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - - 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - - 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - - 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}; - - test_case.add_input(input_data); - test_case.add_expected_output( - data_shape, - {0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, - 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, - 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59, - - 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, - 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, - 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59, - - 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, - 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, - 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59, - - 0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51, - 4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55, - 8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}); - - test_case.run(); -} diff --git a/ngraph/test/backend/space_to_batch.in.cpp b/ngraph/test/backend/space_to_batch.in.cpp deleted file mode 100644 index d168be4bfca..00000000000 --- a/ngraph/test/backend/space_to_batch.in.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (C) 2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "engines_util/test_case.hpp" -#include "engines_util/test_engines.hpp" -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "util/test_control.hpp" - -using namespace std; -using namespace ngraph; - -static string s_manifest = "${MANIFEST}"; -using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); - -static void SpaceToBatchTest(const std::vector& inputs, - const Shape inputs_shape, - const std::vector& block_shapes, - const Shape blocks_shape, - const std::vector& pads_begins, - const std::vector& pads_ends, - const Shape pads_shape, - const std::vector& outputs, - const Shape outputs_shape) { - auto inputs_param = make_shared(element::f32, inputs_shape); - auto block_shapes_param = make_shared(element::i64, blocks_shape, block_shapes); - auto pads_begins_param = make_shared(element::i64, pads_shape, pads_begins); - auto pads_ends_param = make_shared(element::i64, pads_shape, pads_ends); - - auto space_to_batch = - make_shared(inputs_param, block_shapes_param, pads_begins_param, pads_ends_param); - auto f = make_shared(space_to_batch, ParameterVector{inputs_param}); - - auto test_case = test::TestCase(f); - test_case.add_input(inputs); - test_case.add_expected_output(outputs_shape, outputs); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, space_to_batch_4D) { - const Shape inputs_shape{1, 1, 2, 2}; - const std::vector inputs{1.0f, 1.0f, 1.0f, 1.0f}; - - const Shape blocks_shape{4}; - const std::vector block_shapes{1, 1, 1, 1}; - - const Shape pads_shape{4}; - const std::vector pads_begins{0, 0, 0, 0}; - const std::vector pads_ends{0, 0, 0, 0}; - - const Shape outputs_shape{1, 1, 2, 2}; - const std::vector outputs{1.0f, 1.0f, 1.0f, 1.0f}; - - SpaceToBatchTest(inputs, - inputs_shape, - block_shapes, - blocks_shape, - pads_begins, - pads_ends, - pads_shape, - outputs, - outputs_shape); -} - -NGRAPH_TEST(${BACKEND_NAME}, space_to_batch_5D) { - const Shape inputs_shape{1, 1, 3, 2, 1}; - const std::vector inputs{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}; - - const Shape blocks_shape{5}; - const std::vector block_shapes{1, 1, 3, 2, 2}; - - const Shape pads_shape{5}; - const std::vector pads_begins{0, 0, 1, 0, 3}; - const std::vector pads_ends{0, 0, 2, 0, 0}; - - const Shape outputs_shape{12, 1, 2, 1, 2}; - const std::vector outputs{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f}; - - SpaceToBatchTest(inputs, - inputs_shape, - block_shapes, - blocks_shape, - pads_begins, - pads_ends, - pads_shape, - outputs, - outputs_shape); -} - -NGRAPH_TEST(${BACKEND_NAME}, space_to_batch_4x4) { - const Shape inputs_shape{1, 1, 4, 4}; - const std::vector - inputs{1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; - - const Shape blocks_shape{4}; - const std::vector block_shapes{1, 1, 1, 1}; - - const Shape pads_shape{4}; - const std::vector pads_begins{0, 0, 1, 0}; - const std::vector pads_ends{0, 0, 0, 0}; - - const Shape outputs_shape{1, 1, 5, 4}; - const std::vector outputs{0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; - - SpaceToBatchTest(inputs, - inputs_shape, - block_shapes, - blocks_shape, - pads_begins, - pads_ends, - pads_shape, - outputs, - outputs_shape); -} diff --git a/ngraph/test/backend/space_to_depth.in.cpp b/ngraph/test/backend/space_to_depth.in.cpp deleted file mode 100644 index d3467a5d9a3..00000000000 --- a/ngraph/test/backend/space_to_depth.in.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "engines_util/test_case.hpp" -#include "engines_util/test_engines.hpp" -#include "gtest/gtest.h" -#include "ngraph/op/space_to_depth.hpp" -#include "util/test_control.hpp" - -using namespace ngraph; - -static std::string s_manifest = "${MANIFEST}"; - -using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); - -NGRAPH_TEST(${BACKEND_NAME}, space_to_depth_block_first_K2_BS2) { - auto A = std::make_shared(element::f32, Shape{1, 2, 4, 4}); - const auto mode = op::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST; - auto space_to_depth = std::make_shared(A, mode, 2); - auto function = std::make_shared(NodeVector{space_to_depth}, ParameterVector{A}); - - auto test_case = test::TestCase(function); - test_case.add_input({0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, - 11.f, 12.f, 13.f, 14.f, 15.f, 16.f, 17.f, 18.f, 19.f, 20.f, 21.f, - 22.f, 23.f, 24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.f}); - test_case.add_expected_output( - Shape{1, 8, 2, 2}, - {0.f, 2.f, 8.f, 10.f, 16.f, 18.f, 24.f, 26.f, 1.f, 3.f, 9.f, 11.f, 17.f, 19.f, 25.f, 27.f, - 4.f, 6.f, 12.f, 14.f, 20.f, 22.f, 28.f, 30.f, 5.f, 7.f, 13.f, 15.f, 21.f, 23.f, 29.f, 31.f}); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, space_to_depth_block_first_K2_BS3) { - auto A = std::make_shared(element::f32, Shape{1, 2, 6, 3}); - const auto mode = op::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST; - auto space_to_depth = std::make_shared(A, mode, 3); - auto function = std::make_shared(NodeVector{space_to_depth}, ParameterVector{A}); - - auto test_case = test::TestCase(function); - test_case.add_input({0.f, 4.f, 8.f, 12.f, 16.f, 20.f, 24.f, 28.f, 32.f, 1.f, 5.f, 9.f, - 13.f, 17.f, 21.f, 25.f, 29.f, 33.f, 2.f, 6.f, 10.f, 14.f, 18.f, 22.f, - 26.f, 30.f, 34.f, 3.f, 7.f, 11.f, 15.f, 19.f, 23.f, 27.f, 31.f, 35.f}); - test_case.add_expected_output( - Shape{1, 18, 2, 1}, - {0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, 16.f, 17.f, - 18.f, 19.f, 20.f, 21.f, 22.f, 23.f, 24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.f, 32.f, 33.f, 34.f, 35.f}); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, space_to_depth_block_first_K1_BS3) { - auto A = std::make_shared(element::f32, Shape{1, 2, 6}); - const auto mode = op::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST; - auto space_to_depth = std::make_shared(A, mode, 3); - auto function = std::make_shared(NodeVector{space_to_depth}, ParameterVector{A}); - - auto test_case = test::TestCase(function); - test_case.add_input({0.f, 4.f, 8.f, 1.f, 5.f, 9.f, 2.f, 6.f, 10.f, 3.f, 7.f, 11.f}); - test_case.add_expected_output(Shape{1, 6, 2}, - {0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f}); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, space_to_depth_depth_first_K2_BS2) { - auto A = std::make_shared(element::f32, Shape{1, 2, 4, 4}); - const auto mode = op::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST; - auto space_to_depth = std::make_shared(A, mode, 2); - auto function = std::make_shared(NodeVector{space_to_depth}, ParameterVector{A}); - - auto test_case = test::TestCase(function); - test_case.add_input({0.f, 16.f, 2.f, 18.f, 1.f, 17.f, 3.f, 19.f, 8.f, 24.f, 10.f, - 26.f, 9.f, 25.f, 11.f, 27.f, 4.f, 20.f, 6.f, 22.f, 5.f, 21.f, - 7.f, 23.f, 12.f, 28.f, 14.f, 30.f, 13.f, 29.f, 15.f, 31.f}); - test_case.add_expected_output( - Shape{1, 8, 2, 2}, - {0.f, 2.f, 8.f, 10.f, 16.f, 18.f, 24.f, 26.f, 1.f, 3.f, 9.f, 11.f, 17.f, 19.f, 25.f, 27.f, - 4.f, 6.f, 12.f, 14.f, 20.f, 22.f, 28.f, 30.f, 5.f, 7.f, 13.f, 15.f, 21.f, 23.f, 29.f, 31.f}); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, space_to_depth_depth_first_K2_BS3) { - auto A = std::make_shared(element::f32, Shape{1, 2, 6, 3}); - const auto mode = op::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST; - auto space_to_depth = std::make_shared(A, mode, 3); - auto function = std::make_shared(NodeVector{space_to_depth}, ParameterVector{A}); - - auto test_case = test::TestCase(function); - test_case.add_input({0.f, 2.f, 4.f, 6.f, 8.f, 10.f, 12.f, 14.f, 16.f, 1.f, 3.f, 5.f, - 7.f, 9.f, 11.f, 13.f, 15.f, 17.f, 18.f, 20.f, 22.f, 24.f, 26.f, 28.f, - 30.f, 32.f, 34.f, 19.f, 21.f, 23.f, 25.f, 27.f, 29.f, 31.f, 33.f, 35.f}); - test_case.add_expected_output( - Shape{1, 18, 2, 1}, - {0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, 16.f, 17.f, - 18.f, 19.f, 20.f, 21.f, 22.f, 23.f, 24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.f, 32.f, 33.f, 34.f, 35.f}); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, space_to_depth_depth_first_K1_BS3) { - auto A = std::make_shared(element::f32, Shape{1, 2, 6}); - const auto mode = op::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST; - auto space_to_depth = std::make_shared(A, mode, 3); - auto function = std::make_shared(NodeVector{space_to_depth}, ParameterVector{A}); - - auto test_case = test::TestCase(function); - test_case.add_input({0.f, 2.f, 4.f, 1.f, 3.f, 5.f, 6.f, 8.f, 10.f, 7.f, 9.f, 11.f}); - test_case.add_expected_output(Shape{1, 6, 2}, - {0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f}); - test_case.run(); -} diff --git a/ngraph/test/visitors/op/roll.cpp b/ngraph/test/visitors/op/roll.cpp new file mode 100644 index 00000000000..af2a043bbd9 --- /dev/null +++ b/ngraph/test/visitors/op/roll.cpp @@ -0,0 +1,26 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset7.hpp" +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; + +TEST(attributes, roll_op) { + NodeBuilder::get_ops().register_factory(); + const auto A = make_shared(element::f32, Shape{4, 3}); + const auto B = make_shared(element::i32, Shape{3}); + const auto C = make_shared(element::i32, Shape{3}); + + const auto roll = make_shared(A, B, C); + NodeBuilder builder(roll); + + const auto expected_attr_count = 0; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); +}