From 34fce43ab0f4bb6648c095cb17cf513bcbe9c771 Mon Sep 17 00:00:00 2001 From: Wilson Seok Date: Fri, 15 Oct 2021 01:39:04 -0700 Subject: [PATCH] Migrate ngraph backend test/convolution backprop (#7997) * Remove fp16 of Convert layer test from skip_tests.config.cpp as it works now * update repo * add draft reference of binary convolution * build test * fix build error * add binary_convolution reference test and ngraph visitor api test * remove ngraph backend test of binary_convolution * add reference test and remove ngraph backend test of convolution_backprop * add f64 case for convolution_backprop --- .../op_reference/binary_convolution.cpp | 316 +++ .../op_reference/convolution_backprop.cpp | 1776 +++++++++++++++++ ngraph/test/CMakeLists.txt | 3 +- ngraph/test/backend/binary_convolution.in.cpp | 646 ------ .../test/backend/convolution_backprop.in.cpp | 1219 ----------- .../test/visitors/op/binary_convolution.cpp | 57 + 6 files changed, 2150 insertions(+), 1867 deletions(-) create mode 100644 docs/template_plugin/tests/functional/op_reference/binary_convolution.cpp create mode 100644 docs/template_plugin/tests/functional/op_reference/convolution_backprop.cpp delete mode 100644 ngraph/test/backend/binary_convolution.in.cpp delete mode 100644 ngraph/test/backend/convolution_backprop.in.cpp create mode 100644 ngraph/test/visitors/op/binary_convolution.cpp diff --git a/docs/template_plugin/tests/functional/op_reference/binary_convolution.cpp b/docs/template_plugin/tests/functional/op_reference/binary_convolution.cpp new file mode 100644 index 00000000000..1a9a8e3ad68 --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/binary_convolution.cpp @@ -0,0 +1,316 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include "openvino/op/binary_convolution.hpp" +#include "base_reference_test.hpp" +#include "openvino/opsets/opset8.hpp" + +using namespace reference_tests; +using namespace ov; + +namespace { +struct BinaryConvolutionParams { + template + BinaryConvolutionParams(const PartialShape& inputShape, + const Shape& filterShape, + const PartialShape& outputShape, + const element::Type& iType, + const std::vector& iValues, + const std::vector& filterValues, + const std::vector& oValues, + const Strides& strides, + const CoordinateDiff& padBegin, + const CoordinateDiff& padEnd, + const Strides& dialations, + const float padValue = 0, + const std::string& test_name = "") + : inputShape(inputShape), + filterShape(filterShape), + outputShape(outputShape), + inType(iType), + outType(iType), + inputData(CreateTensor(iType, iValues)), + filterData(filterValues), + refData(CreateTensor(iType, oValues)), + strides(strides), + padBegin(padBegin), + padEnd(padEnd), + dialations(dialations), + padValue(padValue) {} + + PartialShape inputShape; + Shape filterShape; + PartialShape outputShape; + ov::element::Type inType; + ov::element::Type outType; + ov::runtime::Tensor inputData; + std::vector filterData; + ov::runtime::Tensor refData; + ov::Strides strides; + ov::CoordinateDiff padBegin; + ov::CoordinateDiff padEnd; + ov::Strides dialations; + ov::op::v1::BinaryConvolution::BinaryConvolutionMode mode = ov::op::v1::BinaryConvolution::BinaryConvolutionMode::XNOR_POPCOUNT; + float padValue; + std::string testcaseName; +}; + +class ReferenceBinaryConvolutionLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params, params.filterData); + inputData = {params.inputData}; + refOutData = {params.refData}; + } + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "inputShape=" << param.inputShape << "_"; + result << "filterShape=" << param.filterShape << "_"; + result << "outputShape=" << param.outputShape << "_"; + result << "iType=" << param.inType << "_"; + result << "oType=" << param.outType << "_"; + result << "strides=" << param.strides << "_"; + result << "padBegin=" << param.padBegin << "_"; + result << "padEnd=" << param.padEnd << "_"; + result << "dialations=" << param.dialations << "_"; + if (param.testcaseName != "") { + result << "padValue=" << param.padValue << "_"; + result << param.testcaseName; + } else { + result << "padValue=" << param.padValue; + } + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(const BinaryConvolutionParams& params, const std::vector& filterData) { + const op::PadType auto_pad{op::PadType::EXPLICIT}; + const auto in = std::make_shared(params.inType, params.inputShape); + auto filter = std::make_shared(ov::element::u1, params.filterShape, &filterData[0]); + const auto BinaryConvolution = std::make_shared(in, + filter, + params.strides, + params.padBegin, + params.padEnd, + params.dialations, + params.mode, + params.padValue, + auto_pad); + return std::make_shared(NodeVector {BinaryConvolution}, ParameterVector {in}); + } +}; + +TEST_P(ReferenceBinaryConvolutionLayerTest, CompareWithRefs) { + Exec(); +} + +template +std::vector generateBinaryConvolutionParams() { + using T = typename element_type_traits::value_type; + + std::vector binaryConvolutionParams { +// --------------------- 2D BinaryConvolution ------------------------------------------ + BinaryConvolutionParams(PartialShape {1, 1, 4, 4}, + Shape {1, 1, 3, 3}, + PartialShape {1, 1, 2, 2}, + IN_ET, + std::vector{1, 0, 0, 1, + 1, 1, 0, 0, + 0, 0, 0, 1, + 1, 0, 1, 1}, + std::vector{0xAA, 0x80}, // 10101010 10000000 + std::vector{1, 1, + 3, -1}, + {1, 1}, + {0, 0}, + {0, 0}, + {1, 1}), + BinaryConvolutionParams(PartialShape {1, 1, 4, 4}, + Shape {1, 1, 3, 3}, + PartialShape {1, 1, 4, 4}, + IN_ET, + std::vector{1, 0, 0, 1, + 1, 1, 0, 0, + 0, 0, 0, 1, + 1, 0, 1, 1}, + std::vector{0xAA, 0x80}, // 10101010 10000000 + std::vector{1, -3, -1, 1, + -3, 1, 1, -5, + -3, 3, -1, 1, + 1, -5, 1, -3}, + {1, 1}, + {1, 1}, + {1, 1}, + {1, 1}), + BinaryConvolutionParams(PartialShape {1, 1, 4, 4}, + Shape {1, 1, 3, 3}, + PartialShape {1, 1, 4, 4}, + IN_ET, + std::vector{1, 0, 0, 1, + 1, 1, 0, 0, + 0, 0, 0, 1, + 1, 0, 1, 1}, + std::vector{0xAA, 0x80}, // 10101010 10000000 + std::vector{3, -1, 1, 3, + -1, 1, 1, -3, + -1, 3, -1, 3, + 3, -3, 3, -1}, + {1, 1}, + {1, 1}, + {1, 1}, + {1, 1}, + 1.0f), + BinaryConvolutionParams(PartialShape {1, 1, 5, 5}, + Shape {1, 1, 3, 3}, + PartialShape {1, 1, 2, 2}, + IN_ET, + std::vector{0, 1, 1, 0, 1, + 1, 1, 0, 1, 0, + 0, 0, 1, 0, 1, + 1, 1, 0, 1, 0, + 0, 0, 1, 1, 1}, + std::vector{0x2E, 0x00}, // 10101010 10000000 + std::vector{-1, 3, + 1, 1}, + {2, 2}, + {0, 0}, + {0, 0}, + {1, 1}), + BinaryConvolutionParams(PartialShape {1, 1, 7, 7}, + Shape {1, 1, 3, 3}, + PartialShape {1, 1, 3, 3}, + IN_ET, + std::vector{1, 1, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 1, 0, 0, + 1, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 1, 1, 0, + 0, 1, 0, 0, 1, 1, 1, + 1, 0, 1, 1, 0, 0, 0, + 1, 1, 1, 0, 1, 0, 0}, + std::vector{0x6B, 0x00}, // 10101010 10000000 + std::vector{-5, -3, -5, + 5, 1, 3, + -1, -1, 3}, + {1, 1}, + {0, 0}, + {0, 0}, + {2, 2}), + BinaryConvolutionParams(PartialShape {1, 1, 7, 7}, + Shape {1, 1, 3, 3}, + PartialShape {1, 1, 4, 4}, + IN_ET, + std::vector{1, 1, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 1, 0, 0, + 1, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 1, 1, 0, + 0, 1, 0, 0, 1, 1, 1, + 1, 0, 1, 1, 0, 0, 0, + 1, 1, 1, 0, 1, 0, 0}, + std::vector{0x6B, 0x00}, // 10101010 10000000 + std::vector{1, 1, -1, 1, + 1, -5, -5, 5, + 3, -1, 3, 3, + -1, -1, 3, -3}, + {2, 2}, + {2, 2}, + {2, 2}, + {2, 2}), + BinaryConvolutionParams(PartialShape {1, 1, 7, 7}, + Shape {1, 1, 3, 3}, + PartialShape {1, 1, 4, 4}, + IN_ET, + std::vector{1, 1, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 1, 0, 0, + 1, 1, 1, 1, 0, 1, 1, + 0, 0, 0, 1, 1, 1, 0, + 0, 1, 0, 0, 1, 1, 1, + 1, 0, 1, 1, 0, 0, 0, + 1, 1, 1, 0, 1, 0, 0}, + std::vector{0x6B, 0x00}, // 10101010 10000000 + std::vector{3, 3, 1, -1, + -1, -5, -5, 3, + 1, -1, 3, 1, + -3, 1, 5, -1}, + {2, 2}, + {2, 2}, + {2, 2}, + {2, 2}, + 1.0f), + BinaryConvolutionParams(PartialShape {1, 2, 4, 4}, + Shape {1, 2, 3, 3}, + PartialShape {1, 1, 2, 2}, + IN_ET, + std::vector{ + // channel 1 + 1, 0, 0, 1, + 1, 1, 0, 0, + 0, 0, 0, 1, + 1, 0, 1, 1, + // channel 2 + 0, 1, 1, 0, + 0, 0, 1, 1, + 1, 1, 1, 0, + 0, 1, 0, 0}, + std::vector{0xAA, 0xAA, 0x80}, // 10101010 10000000 + std::vector{2, 2, + 6, -2}, + {1, 1}, + {0, 0}, + {0, 0}, + {1, 1}), + BinaryConvolutionParams(PartialShape {2, 1, 4, 4}, + Shape {1, 1, 3, 3}, + PartialShape {2, 1, 2, 2}, + IN_ET, + std::vector{ + // batch 1 + 1, 0, 0, 1, + 1, 1, 0, 0, + 0, 0, 0, 1, + 1, 0, 1, 1, + // batch 2 + 0, 0, 0, 0, + 1, 1, 1, 0, + 1, 1, 0, 1, + 1, 0, 1, 0}, + std::vector{0xAA, 0x80}, // 10101010 10000000 + std::vector{ + // batch 1 + 1, 1, + 3, -1, + // batch 2 + -3, 3, + 5, -7}, + {1, 1}, + {0, 0}, + {0, 0}, + {1, 1}) + }; + return binaryConvolutionParams; +} + +std::vector generateBinaryConvolutionCombinedParams() { + const std::vector> binaryConvolutionTypeParams { + generateBinaryConvolutionParams(), + generateBinaryConvolutionParams(), + generateBinaryConvolutionParams(), + generateBinaryConvolutionParams() + }; + std::vector combinedParams; + + for (const auto& params : binaryConvolutionTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_BinaryConvolution_With_Hardcoded_Refs, ReferenceBinaryConvolutionLayerTest, + testing::ValuesIn(generateBinaryConvolutionCombinedParams()), ReferenceBinaryConvolutionLayerTest::getTestCaseName); + +} // namespace \ No newline at end of file diff --git a/docs/template_plugin/tests/functional/op_reference/convolution_backprop.cpp b/docs/template_plugin/tests/functional/op_reference/convolution_backprop.cpp new file mode 100644 index 00000000000..12274560e9f --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/convolution_backprop.cpp @@ -0,0 +1,1776 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "openvino/op/convolution.hpp" +#include "base_reference_test.hpp" + +using namespace reference_tests; +using namespace ov; + +namespace { +struct ConvolutionBackpropParams { + template + ConvolutionBackpropParams(const PartialShape& inputShape, const PartialShape& filterShape, const PartialShape& outputShape, + const element::Type& iType, + const std::vector& iValues, const std::vector& filterValues, const std::vector& oValues, + const Strides& strides, const CoordinateDiff& padBegin, const CoordinateDiff& padEnd, const Strides& dialations) + : inputShape(inputShape), + filterShape(filterShape), + outputShape(outputShape), + inType(iType), + filterType(iType), + outType(iType), + inputData(CreateTensor(iType, iValues)), + filterData(CreateTensor(iType, filterValues)), + refData(CreateTensor(iType, oValues)), + strides(strides), + padBegin(padBegin), + padEnd(padEnd), + dialations(dialations) {} + + template + ConvolutionBackpropParams(const PartialShape& inputShape, const PartialShape& filterShape, const PartialShape& outputShape, + const element::Type& iType, + const std::vector& iValues, const std::vector& filterValues, const std::vector& oValues, + const Strides& strides, const CoordinateDiff& padBegin, const CoordinateDiff& padEnd, const Strides& dialations, + const CoordinateDiff& outPadding) + : inputShape(inputShape), + filterShape(filterShape), + outputShape(outputShape), + inType(iType), + filterType(iType), + outType(iType), + inputData(CreateTensor(iType, iValues)), + filterData(CreateTensor(iType, filterValues)), + refData(CreateTensor(iType, oValues)), + strides(strides), + padBegin(padBegin), + padEnd(padEnd), + dialations(dialations), + outPadding(outPadding) {} + + PartialShape inputShape; + PartialShape filterShape; + PartialShape outputShape; + ov::element::Type inType; + ov::element::Type filterType; + ov::element::Type outType; + ov::runtime::Tensor inputData; + ov::runtime::Tensor filterData; + ov::runtime::Tensor refData; + ov::Strides strides; + ov::CoordinateDiff padBegin; + ov::CoordinateDiff padEnd; + ov::Strides dialations; + ov::CoordinateDiff outPadding; +}; + +class ReferenceConvolutionBackpropLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params); + inputData = {params.inputData, params.filterData}; + refOutData = {params.refData}; + } + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "inputShape=" << param.inputShape << "_"; + result << "filterShape=" << param.filterShape << "_"; + result << "outputShape=" << param.outputShape << "_"; + result << "iType=" << param.inType << "_"; + result << "oType=" << param.outType << "_"; + result << "strides=" << param.strides << "_"; + result << "padBegin=" << param.padBegin << "_"; + result << "padEnd=" << param.padEnd << "_"; + result << "dialations=" << param.dialations << "_"; + result << "outPadding=" << param.outPadding; + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(const ConvolutionBackpropParams& params) { + const op::PadType auto_pad{op::PadType::EXPLICIT}; + + const auto in = std::make_shared(params.inType, params.inputShape); + const auto filter = std::make_shared(params.inType, params.filterShape); + const auto ConvolutionBackprop = std::make_shared(in, + filter, + params.strides, + params.padBegin, + params.padEnd, + params.dialations, + auto_pad, + params.outPadding); + + return std::make_shared(NodeVector {ConvolutionBackprop}, ParameterVector {in, filter}); + } +}; + +TEST_P(ReferenceConvolutionBackpropLayerTest, CompareWithRefs) { + Exec(); +} + +template +std::vector generateConvolutionBackpropFloatParams() { + using T = typename element_type_traits::value_type; + + std::vector convolutionBackpropParams { +// --------------------- 1D ConvolutionBackprop ------------------------------------------ + ConvolutionBackpropParams(PartialShape {1, 1, 4}, + PartialShape {1, 1, 3}, + PartialShape {1, 1, 6}, + IN_ET, + std::vector{5, 6, 7, 2}, + std::vector{2, 0, 1}, + std::vector{10, 12, 19, 10, 7, 2}, + {1}, + {0}, + {0}, + {1}, + {0}), + ConvolutionBackpropParams(PartialShape {1, 1, 4}, + PartialShape {1, 1, 3}, + PartialShape {1, 1, 4}, + IN_ET, + std::vector{5, 6, 7, 2}, + std::vector{2, 0, 1}, + std::vector{12, 19, 10, 7}, + {1}, + {1}, + {1}, + {1}, + {0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2}, + PartialShape {1, 1, 3}, + PartialShape {1, 1, 5}, + IN_ET, + std::vector{5, 7}, + std::vector{2, 0, 1}, + std::vector{10, 0, 19, 0, 7}, + {2}, + {0}, + {0}, + {1}, + {0}), + ConvolutionBackpropParams(PartialShape {1, 1, 4}, + PartialShape {1, 1, 3}, + PartialShape {1, 1, 5}, + IN_ET, + std::vector{5, 6, 7, 2}, + std::vector{2, 0, 1}, + std::vector{12, 19, 10, 7, 2}, + {1}, + {1}, + {1}, + {1}, + {1}), + ConvolutionBackpropParams(PartialShape {1, 1, 3}, + PartialShape {1, 1, 3}, + PartialShape {1, 1, 7}, + IN_ET, + std::vector{8, 5, 1}, + std::vector{2, 0, 1}, + std::vector{16, 10, 2, 0, 8, 5, 1}, + {1}, + {0}, + {0}, + {2}, + {0}), + ConvolutionBackpropParams(PartialShape {1, 1, 4}, + PartialShape {1, 1, 3}, + PartialShape {1, 1, 7}, + IN_ET, + std::vector{3, 9, 1, 2}, + std::vector{2, 0, 1}, + std::vector{18, 0, 5, 0, 13, 0, 1}, + {2}, + {2}, + {2}, + {2}, + {0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2}, + PartialShape {1, 2, 3}, + PartialShape {1, 2, 4}, + IN_ET, + std::vector{10, 3}, + std::vector{ + // channel 1 + 2, 0, 1, + // channel 2 + 1, 0, 2}, + std::vector{ + // channel 1 + 20, 6, 10, 3, + // channel 2 + 10, 3, 20, 6}, + {1}, + {0}, + {0}, + {1}, + {0}), + ConvolutionBackpropParams(PartialShape {1, 2, 2}, + PartialShape {2, 1, 3}, + PartialShape {1, 1, 4}, + IN_ET, + std::vector{ + // channel 1 + 4, 7, + // channel 2 + 5, 5}, + std::vector{ + // filter 1 + 2, 0, 1, + // filter 2 + 1, 0, 2}, + std::vector{13, 19, 14, 17}, + {1}, + {0}, + {0}, + {1}, + {0}), + ConvolutionBackpropParams(PartialShape {2, 1, 2}, + PartialShape {1, 1, 3}, + PartialShape {2, 1, 4}, + IN_ET, + std::vector{ + // batch 1 + 1, 3, + // batch 2 + 2, 2}, + std::vector{2, 0, 1}, + std::vector{ + // batch 1 + 2, 6, 1, 3, + // batch 2 + 4, 4, 2, 2}, + {1}, + {0}, + {0}, + {1}, + {0}), +// --------------------- 2D ConvolutionBackprop ------------------------------------------ + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2}, + PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 4, 4}, + IN_ET, + std::vector{ + 1, 3, + 7, 5}, + std::vector{ + 1, 2, 3, + 0, 1, 0, + 3, 2, 1}, + std::vector{ + 1, 5, 9, 9, + 7, 20, 34, 15, + 3, 18, 12, 3, + 21, 29, 17, 5}, + {1, 1}, + {0, 0}, + {0, 0}, + {1, 1}, + {0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2}, + PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 3, 3}, + IN_ET, + std::vector{ + 1, 3, + 7, 5}, + std::vector{ + 1, 2, 3, + 1, 1, 1, + 3, 2, 1}, + std::vector{ + 23, 35, 18, + 23, 19, 8, + 29, 17, 5}, + {1, 1}, + {1, 1}, + {1, 1}, + {1, 1}, + {1, 1}), + ConvolutionBackpropParams(PartialShape {1, 1, 4, 4}, + PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 4, 4}, + IN_ET, + std::vector{ + 1, 3, 5, 7, + 7, 5, 3, 1, + 2, 4, 6, 8, + 8, 6, 4, 2}, + std::vector{ + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + 20, 37, 27, 18, + 22, 40, 60, 52, + 41, 69, 49, 31, + 18, 26, 34, 22}, + {1, 1}, + {1, 1}, + {1, 1}, + {1, 1}, + {0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2}, + PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 5, 5}, + IN_ET, + std::vector{ + 2, 5, + 4, 3}, + std::vector{ + 1, 2, 3, + 1, 1, 1, + 3, 2, 1}, + std::vector{ + 2, 4, 11, 10, 15, + 2, 2, 7, 5, 5, + 10, 12, 32, 16, 14, + 4, 4, 7, 3, 3, + 12, 8, 13, 6, 3}, + {2, 2}, + {0, 0}, + {0, 0}, + {1, 1}, + {0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2}, + PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 6, 6}, + IN_ET, + std::vector{ + 2, 3, + 4, 3}, + std::vector{ + 1, 2, 3, + 1, 1, 1, + 3, 2, 1}, + std::vector{ + 2, 3, 4, 6, 6, 9, + 4, 3, 8, 6, 12, 9, + 2, 3, 2, 3, 2, 3, + 4, 3, 4, 3, 4, 3, + 6, 9, 4, 6, 2, 3, + 12, 9, 8, 6, 4, 3}, + {1, 1}, + {0, 0}, + {0, 0}, + {2, 2}, + {0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 5, 5}, + IN_ET, + std::vector{ + 1, 3, 5, + 7, 5, 3, + 2, 4, 6}, + std::vector{ + 1, 2, 3, + 1, 1, 1, + 3, 2, 1}, + std::vector{ + 23, 0, 43, 0, 29, + 0, 0, 0, 0, 0, + 31, 0, 57, 0, 45, + 0, 0, 0, 0, 0, + 35, 0, 38, 0, 21}, + {2, 2}, + {2, 2}, + {2, 2}, + {2, 2}, + {0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2}, + PartialShape {1, 2, 3, 3}, + PartialShape {1, 2, 4, 4}, + IN_ET, + std::vector{ + 1, 3, + 7, 5}, + std::vector{ + // channel 1 + 5, 3, 5, + 1, 3, 1, + 4, 2, 4, + // channel 2 + -5, 3, 5, + 1, -3, 1, + 4, 2, -4}, + std::vector{ + // channel 1 + 5, 18, 14, 15, + 36, 52, 60, 28, + 11, 40, 32, 17, + 28, 34, 38, 20, + // channel 2 + -5, -12, 14, 15, + -34, -4, 42, 28, + 11, -2, -6, -7, + 28, 34, -18, -20}, + {1, 1}, + {0, 0}, + {0, 0}, + {1, 1}, + {0, 0}), + ConvolutionBackpropParams(PartialShape {1, 2, 2, 2}, + PartialShape {2, 1, 3, 3}, + PartialShape {1, 1, 4, 4}, + IN_ET, + std::vector{ + // channel 1 + 1, 3, + 7, 5, + // channel 2 + 2, 4, + 8, 6}, + std::vector{ + // channel 1 + 5, 3, 5, + 1, 3, 1, + 4, 2, 4, + // channel 2 + -5, 3, 5, + 1, -3, 1, + 4, 2, -4}, + std::vector{ + -5, 4, 36, 35, + -2, 44, 108, 62, + 27, 42, 22, 7, + 60, 74, 18, -4}, + {1, 1}, + {0, 0}, + {0, 0}, + {1, 1}, + {0, 0}), + ConvolutionBackpropParams(PartialShape {1, 2, 1, 1}, + PartialShape {2, 2, 2, 2}, + PartialShape {1, 2, 2, 2}, + IN_ET, + std::vector{ + // channel 1 + 2, + // channel 2 + 3}, + std::vector{ + // batch 0 + // channel 1 + 5, 3, + 1, 3, + // channel 2 + -5, 3, + 1, -3, + // batch 1 + // channel 1 + 5, 3, + 1, 3, + // channel 2 + -5, 3, + 1, -3}, + std::vector{ + 25, 15, 5, 15, -25, 15, 5, -15}, + {1, 1}, + {0, 0}, + {0, 0}, + {1, 1}, + {0, 0}), + ConvolutionBackpropParams(PartialShape {2, 1, 2, 2}, + PartialShape {1, 1, 3, 3}, + PartialShape {2, 1, 4, 4}, + IN_ET, + std::vector{ + // batch 1 + 1, 3, + 1, 3, + // batch 2 + -1, 3, + 1, 3}, + std::vector{ + -5, 3, 5, + 1, -3, 1, + 4, 2, -4}, + std::vector{ + // batch 1 + -5, -12, 14, 15, + -4, -12, 6, 18, + 5, 14, -6, -9, + 4, 14, 2, -12, + // batch 2 + 5, -18, 4, 15, + -6, -6, 4, 18, + -3, 10, 2, -9, + 4, 14, 2, -12}, + {1, 1}, + {0, 0}, + {0, 0}, + {1, 1}, + {0, 0}), +// --------------------- 3D convolution ------------------------------------------ + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2, 2}, + PartialShape {1, 1, 3, 3, 3}, + PartialShape {1, 1, 4, 4, 4}, + IN_ET, + std::vector{ + // depth: 1 + 15, 3, + 21, 10, + // depth: 2 + 10, 13, + 11, 17}, + std::vector{ + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + // depth: 1 + 15, 33, 51, 9, + 21, 67, 86, 30, + 30, 42, 43, 6, + 42, 41, 52, 20, + // depth: 2 + 25, 66, 107, 48, + 32, 116, 166, 81, + 50, 89, 93, 32, + 64, 86, 91, 54, + // depth: 3 + 25, 66, 107, 48, + 32, 116, 166, 81, + 50, 89, 93, 32, + 64, 86, 91, 54, + // depth: 4 + 10, 33, 56, 39, + 11, 49, 80, 51, + 20, 47, 50, 26, + 22, 45, 39, 34}, + {1, 1, 1}, + {0, 0, 0}, + {0, 0, 0}, + {1, 1, 1}, + {0, 0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2, 2}, + PartialShape {1, 1, 3, 3, 3}, + PartialShape {1, 1, 3, 3, 3}, + IN_ET, + std::vector{ + // depth: 1 + 15, 3, + 21, 10, + // depth: 2 + 10, 13, + 11, 17}, + std::vector{ + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + // depth: 1 + 116, 166, 81, + 89, 93, 32, + 86, 91, 54, + // depth: 2 + 116, 166, 81, + 89, 93, 32, + 86, 91, 54, + // depth: 3 + 49, 80, 51, + 47, 50, 26, + 45, 39, 34}, + {1, 1, 1}, + {1, 1, 1}, + {1, 1, 1}, + {1, 1, 1}, + {1, 1, 1}), + ConvolutionBackpropParams(PartialShape {1, 1, 4, 4, 4}, + PartialShape {1, 1, 3, 3, 3}, + PartialShape {1, 1, 4, 4, 4}, + IN_ET, + std::vector{ + // depth: 1 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3, + // depth: 2 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3, + // depth: 3 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3, + // depth: 4 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3}, + std::vector{ + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + // depth: 1 + 12, 30, 36, 24, + 26, 42, 42, 30, + 34, 56, 54, 50, + 14, 18, 24, 16, + // depth: 2 + 18, 45, 54, 36, + 39, 63, 63, 45, + 51, 84, 81, 75, + 21, 27, 36, 24, + // depth: 3 + 18, 45, 54, 36, + 39, 63, 63, 45, + 51, 84, 81, 75, + 21, 27, 36, 24, + // depth: 4 + 12, 30, 36, 24, + 26, 42, 42, 30, + 34, 56, 54, 50, + 14, 18, 24, 16}, + {1, 1, 1}, + {1, 1, 1}, + {1, 1, 1}, + {1, 1, 1}, + {0, 0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2, 2}, + PartialShape {1, 1, 3, 3, 3}, + PartialShape {1, 1, 5, 5, 5}, + IN_ET, + std::vector{ + // depth: 1 + 15, 3, + 21, 10, + // depth: 2 + 10, 13, + 11, 17}, + std::vector{ + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + // depth: 1 + 15, 30, 48, 6, 9, + 0, 15, 0, 3, 0, + 51, 57, 109, 23, 36, + 0, 21, 0, 10, 0, + 42, 21, 62, 10, 20, + // depth: 2 + 15, 30, 48, 6, 9, + 0, 15, 0, 3, 0, + 51, 57, 109, 23, 36, + 0, 21, 0, 10, 0, + 42, 21, 62, 10, 20, + // depth: 3 + 25, 50, 91, 32, 48, + 0, 25, 0, 16, 0, + 82, 89, 205, 70, 113, + 0, 32, 0, 27, 0, + 64, 32, 118, 27, 54, + // depth: 4 + 10, 20, 43, 26, 39, + 0, 10, 0, 13, 0, + 31, 32, 96, 47, 77, + 0, 11, 0, 17, 0, + 22, 11, 56, 17, 34, + // depth: 5 + 10, 20, 43, 26, 39, + 0, 10, 0, 13, 0, + 31, 32, 96, 47, 77, + 0, 11, 0, 17, 0, + 22, 11, 56, 17, 34}, + {2, 2, 2}, + {0, 0, 0}, + {0, 0, 0}, + {1, 1, 1}, + {0, 0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 4, 4, 4}, + PartialShape {1, 1, 3, 3, 3}, + PartialShape {1, 1, 7, 7, 7}, + IN_ET, + std::vector{ + // depth: 1 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3, + // depth: 2 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3, + // depth: 3 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3, + // depth: 4 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3}, + std::vector{ + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + // depth: 1 + 12, 0, 30, 0, 36, 0, 24, + 0, 0, 0, 0, 0, 0, 0, + 26, 0, 42, 0, 42, 0, 30, + 0, 0, 0, 0, 0, 0, 0, + 34, 0, 56, 0, 54, 0, 50, + 0, 0, 0, 0, 0, 0, 0, + 14, 0, 18, 0, 24, 0, 16, + // depth: 2 + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + // depth: 3 + 18, 0, 45, 0, 54, 0, 36, + 0, 0, 0, 0, 0, 0, 0, + 39, 0, 63, 0, 63, 0, 45, + 0, 0, 0, 0, 0, 0, 0, + 51, 0, 84, 0, 81, 0, 75, + 0, 0, 0, 0, 0, 0, 0, + 21, 0, 27, 0, 36, 0, 24, + // depth: 4 + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + // depth: 5 + 18, 0, 45, 0, 54, 0, 36, + 0, 0, 0, 0, 0, 0, 0, + 39, 0, 63, 0, 63, 0, 45, + 0, 0, 0, 0, 0, 0, 0, + 51, 0, 84, 0, 81, 0, 75, + 0, 0, 0, 0, 0, 0, 0, + 21, 0, 27, 0, 36, 0, 24, + // depth: 6 + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + // depth: 7 + 12, 0, 30, 0, 36, 0, 24, + 0, 0, 0, 0, 0, 0, 0, + 26, 0, 42, 0, 42, 0, 30, + 0, 0, 0, 0, 0, 0, 0, + 34, 0, 56, 0, 54, 0, 50, + 0, 0, 0, 0, 0, 0, 0, + 14, 0, 18, 0, 24, 0, 16}, + {2, 2, 2}, + {2, 2, 2}, + {2, 2, 2}, + {2, 2, 2}, + {0, 0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2, 2}, + PartialShape {1, 2, 3, 3, 3}, + PartialShape {1, 2, 4, 4, 4}, + IN_ET, + std::vector{ + // depth: 1 + 1, 8, + 1, 3, + // depth: 2 + 1, 7, + 3, 8}, + std::vector{ + // -- channel 1 -- + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // -- channel 2 -- + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + // -- channel 1 -- + // depth: 1 + 1, 10, 19, 24, + 1, 6, 17, 9, + 2, 18, 13, 16, + 2, 7, 5, 6, + // depth: 2 + 2, 19, 36, 45, + 4, 21, 49, 33, + 4, 36, 30, 30, + 8, 26, 19, 22, + // depth: 3 + 2, 19, 36, 45, + 4, 21, 49, 33, + 4, 36, 30, 30, + 8, 26, 19, 22, + // depth: 4 + 1, 9, 17, 21, + 3, 15, 32, 24, + 2, 18, 17, 14, + 6, 19, 14, 16, + // -- channel 2 -- + // depth: 1 + 1, 10, 19, 24, + 1, 6, 17, 9, + 2, 18, 13, 16, + 2, 7, 5, 6, + // depth: 2 + 2, 19, 36, 45, + 4, 21, 49, 33, + 4, 36, 30, 30, + 8, 26, 19, 22, + // depth: 3 + 2, 19, 36, 45, + 4, 21, 49, 33, + 4, 36, 30, 30, + 8, 26, 19, 22, + // depth: 4 + 1, 9, 17, 21, + 3, 15, 32, 24, + 2, 18, 17, 14, + 6, 19, 14, 16}, + {1, 1, 1}, + {0, 0, 0}, + {0, 0, 0}, + {1, 1, 1}, + {0, 0, 0}), + ConvolutionBackpropParams(PartialShape {1, 2, 2, 2, 2}, + PartialShape {2, 1, 3, 3, 3}, + PartialShape {1, 1, 4, 4, 4}, + IN_ET, + std::vector{ + // -- in 1 -- + // depth: 1 + 1, 3, + 2, 5, + // depth: 2 + 1, 0, + 3, 6, + // -- in 2 -- + // depth: 1 + 1, 3, + 2, 5, + // depth: 2 + 3, 0, + 1, 8}, + std::vector{ + // -- filter 1 -- + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // -- filter 2 -- + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + // depth: 1 + 2, 10, 18, 18, + 4, 20, 38, 30, + 4, 18, 20, 12, + 8, 24, 18, 20, + // depth: 2 + 6, 18, 30, 18, + 8, 46, 78, 72, + 12, 26, 42, 12, + 16, 56, 40, 48, + // depth: 3 + 6, 18, 30, 18, + 8, 46, 78, 72, + 12, 26, 42, 12, + 16, 56, 40, 48, + // depth: 4 + 4, 8, 12, 0, + 4, 26, 40, 42, + 8, 8, 22, 0, + 8, 32, 22, 28}, + {1, 1, 1}, + {0, 0, 0}, + {0, 0, 0}, + {1, 1, 1}, + {0, 0, 0}), + ConvolutionBackpropParams(PartialShape {2, 1, 2, 2, 2}, + PartialShape {1, 1, 3, 3, 3}, + PartialShape {2, 1, 4, 4, 4}, + IN_ET, + std::vector{ + // -- batch 1 -- + // depth: 1 + 1, 3, + 2, 5, + // depth: 2 + 1, 0, + 6, 4, + // -- batch 2 -- + // depth: 1 + 1, 5, + 2, 8, + // depth: 2 + 2, 1, + 0, 5}, + std::vector{ + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + // -- batch 1 -- + // depth: 1 + 1, 5, 9, 9, + 2, 10, 19, 15, + 2, 9, 10, 6, + 4, 12, 9, 10, + // depth: 2 + 2, 7, 12, 9, + 8, 27, 45, 27, + 4, 16, 16, 6, + 16, 26, 25, 18, + // depth: 3 + 2, 7, 12, 9, + 8, 27, 45, 27, + 4, 16, 16, 6, + 16, 26, 25, 18, + // depth: 4 + 1, 2, 3, 0, + 6, 17, 26, 12, + 2, 7, 6, 0, + 12, 14, 16, 8, + // -- batch 2 -- + // depth: 1 + 1, 7, 13, 15, + 2, 13, 27, 24, + 2, 13, 15, 10, + 4, 18, 12, 16, + // depth: 2 + 3, 12, 21, 18, + 2, 20, 38, 39, + 6, 17, 25, 12, + 4, 28, 17, 26, + // depth: 3 + 3, 12, 21, 18, + 2, 20, 38, 39, + 6, 17, 25, 12, + 4, 28, 17, 26, + // depth: 4 + 2, 5, 8, 3, + 0, 7, 11, 15, + 4, 4, 10, 2, + 0, 10, 5, 10}, + {1, 1, 1}, + {0, 0, 0}, + {0, 0, 0}, + {1, 1, 1}, + {0, 0, 0}) + }; + return convolutionBackpropParams; +} + +template +std::vector generateConvolutionBackpropUintParams() { + using T = typename element_type_traits::value_type; + + std::vector convolutionBackpropParams { +// --------------------- 1D ConvolutionBackprop ------------------------------------------ + ConvolutionBackpropParams(PartialShape {1, 1, 4}, + PartialShape {1, 1, 3}, + PartialShape {1, 1, 6}, + IN_ET, + std::vector{5, 6, 7, 2}, + std::vector{2, 0, 1}, + std::vector{10, 12, 19, 10, 7, 2}, + {1}, + {0}, + {0}, + {1}, + {0}), + ConvolutionBackpropParams(PartialShape {1, 1, 4}, + PartialShape {1, 1, 3}, + PartialShape {1, 1, 4}, + IN_ET, + std::vector{5, 6, 7, 2}, + std::vector{2, 0, 1}, + std::vector{12, 19, 10, 7}, + {1}, + {1}, + {1}, + {1}, + {0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2}, + PartialShape {1, 1, 3}, + PartialShape {1, 1, 5}, + IN_ET, + std::vector{5, 7}, + std::vector{2, 0, 1}, + std::vector{10, 0, 19, 0, 7}, + {2}, + {0}, + {0}, + {1}, + {0}), + ConvolutionBackpropParams(PartialShape {1, 1, 4}, + PartialShape {1, 1, 3}, + PartialShape {1, 1, 5}, + IN_ET, + std::vector{5, 6, 7, 2}, + std::vector{2, 0, 1}, + std::vector{12, 19, 10, 7, 2}, + {1}, + {1}, + {1}, + {1}, + {1}), + ConvolutionBackpropParams(PartialShape {1, 1, 3}, + PartialShape {1, 1, 3}, + PartialShape {1, 1, 7}, + IN_ET, + std::vector{8, 5, 1}, + std::vector{2, 0, 1}, + std::vector{16, 10, 2, 0, 8, 5, 1}, + {1}, + {0}, + {0}, + {2}, + {0}), + ConvolutionBackpropParams(PartialShape {1, 1, 4}, + PartialShape {1, 1, 3}, + PartialShape {1, 1, 7}, + IN_ET, + std::vector{3, 9, 1, 2}, + std::vector{2, 0, 1}, + std::vector{18, 0, 5, 0, 13, 0, 1}, + {2}, + {2}, + {2}, + {2}, + {0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2}, + PartialShape {1, 2, 3}, + PartialShape {1, 2, 4}, + IN_ET, + std::vector{10, 3}, + std::vector{ + // channel 1 + 2, 0, 1, + // channel 2 + 1, 0, 2}, + std::vector{ + // channel 1 + 20, 6, 10, 3, + // channel 2 + 10, 3, 20, 6}, + {1}, + {0}, + {0}, + {1}, + {0}), + ConvolutionBackpropParams(PartialShape {1, 2, 2}, + PartialShape {2, 1, 3}, + PartialShape {1, 1, 4}, + IN_ET, + std::vector{ + // channel 1 + 4, 7, + // channel 2 + 5, 5}, + std::vector{ + // filter 1 + 2, 0, 1, + // filter 2 + 1, 0, 2}, + std::vector{13, 19, 14, 17}, + {1}, + {0}, + {0}, + {1}, + {0}), + ConvolutionBackpropParams(PartialShape {2, 1, 2}, + PartialShape {1, 1, 3}, + PartialShape {2, 1, 4}, + IN_ET, + std::vector{ + // batch 1 + 1, 3, + // batch 2 + 2, 2}, + std::vector{2, 0, 1}, + std::vector{ + // batch 1 + 2, 6, 1, 3, + // batch 2 + 4, 4, 2, 2}, + {1}, + {0}, + {0}, + {1}, + {0}), +// --------------------- 2D ConvolutionBackprop ------------------------------------------ + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2}, + PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 4, 4}, + IN_ET, + std::vector{ + 1, 3, + 7, 5}, + std::vector{ + 1, 2, 3, + 0, 1, 0, + 3, 2, 1}, + std::vector{ + 1, 5, 9, 9, + 7, 20, 34, 15, + 3, 18, 12, 3, + 21, 29, 17, 5}, + {1, 1}, + {0, 0}, + {0, 0}, + {1, 1}, + {0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2}, + PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 3, 3}, + IN_ET, + std::vector{ + 1, 3, + 7, 5}, + std::vector{ + 1, 2, 3, + 1, 1, 1, + 3, 2, 1}, + std::vector{ + 23, 35, 18, + 23, 19, 8, + 29, 17, 5}, + {1, 1}, + {1, 1}, + {1, 1}, + {1, 1}, + {1, 1}), + ConvolutionBackpropParams(PartialShape {1, 1, 4, 4}, + PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 4, 4}, + IN_ET, + std::vector{ + 1, 3, 5, 7, + 7, 5, 3, 1, + 2, 4, 6, 8, + 8, 6, 4, 2}, + std::vector{ + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + 20, 37, 27, 18, + 22, 40, 60, 52, + 41, 69, 49, 31, + 18, 26, 34, 22}, + {1, 1}, + {1, 1}, + {1, 1}, + {1, 1}, + {0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2}, + PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 5, 5}, + IN_ET, + std::vector{ + 2, 5, + 4, 3}, + std::vector{ + 1, 2, 3, + 1, 1, 1, + 3, 2, 1}, + std::vector{ + 2, 4, 11, 10, 15, + 2, 2, 7, 5, 5, + 10, 12, 32, 16, 14, + 4, 4, 7, 3, 3, + 12, 8, 13, 6, 3}, + {2, 2}, + {0, 0}, + {0, 0}, + {1, 1}, + {0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2}, + PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 6, 6}, + IN_ET, + std::vector{ + 2, 3, + 4, 3}, + std::vector{ + 1, 2, 3, + 1, 1, 1, + 3, 2, 1}, + std::vector{ + 2, 3, 4, 6, 6, 9, + 4, 3, 8, 6, 12, 9, + 2, 3, 2, 3, 2, 3, + 4, 3, 4, 3, 4, 3, + 6, 9, 4, 6, 2, 3, + 12, 9, 8, 6, 4, 3}, + {1, 1}, + {0, 0}, + {0, 0}, + {2, 2}, + {0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 3, 3}, + PartialShape {1, 1, 5, 5}, + IN_ET, + std::vector{ + 1, 3, 5, + 7, 5, 3, + 2, 4, 6}, + std::vector{ + 1, 2, 3, + 1, 1, 1, + 3, 2, 1}, + std::vector{ + 23, 0, 43, 0, 29, + 0, 0, 0, 0, 0, + 31, 0, 57, 0, 45, + 0, 0, 0, 0, 0, + 35, 0, 38, 0, 21}, + {2, 2}, + {2, 2}, + {2, 2}, + {2, 2}, + {0, 0}), +// --------------------- 3D convolution ------------------------------------------ + ConvolutionBackpropParams(PartialShape {1, 1, 4, 4, 4}, + PartialShape {1, 1, 3, 3, 3}, + PartialShape {1, 1, 4, 4, 4}, + IN_ET, + std::vector{ + // depth: 1 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3, + // depth: 2 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3, + // depth: 3 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3, + // depth: 4 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3}, + std::vector{ + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + // depth: 1 + 12, 30, 36, 24, + 26, 42, 42, 30, + 34, 56, 54, 50, + 14, 18, 24, 16, + // depth: 2 + 18, 45, 54, 36, + 39, 63, 63, 45, + 51, 84, 81, 75, + 21, 27, 36, 24, + // depth: 3 + 18, 45, 54, 36, + 39, 63, 63, 45, + 51, 84, 81, 75, + 21, 27, 36, 24, + // depth: 4 + 12, 30, 36, 24, + 26, 42, 42, 30, + 34, 56, 54, 50, + 14, 18, 24, 16}, + {1, 1, 1}, + {1, 1, 1}, + {1, 1, 1}, + {1, 1, 1}, + {0, 0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 4, 4, 4}, + PartialShape {1, 1, 3, 3, 3}, + PartialShape {1, 1, 7, 7, 7}, + IN_ET, + std::vector{ + // depth: 1 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3, + // depth: 2 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3, + // depth: 3 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3, + // depth: 4 + 1, 3, 2, 1, + 1, 3, 3, 1, + 2, 1, 1, 3, + 3, 2, 3, 3}, + std::vector{ + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + // depth: 1 + 12, 0, 30, 0, 36, 0, 24, + 0, 0, 0, 0, 0, 0, 0, + 26, 0, 42, 0, 42, 0, 30, + 0, 0, 0, 0, 0, 0, 0, + 34, 0, 56, 0, 54, 0, 50, + 0, 0, 0, 0, 0, 0, 0, + 14, 0, 18, 0, 24, 0, 16, + // depth: 2 + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + // depth: 3 + 18, 0, 45, 0, 54, 0, 36, + 0, 0, 0, 0, 0, 0, 0, + 39, 0, 63, 0, 63, 0, 45, + 0, 0, 0, 0, 0, 0, 0, + 51, 0, 84, 0, 81, 0, 75, + 0, 0, 0, 0, 0, 0, 0, + 21, 0, 27, 0, 36, 0, 24, + // depth: 4 + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + // depth: 5 + 18, 0, 45, 0, 54, 0, 36, + 0, 0, 0, 0, 0, 0, 0, + 39, 0, 63, 0, 63, 0, 45, + 0, 0, 0, 0, 0, 0, 0, + 51, 0, 84, 0, 81, 0, 75, + 0, 0, 0, 0, 0, 0, 0, + 21, 0, 27, 0, 36, 0, 24, + // depth: 6 + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + // depth: 7 + 12, 0, 30, 0, 36, 0, 24, + 0, 0, 0, 0, 0, 0, 0, + 26, 0, 42, 0, 42, 0, 30, + 0, 0, 0, 0, 0, 0, 0, + 34, 0, 56, 0, 54, 0, 50, + 0, 0, 0, 0, 0, 0, 0, + 14, 0, 18, 0, 24, 0, 16}, + {2, 2, 2}, + {2, 2, 2}, + {2, 2, 2}, + {2, 2, 2}, + {0, 0, 0}), + ConvolutionBackpropParams(PartialShape {1, 1, 2, 2, 2}, + PartialShape {1, 2, 3, 3, 3}, + PartialShape {1, 2, 4, 4, 4}, + IN_ET, + std::vector{ + // depth: 1 + 1, 8, + 1, 3, + // depth: 2 + 1, 7, + 3, 8}, + std::vector{ + // -- channel 1 -- + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // -- channel 2 -- + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + // -- channel 1 -- + // depth: 1 + 1, 10, 19, 24, + 1, 6, 17, 9, + 2, 18, 13, 16, + 2, 7, 5, 6, + // depth: 2 + 2, 19, 36, 45, + 4, 21, 49, 33, + 4, 36, 30, 30, + 8, 26, 19, 22, + // depth: 3 + 2, 19, 36, 45, + 4, 21, 49, 33, + 4, 36, 30, 30, + 8, 26, 19, 22, + // depth: 4 + 1, 9, 17, 21, + 3, 15, 32, 24, + 2, 18, 17, 14, + 6, 19, 14, 16, + // -- channel 2 -- + // depth: 1 + 1, 10, 19, 24, + 1, 6, 17, 9, + 2, 18, 13, 16, + 2, 7, 5, 6, + // depth: 2 + 2, 19, 36, 45, + 4, 21, 49, 33, + 4, 36, 30, 30, + 8, 26, 19, 22, + // depth: 3 + 2, 19, 36, 45, + 4, 21, 49, 33, + 4, 36, 30, 30, + 8, 26, 19, 22, + // depth: 4 + 1, 9, 17, 21, + 3, 15, 32, 24, + 2, 18, 17, 14, + 6, 19, 14, 16}, + {1, 1, 1}, + {0, 0, 0}, + {0, 0, 0}, + {1, 1, 1}, + {0, 0, 0}), + ConvolutionBackpropParams(PartialShape {1, 2, 2, 2, 2}, + PartialShape {2, 1, 3, 3, 3}, + PartialShape {1, 1, 4, 4, 4}, + IN_ET, + std::vector{ + // -- in 1 -- + // depth: 1 + 1, 3, + 2, 5, + // depth: 2 + 1, 0, + 3, 6, + // -- in 2 -- + // depth: 1 + 1, 3, + 2, 5, + // depth: 2 + 3, 0, + 1, 8}, + std::vector{ + // -- filter 1 -- + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // -- filter 2 -- + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + // depth: 1 + 2, 10, 18, 18, + 4, 20, 38, 30, + 4, 18, 20, 12, + 8, 24, 18, 20, + // depth: 2 + 6, 18, 30, 18, + 8, 46, 78, 72, + 12, 26, 42, 12, + 16, 56, 40, 48, + // depth: 3 + 6, 18, 30, 18, + 8, 46, 78, 72, + 12, 26, 42, 12, + 16, 56, 40, 48, + // depth: 4 + 4, 8, 12, 0, + 4, 26, 40, 42, + 8, 8, 22, 0, + 8, 32, 22, 28}, + {1, 1, 1}, + {0, 0, 0}, + {0, 0, 0}, + {1, 1, 1}, + {0, 0, 0}), + ConvolutionBackpropParams(PartialShape {2, 1, 2, 2, 2}, + PartialShape {1, 1, 3, 3, 3}, + PartialShape {2, 1, 4, 4, 4}, + IN_ET, + std::vector{ + // -- batch 1 -- + // depth: 1 + 1, 3, + 2, 5, + // depth: 2 + 1, 0, + 6, 4, + // -- batch 2 -- + // depth: 1 + 1, 5, + 2, 8, + // depth: 2 + 2, 1, + 0, 5}, + std::vector{ + // depth: 1 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 2 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2, + // depth: 3 + 1, 2, 3, + 0, 1, 0, + 2, 1, 2}, + std::vector{ + // -- batch 1 -- + // depth: 1 + 1, 5, 9, 9, + 2, 10, 19, 15, + 2, 9, 10, 6, + 4, 12, 9, 10, + // depth: 2 + 2, 7, 12, 9, + 8, 27, 45, 27, + 4, 16, 16, 6, + 16, 26, 25, 18, + // depth: 3 + 2, 7, 12, 9, + 8, 27, 45, 27, + 4, 16, 16, 6, + 16, 26, 25, 18, + // depth: 4 + 1, 2, 3, 0, + 6, 17, 26, 12, + 2, 7, 6, 0, + 12, 14, 16, 8, + // -- batch 2 -- + // depth: 1 + 1, 7, 13, 15, + 2, 13, 27, 24, + 2, 13, 15, 10, + 4, 18, 12, 16, + // depth: 2 + 3, 12, 21, 18, + 2, 20, 38, 39, + 6, 17, 25, 12, + 4, 28, 17, 26, + // depth: 3 + 3, 12, 21, 18, + 2, 20, 38, 39, + 6, 17, 25, 12, + 4, 28, 17, 26, + // depth: 4 + 2, 5, 8, 3, + 0, 7, 11, 15, + 4, 4, 10, 2, + 0, 10, 5, 10}, + {1, 1, 1}, + {0, 0, 0}, + {0, 0, 0}, + {1, 1, 1}, + {0, 0, 0}) + }; + return convolutionBackpropParams; +} + +std::vector generateConvolutionBackpropCombinedParams() { + const std::vector> convolutionBackpropTypeParams { + generateConvolutionBackpropFloatParams(), + generateConvolutionBackpropFloatParams(), + generateConvolutionBackpropFloatParams(), + generateConvolutionBackpropFloatParams(), + generateConvolutionBackpropFloatParams(), + generateConvolutionBackpropFloatParams(), + generateConvolutionBackpropFloatParams(), + generateConvolutionBackpropUintParams(), + generateConvolutionBackpropUintParams(), + generateConvolutionBackpropUintParams(), + generateConvolutionBackpropUintParams(), + generateConvolutionBackpropUintParams(), + }; + std::vector combinedParams; + + for (const auto& params : convolutionBackpropTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionBackprop_With_Hardcoded_Refs, ReferenceConvolutionBackpropLayerTest, + testing::ValuesIn(generateConvolutionBackpropCombinedParams()), ReferenceConvolutionBackpropLayerTest::getTestCaseName); + +} // namespace \ No newline at end of file diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 266faee4a52..ecb7f01bf4f 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -268,6 +268,7 @@ set(SRC visitors/op/atanh.cpp visitors/op/batch_norm.cpp visitors/op/batch_to_space.cpp + visitors/op/binary_convolution.cpp visitors/op/broadcast.cpp visitors/op/bucketize.cpp visitors/op/ceiling.cpp @@ -464,8 +465,6 @@ set(MULTI_TEST_SRC backend/ceiling.in.cpp backend/concat.in.cpp backend/constant.in.cpp - backend/convolution_backprop.in.cpp - backend/binary_convolution.in.cpp backend/ctc_greedy_decoder.in.cpp backend/ctc_greedy_decoder_seq_len.in.cpp backend/deformable_psroi_pooling.in.cpp diff --git a/ngraph/test/backend/binary_convolution.in.cpp b/ngraph/test/backend/binary_convolution.in.cpp deleted file mode 100644 index 805c41ff29c..00000000000 --- a/ngraph/test/backend/binary_convolution.in.cpp +++ /dev/null @@ -1,646 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "engines_util/execute_tools.hpp" -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "ngraph/runtime/tensor.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}"; - -template -static void BinaryConvolutionTest(const std::vector& inputs, - const Shape inputs_shape, - const std::vector& filters, - const Shape filters_shape, - const std::vector& outputs, - const Shape outputs_shape, - const Strides& strides, - const CoordinateDiff& padding, - const Strides& dilations, - const float pad_value = 0.0f) { - const CoordinateDiff pads_begin{padding}; - const CoordinateDiff pads_end{padding}; - const op::PadType auto_pad{op::PadType::EXPLICIT}; - - auto inputs_param = make_shared(element::from(), inputs_shape); - auto filters_const = make_shared(element::u1, filters_shape, &filters[0]); - auto bin_conv = - make_shared(inputs_param, - filters_const, - strides, - pads_begin, - pads_end, - dilations, - op::v1::BinaryConvolution::BinaryConvolutionMode::XNOR_POPCOUNT, - pad_value, - auto_pad); - auto f = make_shared(bin_conv, ParameterVector{inputs_param}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - auto input_tensor = backend->create_tensor(element::from(), inputs_shape); - copy_data(input_tensor, inputs); - auto result = backend->create_tensor(element::from(), outputs_shape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {input_tensor}); - EXPECT_TRUE(test::all_close_f((outputs), read_vector(result), MIN_FLOAT_TOLERANCE_BITS)); -} - -template -static void ConvolutionTest(const std::vector& inputs, - const Shape inputs_shape, - const std::vector& filters, - const Shape filters_shape, - const std::vector& outputs, - const Shape outputs_shape, - const Strides& strides, - const CoordinateDiff& padding, - const Strides& dilations) { - const CoordinateDiff pads_begin{padding}; - const CoordinateDiff pads_end{padding}; - const op::PadType auto_pad{op::PadType::EXPLICIT}; - - auto inputs_param = make_shared(element::from(), inputs_shape); - auto filters_param = make_shared(element::from(), filters_shape); - auto conv = make_shared(inputs_param, - filters_param, - strides, - pads_begin, - pads_end, - dilations, - auto_pad); - auto f = make_shared(conv, ParameterVector{inputs_param, filters_param}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - auto input_tensor = backend->create_tensor(element::from(), inputs_shape); - copy_data(input_tensor, inputs); - auto filters_tensor = backend->create_tensor(element::from(), filters_shape); - copy_data(filters_tensor, filters); - auto result = backend->create_tensor(element::from(), outputs_shape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {input_tensor, filters_tensor}); - EXPECT_TRUE(test::all_close_f((outputs), read_vector(result), MIN_FLOAT_TOLERANCE_BITS)); -} - -// clang-format off -// --------------------- 2D convolution ------------------------------------------ -NGRAPH_TEST(${BACKEND_NAME}, bin_convolution_2D_1batch_1channel) -{ - const Strides strides{1, 1}; - const CoordinateDiff padding{0, 0}; - const Strides dilations{1, 1}; - - const Shape inputs_shape{1, 1, 4, 4}; - const std::vector inputs_conv{1.0f, -1.0f, -1.0f, 1.0f, - 1.0f, 1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, -1.0f, 1.0f, - 1.0f, -1.0f, 1.0f, 1.0f}; - - const std::vector inputs_bin_conv{1.0f, 0.0f, 0.0f, 1.0f, - 1.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f, - 1.0f, 0.0f, 1.0f, 1.0f}; - - const Shape filters_shape{1, 1, 3, 3}; - const std::vector filters_conv{1.0f, -1.0f, 1.0f, - -1.0f, 1.0f, -1.0f, - 1.0f, -1.0f, 1.0f}; - - const std::vector filters_bin_conv{0xAA, 0x80}; // 10101010 10000000 - - const Shape outputs_shape{1, 1, 2, 2}; - const std::vector outputs{1.0f, 1.0f, - 3.0f, -1.0f}; - - BinaryConvolutionTest( - inputs_bin_conv, - inputs_shape, - filters_bin_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding, - dilations); - - ConvolutionTest( - inputs_conv, - inputs_shape, - filters_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding, - dilations); -} - -NGRAPH_TEST(${BACKEND_NAME}, bin_convolution_2D_1batch_1channel_padding_pad_val_0) -{ - const Strides strides{1, 1}; - const Strides dilations{1, 1}; - - const CoordinateDiff padding_conv{0, 0}; - const Shape inputs_conv_shape{1, 1, 6, 6}; - const std::vector inputs_conv{-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, - -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, - -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, - -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, - -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f}; - - const CoordinateDiff padding_bin_conv{1, 1}; - const Shape inputs_bin_conv_shape{1, 1, 4, 4}; - const std::vector inputs_bin_conv{1.0f, 0.0f, 0.0f, 1.0f, - 1.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f, - 1.0f, 0.0f, 1.0f, 1.0f}; - - const Shape filters_shape{1, 1, 3, 3}; - const std::vector filters_conv{1.0f, -1.0f, 1.0f, - -1.0f, 1.0f, -1.0f, - 1.0f, -1.0f, 1.0f}; - - const std::vector filters_bin_conv{0xAA, 0x80}; // 10101010 10000000 - - const Shape outputs_shape{1, 1, 4, 4}; - const std::vector outputs{1.0f, -3.0f, -1.0f, 1.0f, - -3.0f, 1.0f, 1.0f, -5.0f, - -3.0f, 3.0f, -1.0f, 1.0f, - 1.0f, -5.0f, 1.0f, -3.0f}; - - BinaryConvolutionTest( - inputs_bin_conv, - inputs_bin_conv_shape, - filters_bin_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding_bin_conv, - dilations); - - ConvolutionTest( - inputs_conv, - inputs_conv_shape, - filters_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding_conv, - dilations); -} - -NGRAPH_TEST(${BACKEND_NAME}, bin_convolution_2D_1batch_1channel_padding_pad_val_1) -{ - const Strides strides{1, 1}; - const Strides dilations{1, 1}; - const float pad_value = 1.0f; - - const CoordinateDiff padding_conv{0, 0}; - const Shape inputs_conv_shape{1, 1, 6, 6}; - const std::vector inputs_conv{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, - 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}; - - const CoordinateDiff padding_bin_conv{1, 1}; - const Shape inputs_bin_conv_shape{1, 1, 4, 4}; - const std::vector inputs_bin_conv{1.0f, 0.0f, 0.0f, 1.0f, - 1.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f, - 1.0f, 0.0f, 1.0f, 1.0f}; - - const Shape filters_shape{1, 1, 3, 3}; - const std::vector filters_conv{1.0f, -1.0f, 1.0f, - -1.0f, 1.0f, -1.0f, - 1.0f, -1.0f, 1.0f}; - - const std::vector filters_bin_conv{0xAA, 0x80}; // 10101010 10000000 - - const Shape outputs_shape{1, 1, 4, 4}; - const std::vector outputs{3.0f, -1.0f, 1.0f, 3.0f, - -1.0f, 1.0f, 1.0f, -3.0f, - -1.0f, 3.0f, -1.0f, 3.0f, - 3.0f, -3.0f, 3.0f, -1.0f,}; - - BinaryConvolutionTest( - inputs_bin_conv, - inputs_bin_conv_shape, - filters_bin_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding_bin_conv, - dilations, - pad_value); - - ConvolutionTest( - inputs_conv, - inputs_conv_shape, - filters_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding_conv, - dilations); -} - -NGRAPH_TEST(${BACKEND_NAME}, bin_convolution_2D_1batch_1channel_stride) -{ - const Strides strides{2, 2}; - const CoordinateDiff padding{0, 0}; - const Strides dilations{1, 1}; - - const Shape inputs_shape{1, 1, 5, 5}; - const std::vector inputs_conv{-1.0f, 1.0f, 1.0f, -1.0f, 1.0f, - 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, - -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, - 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, - -1.0f, -1.0f, 1.0f, 1.0f, 1.0f}; - - const std::vector inputs_bin_conv{0.0f, 1.0f, 1.0f, 0.0f, 1.0f, - 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, - 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 1.0f, 1.0f}; - - const Shape filters_shape{1, 1, 3, 3}; - const std::vector filters_conv{-1.0f, -1.0f, 1.0f, - -1.0f, 1.0f, 1.0f, - 1.0f, -1.0f, -1.0f}; - const std::vector filters_bin_conv{0x2E, 0x00}; // 00101110 00000000 - - const Shape outputs_shape{1, 1, 2, 2}; - const std::vector outputs{-1.0f, 3.0f, - 1.0f, 1.0f}; - - BinaryConvolutionTest( - inputs_bin_conv, - inputs_shape, - filters_bin_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding, - dilations); - - ConvolutionTest( - inputs_conv, - inputs_shape, - filters_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding, - dilations); -} - -NGRAPH_TEST(${BACKEND_NAME}, bin_convolution_2D_1batch_1channel_dilation) -{ - const Strides strides{1, 1}; - const CoordinateDiff padding{0, 0}; - const Strides dilations{2, 2}; - - const Shape inputs_shape{1, 1, 7, 7}; - const std::vector inputs_conv{1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, - -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, - -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, -1.0f, - -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, - 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f}; - - const std::vector inputs_bin_conv{1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, - 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, - 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f}; - - const Shape filters_shape{1, 1, 3, 3}; - const std::vector filters_conv{-1.0f, 1.0f, 1.0f, - -1.0f, 1.0f, -1.0f, - 1.0f, 1.0f, -1.0f}; - const std::vector filters_bin_conv{0x6B, 0x00}; // 01101011 00000000 - - const Shape outputs_shape{1, 1, 3, 3}; - const std::vector outputs{-5.0f, -3.0f, -5.0f, - 5.0f, 1.0f, 3.0f, - -1.0f, -1.0f, 3.0f}; - - BinaryConvolutionTest( - inputs_bin_conv, - inputs_shape, - filters_bin_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding, - dilations); - - ConvolutionTest( - inputs_conv, - inputs_shape, - filters_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding, - dilations); -} - -NGRAPH_TEST(${BACKEND_NAME}, - bin_convolution_2D_1batch_1channel_strides_dilation_padding_pad_val_0) -{ - const Strides strides{2, 2}; - const Strides dilations{2, 2}; - - const CoordinateDiff padding_conv{0, 0}; - const Shape inputs_conv_shape{1, 1, 11, 11}; - const std::vector inputs_conv{ - -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,-1.0f, -1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f}; - - const CoordinateDiff padding_bin_conv{2, 2}; - const Shape inputs_bin_conv_shape{1, 1, 7, 7}; - const std::vector inputs_bin_conv{1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, - 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, - 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f}; - - const Shape filters_shape{1, 1, 3, 3}; - const std::vector filters_conv{-1.0f, 1.0f, 1.0f, - -1.0f, 1.0f, -1.0f, - 1.0f, 1.0f, -1.0f}; - const std::vector filters_bin_conv{0x6B, 0x00}; // 01101011 00000000 - - const Shape outputs_shape{1, 1, 4, 4}; - const std::vector outputs{1.0f, 1.0f, -1.0f, 1.0f, - 1.0f, -5.0f, -5.0f, 5.0f, - 3.0f, -1.0f, 3.0f, 3.0f, - -1.0f, -1.0f, 3.0f, -3.0f}; - - BinaryConvolutionTest( - inputs_bin_conv, - inputs_bin_conv_shape, - filters_bin_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding_bin_conv, - dilations); - - ConvolutionTest( - inputs_conv, - inputs_conv_shape, - filters_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding_conv, - dilations); -} - -NGRAPH_TEST(${BACKEND_NAME}, - bin_convolution_2D_1batch_1channel_strides_dilation_padding_pad_val_1) -{ - const Strides strides{2, 2}; - const Strides dilations{2, 2}; - const float pad_value = 1.0f; - - const CoordinateDiff padding_conv{0, 0}; - const Shape inputs_conv_shape{1, 1, 11, 11}; - const std::vector inputs_conv{ - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}; - - const CoordinateDiff padding_bin_conv{2, 2}; - const Shape inputs_bin_conv_shape{1, 1, 7, 7}; - const std::vector inputs_bin_conv{1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, - 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, - 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f}; - - const Shape filters_shape{1, 1, 3, 3}; - const std::vector filters_conv{-1.0f, 1.0f, 1.0f, - -1.0f, 1.0f, -1.0f, - 1.0f, 1.0f, -1.0f}; - const std::vector filters_bin_conv{0x6B, 0x00}; // 01101011 00000000 - - const Shape outputs_shape{1, 1, 4, 4}; - const std::vector outputs{3.0f, 3.0f, 1.0f, -1.0f, - -1.0f, -5.0f, -5.0f, 3.0f, - 1.0f, -1.0f, 3.0f, 1.0f, - -3.0f, 1.0f, 5.0f, -1.0f}; - - BinaryConvolutionTest( - inputs_bin_conv, - inputs_bin_conv_shape, - filters_bin_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding_bin_conv, - dilations, - pad_value); - - ConvolutionTest( - inputs_conv, - inputs_conv_shape, - filters_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding_conv, - dilations); -} - -NGRAPH_TEST(${BACKEND_NAME}, bin_convolution_2D_1batch_2channel) -{ - const Strides strides{1, 1}; - const CoordinateDiff padding{0, 0}; - const Strides dilations{1, 1}; - - const Shape inputs_shape{1, 2, 4, 4}; - const std::vector inputs_conv{ - // channel 1 - 1.0f, -1.0f, -1.0f, 1.0f, - 1.0f, 1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, -1.0f, 1.0f, - 1.0f, -1.0f, 1.0f, 1.0f, - // channel 2 - -1.0f, 1.0f, 1.0f, -1.0f, - -1.0f, -1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, -1.0f, - -1.0f, 1.0f, -1.0f, -1.0f}; - const std::vector inputs_bin_conv{ - // channel 1 - 1.0f, 0.0f, 0.0f, 1.0f, - 1.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f, - 1.0f, 0.0f, 1.0f, 1.0f, - // channel 2 - 0.0f, 1.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f}; - - const Shape filters_shape{1, 2, 3, 3}; - const std::vector filters_conv{ - // channel 1 - 1.0f, -1.0f, 1.0f, - -1.0f, 1.0f, -1.0f, - 1.0f, -1.0f, 1.0f, - // channel 2 - -1.0f, 1.0f, -1.0f, - 1.0f, -1.0f, 1.0f, - -1.0f, 1.0f, -1.0f}; - // 10101010 10101010 10000000 - const std::vector filters_bin_conv{0xAA, 0xAA, 0x80}; - - const Shape outputs_shape{1, 1, 2, 2}; - const std::vector outputs{2.0f, 2.0f, - 6.0f, -2.0f}; - - BinaryConvolutionTest( - inputs_bin_conv, - inputs_shape, - filters_bin_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding, - dilations); - - ConvolutionTest( - inputs_conv, - inputs_shape, - filters_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding, - dilations); -} - -NGRAPH_TEST(${BACKEND_NAME}, bin_convolution_2D_2batch_1channel) -{ - const Strides strides{1, 1}; - const CoordinateDiff padding{0, 0}; - const Strides dilations{1, 1}; - - const Shape inputs_shape{2, 1, 4, 4}; - const std::vector inputs_conv{ - // batch 1 - 1.0f, -1.0f, -1.0f, 1.0f, - 1.0f, 1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, -1.0f, 1.0f, - 1.0f, -1.0f, 1.0f, 1.0f, - // batch 2 - -1.0f, -1.0f, -1.0f, -1.0f, - 1.0f, 1.0f, 1.0f, -1.0f, - 1.0f, 1.0f, -1.0f, 1.0f, - 1.0f, -1.0f, 1.0f, -1.0f}; - const std::vector inputs_bin_conv{ - // batch 1 - 1.0f, 0.0f, 0.0f, 1.0f, - 1.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f, - 1.0f, 0.0f, 1.0f, 1.0f, - // batch 2 - 0.0f, 0.0f, 0.0f, 0.0f, - 1.0f, 1.0f, 1.0f, 0.0f, - 1.0f, 1.0f, 0.0f, 1.0f, - 1.0f, 0.0f, 1.0f, 0.0f}; - - const Shape filters_shape{1, 1, 3, 3}; - const std::vector filters_conv{1.0f, -1.0f, 1.0f, - -1.0f, 1.0f, -1.0f, - 1.0f, -1.0f, 1.0f}; - const std::vector filters_bin_conv{0xAA, 0x80}; // 10101010 10000000 - - const Shape outputs_shape{2, 1, 2, 2}; - const std::vector outputs{ - // batch 1 - 1.0f, 1.0f, - 3.0f, -1.0f, - // batch 2 - -3.0f, 3.0f, - 5.0f, -7.0f}; - - BinaryConvolutionTest( - inputs_bin_conv, - inputs_shape, - filters_bin_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding, - dilations); - - ConvolutionTest( - inputs_conv, - inputs_shape, - filters_conv, - filters_shape, - outputs, - outputs_shape, - strides, - padding, - dilations); -} -// clang-format on diff --git a/ngraph/test/backend/convolution_backprop.in.cpp b/ngraph/test/backend/convolution_backprop.in.cpp deleted file mode 100644 index cd483a7cbfa..00000000000 --- a/ngraph/test/backend/convolution_backprop.in.cpp +++ /dev/null @@ -1,1219 +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 "engines_util/test_case.hpp" -#include "engines_util/test_engines.hpp" -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "ngraph/runtime/tensor.hpp" -#include "runtime/backend.hpp" -#include "util/all_close.hpp" -#include "util/all_close_f.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}); - -static void ConvolutionBackpropTest(const std::vector& inputs, - const Shape inputs_shape, - const std::vector& filters, - const Shape filter_shape, - const std::vector& outputs, - const Shape outputs_shape, - const Strides& strides, - const CoordinateDiff& padding, - const Strides& dilations, - const CoordinateDiff& output_padding) { - const CoordinateDiff pads_begin{padding}; - const CoordinateDiff pads_end{padding}; - const op::PadType auto_pad{op::PadType::EXPLICIT}; - const CoordinateDiff out_padding{output_padding}; - - auto inputs_param = make_shared(element::f32, inputs_shape); - auto filters_param = make_shared(element::f32, filter_shape); - auto conv = make_shared(inputs_param, - filters_param, - strides, - pads_begin, - pads_end, - dilations, - auto_pad, - out_padding); - auto f = make_shared(conv, ParameterVector{inputs_param, filters_param}); - - auto test_case = test::TestCase(f); - test_case.add_input(inputs); - test_case.add_input(filters); - test_case.add_expected_output(outputs_shape, outputs); - test_case.run(); -} - -// --------------------- 1D convolution ------------------------------------------ -// clang-format off -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_1channel) -{ - const Strides strides{1}; - const CoordinateDiff padding{0}; - const Strides dilations{1}; - const CoordinateDiff output_padding{0}; - - const Shape inputs_shape{1, 1, 4}; - const std::vector inputs{5.0f, 6.0f, 7.0f, 2.0f}; - - const Shape filter_shape{1, 1, 3}; - const std::vector filters{2.0f, 0.0f, 1.0f}; - - const Shape outputs_shape{1, 1, 6}; - const std::vector outputs{10.0f, 12.0f, 19.0f, 10.0f, 7.0f, 2.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_1channel_padding) -{ - const Strides strides{1}; - const CoordinateDiff padding{1}; - const Strides dilations{1}; - const CoordinateDiff output_padding{0}; - - const Shape inputs_shape{1, 1, 4}; - const std::vector inputs{5.0f, 6.0f, 7.0f, 2.0f}; - - const Shape filter_shape{1, 1, 3}; - const std::vector filters{2.0f, 0.0f, 1.0f}; - - const Shape outputs_shape{1, 1, 4}; - const std::vector outputs{12.0f, 19.0f, 10.0f, 7.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_1channel_stride) -{ - const Strides strides{2}; - const CoordinateDiff padding{0}; - const Strides dilations{1}; - const CoordinateDiff output_padding{0}; - - const Shape inputs_shape{1, 1, 2}; - const std::vector inputs{5.0f, 7.0f}; - - const Shape filter_shape{1, 1, 3}; - const std::vector filters{2.0f, 0.0f, 1.0f}; - - const Shape outputs_shape{1, 1, 5}; - const std::vector outputs{10.0f, 0.0f, 19.0f, 0.0f, 7.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_1channel_output_padding) -{ - const Strides strides{1}; - const CoordinateDiff padding{1}; - const Strides dilations{1}; - const CoordinateDiff output_padding{1}; - - const Shape inputs_shape{1, 1, 4}; - const std::vector inputs{5.0f, 6.0f, 7.0f, 2.0f}; - - const Shape filter_shape{1, 1, 3}; - const std::vector filters{2.0f, 0.0f, 1.0f}; - - const Shape outputs_shape{1, 1, 5}; - const std::vector outputs{12.0f, 19.0f, 10.0f, 7.0f, 2.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_1channel_dilation) -{ - const Strides strides{1}; - const CoordinateDiff padding{0}; - const Strides dilations{2}; - const CoordinateDiff output_padding{0}; - - const Shape inputs_shape{1, 1, 3}; - const std::vector inputs{8.0f, 5.0f, 1.0f}; - - const Shape filter_shape{1, 1, 3}; - const std::vector filters{2.0f, 0.0f, 1.0f}; - - const Shape outputs_shape{1, 1, 7}; - const std::vector outputs{16.0f, 10.0f, 2.0f, 0.0f, 8.0f, 5.0f, 1.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_1channel_padding_stride_dilation) -{ - const Strides strides{2}; - const CoordinateDiff padding{2}; - const Strides dilations{2}; - const CoordinateDiff output_padding{0}; - - const Shape inputs_shape{1, 1, 4}; - const std::vector inputs{3.0f, 9.0f, 1.0f, 2.0f}; - - const Shape filter_shape{1, 1, 3}; - const std::vector filters{2.0f, 0.0f, 1.0f}; - - const Shape outputs_shape{1, 1, 7}; - const std::vector outputs{18.0f, 0.0f, 5.0f, 0.0f, 13.0f, 0.0f, 1.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_2channel) -{ - const Strides strides{1}; - const CoordinateDiff padding{0}; - const Strides dilations{1}; - const CoordinateDiff output_padding{0}; - - const Shape inputs_shape{1, 1, 2}; - const std::vector inputs{10.0f, 3.0f}; - - const Shape filter_shape{1, 2, 3}; - const std::vector filters{ - // channel 1 - 2.0f, 0.0f, 1.0f, - // channel 2 - 1.0f, 0.0f, 2.0f}; - - const Shape outputs_shape{1, 2, 4}; - const std::vector outputs{ - // channel 1 - 20.0f, 6.0f, 10.0f, 3.0f, - // channel 2 - 10.0f, 3.0f, 20.0f, 6.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_1batch_2filter) -{ - const Strides strides{1}; - const CoordinateDiff padding{0}; - const Strides dilations{1}; - const CoordinateDiff output_padding{0}; - - const Shape inputs_shape{1, 2, 2}; - const std::vector inputs{ - // channel 1 - 4.0f, 7.0f, - // channel 2 - 5.0f, 5.0f}; - - const Shape filter_shape{2, 1, 3}; - const std::vector filters{ - // filter 1 - 2.0f, 0.0f, 1.0f, - // filter 2 - 1.0f, 0.0f, 2.0f}; - - const Shape outputs_shape{1, 1, 4}; - const std::vector outputs{13.0f, 19.0f, 14.0f, 17.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_1D_2batch_1channel) -{ - const Strides strides{1}; - const CoordinateDiff padding{0}; - const Strides dilations{1}; - const CoordinateDiff output_padding{0}; - - const Shape inputs_shape{2, 1, 2}; - const std::vector inputs{ - // batch 1 - 1.0f, 3.0f, - // batch 2 - 2.0f, 2.0f}; - - const Shape filter_shape{1, 1, 3}; - const std::vector filters{2.0f, 0.0f, 1.0f}; - - const Shape outputs_shape{2, 1, 4}; - const std::vector outputs{ - // batch 1 - 2.0f, 6.0f, 1.0f, 3.0f, - // batch 2 - 4.0f, 4.0f, 2.0f, 2.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -// --------------------- 2D convolution ------------------------------------------ -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_1channel) -{ - const Strides strides{1, 1}; - const CoordinateDiff padding{0, 0}; - const Strides dilations{1, 1}; - const CoordinateDiff output_padding{0, 0}; - - const Shape inputs_shape{1, 1, 2, 2}; - const std::vector inputs{1.0f, 3.0f, - 7.0f, 5.0f}; - - const Shape filter_shape{1, 1, 3, 3}; - const std::vector filters{1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 3.0f, 2.0f, 1.0f}; - - const Shape outputs_shape{1, 1, 4, 4}; - const std::vector outputs{1.0f, 5.0f, 9.0f, 9.0f, - 7.0f, 20.0f, 34.0f, 15.0f, - 3.0f, 18.0f, 12.0f, 3.0f, - 21.0f, 29.0f, 17.0f, 5.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_1channel_output_padding) -{ - const Strides strides{1, 1}; - const CoordinateDiff padding{1, 1}; - const Strides dilations{1, 1}; - const CoordinateDiff output_padding{1, 1}; - - const Shape inputs_shape{1, 1, 2, 2}; - const std::vector inputs{1.0f, 3.0f, - 7.0f, 5.0f}; - - const Shape filter_shape{1, 1, 3, 3}; - const std::vector filters{1.0f, 2.0f, 3.0f, - 1.0f, 1.0f, 1.0f, - 3.0f, 2.0f, 1.0f}; - - const Shape outputs_shape{1, 1, 3, 3}; - const std::vector outputs{23.0f, 35.0f, 18.0f, - 23.0f, 19.0f, 8.0f, - 29.0f, 17.0f, 5.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_1channel_padding) -{ - const Strides strides{1, 1}; - const CoordinateDiff padding{1, 1}; - const Strides dilations{1, 1}; - const CoordinateDiff output_padding{0, 0}; - - const Shape inputs_shape{1, 1, 4, 4}; - const std::vector inputs{1.0f, 3.0f, 5.0f, 7.0f, - 7.0f, 5.0f, 3.0f, 1.0f, - 2.0f, 4.0f, 6.0f, 8.0f, - 8.0f, 6.0f, 4.0f, 2.0f}; - - const Shape filter_shape{1, 1, 3, 3}; - const std::vector filters{1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f}; - - const Shape outputs_shape{1, 1, 4, 4}; - const std::vector outputs{20.0f, 37.0f, 27.0f, 18.0f, - 22.0f, 40.0f, 60.0f, 52.0f, - 41.0f, 69.0f, 49.0f, 31.0f, - 18.0f, 26.0f, 34.0f, 22.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_1channel_stride) -{ - const Strides strides{2, 2}; - const CoordinateDiff padding{0, 0}; - const Strides dilations{1, 1}; - const CoordinateDiff output_padding{0, 0}; - - const Shape inputs_shape{1, 1, 2, 2}; - const std::vector inputs{2.0f, 5.0f, - 4.0f, 3.0f}; - - const Shape filter_shape{1, 1, 3, 3}; - const std::vector filters{1.0f, 2.0f, 3.0f, - 1.0f, 1.0f, 1.0f, - 3.0f, 2.0f, 1.0f}; - - const Shape outputs_shape{1, 1, 5, 5}; - const std::vector outputs{2.0f, 4.0f, 11.0f, 10.0f, 15.0f, - 2.0f, 2.0f, 7.0f, 5.0f, 5.0f, - 10.0f, 12.0f, 32.0f, 16.0f, 14.0f, - 4.0f, 4.0f, 7.0f, 3.0f, 3.0f, - 12.0f, 8.0f, 13.0f, 6.0f, 3.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_1channel_dilation) -{ - const Strides strides{1, 1}; - const CoordinateDiff padding{0, 0}; - const Strides dilations{2, 2}; - const CoordinateDiff output_padding{0, 0}; - - const Shape inputs_shape{1, 1, 2, 2}; - const std::vector inputs{2.0f, 3.0f, - 4.0f, 3.0f}; - - const Shape filter_shape{1, 1, 3, 3}; - const std::vector filters{1.0f, 2.0f, 3.0f, - 1.0f, 1.0f, 1.0f, - 3.0f, 2.0f, 1.0f}; - - const Shape outputs_shape{1, 1, 6, 6}; - const std::vector outputs{2.f, 3.f, 4.f, 6.f, 6.f, 9.f, - 4.f, 3.f, 8.f, 6.f, 12.f, 9.f, - 2.f, 3.f, 2.f, 3.f, 2.f, 3.f, - 4.f, 3.f, 4.f, 3.f, 4.f, 3.f, - 6.f, 9.f, 4.f, 6.f, 2.f, 3.f, - 12.f, 9.f, 8.f, 6.f, 4.f, 3.f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_1channel_padding_strides_dilation) -{ - const Strides strides{2, 2}; - const CoordinateDiff padding{2, 2}; - const Strides dilations{2, 2}; - const CoordinateDiff output_padding{0, 0}; - - const Shape inputs_shape{1, 1, 3, 3}; - const std::vector inputs{1.0f, 3.0f, 5.0f, - 7.0f, 5.0f, 3.0f, - 2.0f, 4.0f, 6.0f}; - - const Shape filter_shape{1, 1, 3, 3}; - const std::vector filters{1.0f, 2.0f, 3.0f, - 1.0f, 1.0f, 1.0f, - 3.0f, 2.0f, 1.0f}; - - const Shape outputs_shape{1, 1, 5, 5}; - const std::vector outputs{23.0f, 0.0f, 43.0f, 0.0f, 29.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 31.0f, 0.0f, 57.0f, 0.0f, 45.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 35.0f, 0.0f, 38.0f, 0.0f, 21.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_2channel) -{ - const Strides strides{1, 1}; - const CoordinateDiff padding{0, 0}; - const Strides dilations{1, 1}; - const CoordinateDiff output_padding{0, 0}; - - const Shape inputs_shape{1, 1, 2, 2}; - const std::vector inputs{1.0f, 3.0f, - 7.0f, 5.0f}; - - const Shape filter_shape{1, 2, 3, 3}; - const std::vector filters{ - // channel 1 - 5.0f, 3.0f, 5.0f, - 1.0f, 3.0f, 1.0f, - 4.0f, 2.0f, 4.0f, - // channel 2 - -5.0f, 3.0f, 5.0f, - 1.0f, -3.0f, 1.0f, - 4.0f, 2.0f, -4.0f}; - - const Shape outputs_shape{1, 2, 4, 4}; - const std::vector outputs{ - // channel 1 - 5.0f, 18.0f, 14.0f, 15.0f, - 36.0f, 52.0f, 60.0f, 28.0f, - 11.0f, 40.0f, 32.0f, 17.0f, - 28.0f, 34.0f, 38.0f, 20.0f, - // channel 2 - -5.0f, -12.0f, 14.0f, 15.0f, - -34.0f, -4.0f, 42.0f, 28.0f, - 11.0f, -2.0f, -6.0f, -7.0f, - 28.0f, 34.0f, -18.0f, -20.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_1batch_2filter) -{ - const Strides strides{1, 1}; - const CoordinateDiff padding{0, 0}; - const Strides dilations{1, 1}; - const CoordinateDiff output_padding{0, 0}; - - const Shape inputs_shape{1, 2, 2, 2}; - const std::vector inputs{ - // channel 1 - 1.0f, 3.0f, - 7.0f, 5.0f, - // channel 2 - 2.0f, 4.0f, - 8.0f, 6.0f}; - - const Shape filter_shape{2, 1, 3, 3}; - const std::vector filters{ - // channel 1 - 5.0f, 3.0f, 5.0f, - 1.0f, 3.0f, 1.0f, - 4.0f, 2.0f, 4.0f, - // channel 2 - -5.0f, 3.0f, 5.0f, - 1.0f, -3.0f, 1.0f, - 4.0f, 2.0f, -4.0f}; - - const Shape outputs_shape{1, 1, 4, 4}; - const std::vector outputs{ - -5.0f, 4.0f, 36.0f, 35.0f, - -2.0f, 44.0f, 108.0f, 62.0f, - 27.0f, 42.0f, 22.0f, 7.0f, - 60.0f, 74.0f, 18.0f, -4.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_2batch_2filter) -{ - const Strides strides{1, 1}; - const CoordinateDiff padding{0, 0}; - const Strides dilations{1, 1}; - const CoordinateDiff output_padding{0, 0}; - - const Shape inputs_shape{1, 2, 1, 1}; - const std::vector inputs{ - // channel 1 - 2.0f, - // channel 2 - 3.0f}; - - const Shape filter_shape{2, 2, 2, 2}; - const std::vector filters{ - // batch 0 - // channel 1 - 5.0f, 3.0f, - 1.0f, 3.0f, - // channel 2 - -5.0f, 3.0f, - 1.0f, -3.0f, - // batch 1 - // channel 1 - 5.0f, 3.0f, - 1.0f, 3.0f, - // channel 2 - -5.0f, 3.0f, - 1.0f, -3.0f}; - - const Shape outputs_shape{1, 2, 2, 2}; - const std::vector outputs{ - 25.0f, 15.0f, 5.0f, 15.0f, -25.0f, 15.0f, 5.0f, -15.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_2D_2batch_1channel) -{ - const Strides strides{1, 1}; - const CoordinateDiff padding{0, 0}; - const Strides dilations{1, 1}; - const CoordinateDiff output_padding{0, 0}; - - const Shape inputs_shape{2, 1, 2, 2}; - const std::vector inputs{ - // batch 1 - 1.0f, 3.0f, - 1.0f, 3.0f, - // batch 2 - -1.0f, 3.0f, - 1.0f, 3.0f}; - - const Shape filter_shape{1, 1, 3, 3}; - const std::vector filters{-5.0f, 3.0f, 5.0f, - 1.0f, -3.0f, 1.0f, - 4.0f, 2.0f, -4.0f}; - - const Shape outputs_shape{2, 1, 4, 4}; - const std::vector outputs{ - // batch 1 - -5.0f, -12.0f, 14.0f, 15.0f, - -4.0f, -12.0f, 6.0f, 18.0f, - 5.0f, 14.0f, -6.0f, -9.0f, - 4.0f, 14.0f, 2.0f, -12.0f, - // batch 2 - 5.0f, -18.0f, 4.0f, 15.0f, - -6.0f, -6.0f, 4.0f, 18.0f, - -3.0f, 10.0f, 2.0f, -9.0f, - 4.0f, 14.0f, 2.0f, -12.0f}; - - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -// --------------------- 3D convolution ------------------------------------------ -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_1channel) -{ - const Strides strides{1, 1, 1}; - const CoordinateDiff padding{0, 0, 0}; - const Strides dilations{1, 1, 1}; - const CoordinateDiff output_padding{0, 0, 0}; - - const Shape inputs_shape{1, 1, 2, 2, 2}; - const std::vector inputs{ - // depth: 1 - 15.0f, 3.0f, - 21.0f, 10.0f, - // depth: 2 - 10.0f, 13.0f, - 11.0f, 17.0f}; - - const Shape filter_shape{1, 1, 3, 3, 3}; - const std::vector filters{ - // depth: 1 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 2 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 3 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f}; - - const Shape outputs_shape{1, 1, 4, 4, 4}; - const std::vector outputs{ - // depth: 1 - 15.0f, 33.0f, 51.0f, 9.0f, - 21.0f, 67.0f, 86.0f, 30.0f, - 30.0f, 42.0f, 43.0f, 6.0f, - 42.0f, 41.0f, 52.0f, 20.0f, - // depth: 2 - 25.0f, 66.0f, 107.0f, 48.0f, - 32.0f, 116.0f, 166.0f, 81.0f, - 50.0f, 89.0f, 93.0f, 32.0f, - 64.0f, 86.0f, 91.0f, 54.0f, - // depth: 3 - 25.0f, 66.0f, 107.0f, 48.0f, - 32.0f, 116.0f, 166.0f, 81.0f, - 50.0f, 89.0f, 93.0f, 32.0f, - 64.0f, 86.0f, 91.0f, 54.0f, - // depth: 4 - 10.0f, 33.0f, 56.0f, 39.0f, - 11.0f, 49.0f, 80.0f, 51.0f, - 20.0f, 47.0f, 50.0f, 26.0f, - 22.0f, 45.0f, 39.0f, 34.0f - }; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_1channel_output_padding) -{ - const Strides strides{1, 1, 1}; - const CoordinateDiff padding{1, 1, 1}; - const Strides dilations{1, 1, 1}; - const CoordinateDiff output_padding{1, 1, 1}; - - const Shape inputs_shape{1, 1, 2, 2, 2}; - const std::vector inputs{ - // depth: 1 - 15.0f, 3.0f, - 21.0f, 10.0f, - // depth: 2 - 10.0f, 13.0f, - 11.0f, 17.0f}; - - const Shape filter_shape{1, 1, 3, 3, 3}; - const std::vector filters{ - // depth: 1 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 2 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 3 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f}; - - const Shape outputs_shape{1, 1, 3, 3, 3}; - const std::vector outputs{ - // depth: 1 - 116.0f, 166.0f, 81.0f, - 89.0f, 93.0f, 32.0f, - 86.0f, 91.0f, 54.0f, - // depth: 2 - 116.0f, 166.0f, 81.0f, - 89.0f, 93.0f, 32.0f, - 86.0f, 91.0f, 54.0f, - // depth: 3 - 49.0f, 80.0f, 51.0f, - 47.0f, 50.0f, 26.0f, - 45.0f, 39.0f, 34.0f - }; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_1channel_padding) -{ - const Strides strides{1, 1, 1}; - const CoordinateDiff padding{1, 1, 1}; - const Strides dilations{1, 1, 1}; - const CoordinateDiff output_padding{0, 0, 0}; - - const Shape inputs_shape{1, 1, 4, 4, 4}; - const std::vector inputs{ - // depth: 1 - 1.0f, 3.0f, 2.0f, 1.0f, - 1.0f, 3.0f, 3.0f, 1.0f, - 2.0f, 1.0f, 1.0f, 3.0f, - 3.0f, 2.0f, 3.0f, 3.0f, - // depth: 2 - 1.0f, 3.0f, 2.0f, 1.0f, - 1.0f, 3.0f, 3.0f, 1.0f, - 2.0f, 1.0f, 1.0f, 3.0f, - 3.0f, 2.0f, 3.0f, 3.0f, - // depth: 3 - 1.0f, 3.0f, 2.0f, 1.0f, - 1.0f, 3.0f, 3.0f, 1.0f, - 2.0f, 1.0f, 1.0f, 3.0f, - 3.0f, 2.0f, 3.0f, 3.0f, - // depth: 4 - 1.0f, 3.0f, 2.0f, 1.0f, - 1.0f, 3.0f, 3.0f, 1.0f, - 2.0f, 1.0f, 1.0f, 3.0f, - 3.0f, 2.0f, 3.0f, 3.0f - }; - - const Shape filter_shape{1, 1, 3, 3, 3}; - const std::vector filters{ - // depth: 1 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 2 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 3 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f}; - - const Shape outputs_shape{1, 1, 4, 4, 4}; - const std::vector outputs{ - // depth: 1 - 12.0f, 30.0f, 36.0f, 24.0f, - 26.0f, 42.0f, 42.0f, 30.0f, - 34.0f, 56.0f, 54.0f, 50.0f, - 14.0f, 18.0f, 24.0f, 16.0f, - // depth: 2 - 18.0f, 45.0f, 54.0f, 36.0f, - 39.0f, 63.0f, 63.0f, 45.0f, - 51.0f, 84.0f, 81.0f, 75.0f, - 21.0f, 27.0f, 36.0f, 24.0f, - // depth: 3 - 18.0f, 45.0f, 54.0f, 36.0f, - 39.0f, 63.0f, 63.0f, 45.0f, - 51.0f, 84.0f, 81.0f, 75.0f, - 21.0f, 27.0f, 36.0f, 24.0f, - // depth: 4 - 12.0f, 30.0f, 36.0f, 24.0f, - 26.0f, 42.0f, 42.0f, 30.0f, - 34.0f, 56.0f, 54.0f, 50.0f, - 14.0f, 18.0f, 24.0f, 16.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_1channel_stride) -{ - const Strides strides{2, 2, 2}; - const CoordinateDiff padding{0, 0, 0}; - const Strides dilations{1, 1, 1}; - const CoordinateDiff output_padding{0, 0, 0}; - - const Shape inputs_shape{1, 1, 2, 2, 2}; - const std::vector inputs{ - // depth: 1 - 15.0f, 3.0f, - 21.0f, 10.0f, - // depth: 2 - 10.0f, 13.0f, - 11.0f, 17.0f}; - - const Shape filter_shape{1, 1, 3, 3, 3}; - const std::vector filters{ - // depth: 1 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 2 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 3 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f}; - - const Shape outputs_shape{1, 1, 5, 5, 5}; - const std::vector outputs{ - // depth: 1 - 15.0f, 30.0f, 48.0f, 6.0f, 9.0f, - 0.0f, 15.0f, 0.0f, 3.0f, 0.0f, - 51.0f, 57.0f, 109.0f, 23.0f, 36.0f, - 0.0f, 21.0f, 0.0f, 10.0f, 0.0f, - 42.0f, 21.0f, 62.0f, 10.0f, 20.0f, - // depth: 2 - 15.0f, 30.0f, 48.0f, 6.0f, 9.0f, - 0.0f, 15.0f, 0.0f, 3.0f, 0.0f, - 51.0f, 57.0f, 109.0f, 23.0f, 36.0f, - 0.0f, 21.0f, 0.0f, 10.0f, 0.0f, - 42.0f, 21.0f, 62.0f, 10.0f, 20.0f, - // depth: 3 - 25.0f, 50.0f, 91.0f, 32.0f, 48.0f, - 0.0f, 25.0f, 0.0f, 16.0f, 0.0f, - 82.0f, 89.0f, 205.0f, 70.0f, 113.0f, - 0.0f, 32.0f, 0.0f, 27.0f, 0.0f, - 64.0f, 32.0f, 118.0f, 27.0f, 54.0f, - // depth: 4 - 10.0f, 20.0f, 43.0f, 26.0f, 39.0f, - 0.0f, 10.0f, 0.0f, 13.0f, 0.0f, - 31.0f, 32.0f, 96.0f, 47.0f, 77.0f, - 0.0f, 11.0f, 0.0f, 17.0f, 0.0f, - 22.0f, 11.0f, 56.0f, 17.0f, 34.0f, - // depth: 5 - 10.0f, 20.0f, 43.0f, 26.0f, 39.0f, - 0.0f, 10.0f, 0.0f, 13.0f, 0.0f, - 31.0f, 32.0f, 96.0f, 47.0f, 77.0f, - 0.0f, 11.0f, 0.0f, 17.0f, 0.0f, - 22.0f, 11.0f, 56.0f, 17.0f, 34.0f - }; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_1channel_padding_strides_dilation) -{ - const Strides strides{2, 2, 2}; - const CoordinateDiff padding{2, 2, 2}; - const Strides dilations{2, 2, 2}; - const CoordinateDiff output_padding{0, 0, 0}; - - const Shape inputs_shape{1, 1, 4, 4, 4}; - const std::vector inputs{ - // depth: 1 - 1.0f, 3.0f, 2.0f, 1.0f, - 1.0f, 3.0f, 3.0f, 1.0f, - 2.0f, 1.0f, 1.0f, 3.0f, - 3.0f, 2.0f, 3.0f, 3.0f, - // depth: 2 - 1.0f, 3.0f, 2.0f, 1.0f, - 1.0f, 3.0f, 3.0f, 1.0f, - 2.0f, 1.0f, 1.0f, 3.0f, - 3.0f, 2.0f, 3.0f, 3.0f, - // depth: 3 - 1.0f, 3.0f, 2.0f, 1.0f, - 1.0f, 3.0f, 3.0f, 1.0f, - 2.0f, 1.0f, 1.0f, 3.0f, - 3.0f, 2.0f, 3.0f, 3.0f, - // depth: 4 - 1.0f, 3.0f, 2.0f, 1.0f, - 1.0f, 3.0f, 3.0f, 1.0f, - 2.0f, 1.0f, 1.0f, 3.0f, - 3.0f, 2.0f, 3.0f, 3.0f - }; - - const Shape filter_shape{1, 1, 3, 3, 3}; - const std::vector filters{ - // depth: 1 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 2 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 3 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f}; - - const Shape outputs_shape{1, 1, 7, 7, 7}; - const std::vector outputs{ - // depth: 1 - 12.0f, 0.0f, 30.0f, 0.0f, 36.0f, 0.0f, 24.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 26.0f, 0.0f, 42.0f, 0.0f, 42.0f, 0.0f, 30.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 34.0f, 0.0f, 56.0f, 0.0f, 54.0f, 0.0f, 50.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 14.0f, 0.0f, 18.0f, 0.0f, 24.0f, 0.0f, 16.0f, - // depth: 2 - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - // depth: 3 - 18.0f, 0.0f, 45.0f, 0.0f, 54.0f, 0.0f, 36.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 39.0f, 0.0f, 63.0f, 0.0f, 63.0f, 0.0f, 45.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 51.0f, 0.0f, 84.0f, 0.0f, 81.0f, 0.0f, 75.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 21.0f, 0.0f, 27.0f, 0.0f, 36.0f, 0.0f, 24.0f, - // depth: 4 - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - // depth: 5 - 18.0f, 0.0f, 45.0f, 0.0f, 54.0f, 0.0f, 36.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 39.0f, 0.0f, 63.0f, 0.0f, 63.0f, 0.0f, 45.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 51.0f, 0.0f, 84.0f, 0.0f, 81.0f, 0.0f, 75.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 21.0f, 0.0f, 27.0f, 0.0f, 36.0f, 0.0f, 24.0f, - // depth: 6 - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - // depth: 7 - 12.0f, 0.0f, 30.0f, 0.0f, 36.0f, 0.0f, 24.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 26.0f, 0.0f, 42.0f, 0.0f, 42.0f, 0.0f, 30.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 34.0f, 0.0f, 56.0f, 0.0f, 54.0f, 0.0f, 50.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 14.0f, 0.0f, 18.0f, 0.0f, 24.0f, 0.0f, 16.0f - }; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_2channel) -{ - const Strides strides{1, 1, 1}; - const CoordinateDiff padding{0, 0, 0}; - const Strides dilations{1, 1, 1}; - const CoordinateDiff output_padding{0, 0, 0}; - - const Shape inputs_shape{1, 1, 2, 2, 2}; - const std::vector inputs{ - // depth: 1 - 1.0f, 8.0f, - 1.0f, 3.0f, - // depth: 2 - 1.0f, 7.0f, - 3.0f, 8.0f}; - - const Shape filter_shape{1, 2, 3, 3, 3}; - const std::vector filters{ - // -- channel 1 -- - // depth: 1 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 2 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 3 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // -- channel 2 -- - // depth: 1 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 2 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 3 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f - }; - - const Shape outputs_shape{1, 2, 4, 4, 4}; - const std::vector outputs{ - // -- channel 1 -- - // depth: 1 - 1.0f, 10.0f, 19.0f, 24.0f, - 1.0f, 6.0f, 17.0f, 9.0f, - 2.0f, 18.0f, 13.0f, 16.0f, - 2.0f, 7.0f, 5.0f, 6.0f, - // depth: 2 - 2.0f, 19.0f, 36.0f, 45.0f, - 4.0f, 21.0f, 49.0f, 33.0f, - 4.0f, 36.0f, 30.0f, 30.0f, - 8.0f, 26.0f, 19.0f, 22.0f, - // depth: 3 - 2.0f, 19.0f, 36.0f, 45.0f, - 4.0f, 21.0f, 49.0f, 33.0f, - 4.0f, 36.0f, 30.0f, 30.0f, - 8.0f, 26.0f, 19.0f, 22.0f, - // depth: 4 - 1.0f, 9.0f, 17.0f, 21.0f, - 3.0f, 15.0f, 32.0f, 24.0f, - 2.0f, 18.0f, 17.0f, 14.0f, - 6.0f, 19.0f, 14.0f, 16.0f, - // -- channel 2 -- - // depth: 1 - 1.0f, 10.0f, 19.0f, 24.0f, - 1.0f, 6.0f, 17.0f, 9.0f, - 2.0f, 18.0f, 13.0f, 16.0f, - 2.0f, 7.0f, 5.0f, 6.0f, - // depth: 2 - 2.0f, 19.0f, 36.0f, 45.0f, - 4.0f, 21.0f, 49.0f, 33.0f, - 4.0f, 36.0f, 30.0f, 30.0f, - 8.0f, 26.0f, 19.0f, 22.0f, - // depth: 3 - 2.0f, 19.0f, 36.0f, 45.0f, - 4.0f, 21.0f, 49.0f, 33.0f, - 4.0f, 36.0f, 30.0f, 30.0f, - 8.0f, 26.0f, 19.0f, 22.0f, - // depth: 4 - 1.0f, 9.0f, 17.0f, 21.0f, - 3.0f, 15.0f, 32.0f, 24.0f, - 2.0f, 18.0f, 17.0f, 14.0f, - 6.0f, 19.0f, 14.0f, 16.0f - }; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_1batch_2filter) -{ - const Strides strides{1, 1, 1}; - const CoordinateDiff padding{0, 0, 0}; - const Strides dilations{1, 1, 1}; - const CoordinateDiff output_padding{0, 0, 0}; - - const Shape inputs_shape{1, 2, 2, 2, 2}; - const std::vector inputs{ - // -- in 1 -- - // depth: 1 - 1.0f, 3.0f, - 2.0f, 5.0f, - // depth: 2 - 1.0f, 0.0f, - 3.0f, 6.0f, - // -- in 2 -- - // depth: 1 - 1.0f, 3.0f, - 2.0f, 5.0f, - // depth: 2 - 3.0f, 0.0f, - 1.0f, 8.0f}; - - const Shape filter_shape{2, 1, 3, 3, 3}; - const std::vector filters{ - // -- filter 1 -- - // depth: 1 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 2 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 3 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // -- filter 2 -- - // depth: 1 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 2 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 3 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f - }; - - const Shape outputs_shape{1, 1, 4, 4, 4}; - const std::vector outputs{ - // depth: 1 - 2.0f, 10.0f, 18.0f, 18.0f, - 4.0f, 20.0f, 38.0f, 30.0f, - 4.0f, 18.0f, 20.0f, 12.0f, - 8.0f, 24.0f, 18.0f, 20.0f, - // depth: 2 - 6.0f, 18.0f, 30.0f, 18.0f, - 8.0f, 46.0f, 78.0f, 72.0f, - 12.0f, 26.0f, 42.0f, 12.0f, - 16.0f, 56.0f, 40.0f, 48.0f, - // depth: 3 - 6.0f, 18.0f, 30.0f, 18.0f, - 8.0f, 46.0f, 78.0f, 72.0f, - 12.0f, 26.0f, 42.0f, 12.0f, - 16.0f, 56.0f, 40.0f, 48.0f, - // depth: 4 - 4.0f, 8.0f, 12.0f, 0.0f, - 4.0f, 26.0f, 40.0f, 42.0f, - 8.0f, 8.0f, 22.0f, 0.0f, - 8.0f, 32.0f, 22.0f, 28.0f - }; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} - -NGRAPH_TEST(${BACKEND_NAME}, convolution_backprop_3D_2batch_1channel) -{ - const Strides strides{1, 1, 1}; - const CoordinateDiff padding{0, 0, 0}; - const Strides dilations{1, 1, 1}; - const CoordinateDiff output_padding{0, 0, 0}; - - const Shape inputs_shape{2, 1, 2, 2, 2}; - const std::vector inputs{ - // -- batch 1 -- - // depth: 1 - 1.0f, 3.0f, - 2.0f, 5.0f, - // depth: 2 - 1.0f, 0.0f, - 6.0f, 4.0f, - // -- batch 2 -- - // depth: 1 - 1.0f, 5.0f, - 2.0f, 8.0f, - // depth: 2 - 2.0f, 1.0f, - 0.0f, 5.0f}; - const Shape filter_shape{1, 1, 3, 3, 3}; - const std::vector filters{ - // depth: 1 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 2 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f, - // depth: 3 - 1.0f, 2.0f, 3.0f, - 0.0f, 1.0f, 0.0f, - 2.0f, 1.0f, 2.0f}; - - const Shape outputs_shape{2, 1, 4, 4, 4}; - const std::vector outputs{ - // -- batch 1 -- - // depth: 1 - 1.0f, 5.0f, 9.0f, 9.0f, - 2.0f, 10.0f, 19.0f, 15.0f, - 2.0f, 9.0f, 10.0f, 6.0f, - 4.0f, 12.0f, 9.0f, 10.0f, - // depth: 2 - 2.0f, 7.0f, 12.0f, 9.0f, - 8.0f, 27.0f, 45.0f, 27.0f, - 4.0f, 16.0f, 16.0f, 6.0f, - 16.0f, 26.0f, 25.0f, 18.0f, - // depth: 3 - 2.0f, 7.0f, 12.0f, 9.0f, - 8.0f, 27.0f, 45.0f, 27.0f, - 4.0f, 16.0f, 16.0f, 6.0f, - 16.0f, 26.0f, 25.0f, 18.0f, - // depth: 4 - 1.0f, 2.0f, 3.0f, 0.0f, - 6.0f, 17.0f, 26.0f, 12.0f, - 2.0f, 7.0f, 6.0f, 0.0f, - 12.0f, 14.0f, 16.0f, 8.0f, - // -- batch 2 -- - // depth: 1 - 1.0f, 7.0f, 13.0f, 15.0f, - 2.0f, 13.0f, 27.0f, 24.0f, - 2.0f, 13.0f, 15.0f, 10.0f, - 4.0f, 18.0f, 12.0f, 16.0f, - // depth: 2 - 3.0f, 12.0f, 21.0f, 18.0f, - 2.0f, 20.0f, 38.0f, 39.0f, - 6.0f, 17.0f, 25.0f, 12.0f, - 4.0f, 28.0f, 17.0f, 26.0f, - // depth: 3 - 3.0f, 12.0f, 21.0f, 18.0f, - 2.0f, 20.0f, 38.0f, 39.0f, - 6.0f, 17.0f, 25.0f, 12.0f, - 4.0f, 28.0f, 17.0f, 26.0f, - // depth: 4 - 2.0f, 5.0f, 8.0f, 3.0f, - 0.0f, 7.0f, 11.0f, 15.0f, - 4.0f, 4.0f, 10.0f, 2.0f, - 0.0f, 10.0f, 5.0f, 10.0f}; - - ConvolutionBackpropTest(inputs, inputs_shape, filters, filter_shape, outputs, outputs_shape, - strides, padding, dilations, output_padding); -} diff --git a/ngraph/test/visitors/op/binary_convolution.cpp b/ngraph/test/visitors/op/binary_convolution.cpp new file mode 100644 index 00000000000..77df62cb512 --- /dev/null +++ b/ngraph/test/visitors/op/binary_convolution.cpp @@ -0,0 +1,57 @@ +// 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/opset1.hpp" +#include "ngraph/opsets/opset3.hpp" +#include "ngraph/opsets/opset4.hpp" +#include "ngraph/opsets/opset5.hpp" +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; +using ngraph::test::ValueMap; + +TEST(attributes, bin_convolution) { + NodeBuilder::get_ops().register_factory(); + const PartialShape data_batch_shape{1, 1, 5, 5}; + const PartialShape filters_shape{1, 1, 3, 3}; + Strides strides{1, 1}; + CoordinateDiff pads_begin{0, 0}; + CoordinateDiff pads_end{0, 0}; + Strides dilations{1, 1}; + const auto mode = op::v1::BinaryConvolution::BinaryConvolutionMode::XNOR_POPCOUNT; + const float pad_value = 1.0f; + const auto auto_pad = op::PadType::SAME_LOWER; + + auto data_batch = make_shared(element::f32, data_batch_shape); + auto filters = make_shared(element::u1, filters_shape); + + auto conv = make_shared(data_batch, + filters, + strides, + pads_begin, + pads_end, + dilations, + mode, + pad_value, + auto_pad); + NodeBuilder builder(conv); + auto g_convolution = ov::as_type_ptr(builder.create()); + + // attribute count + const auto expected_attr_count = 7; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); + + EXPECT_EQ(g_convolution->get_strides(), conv->get_strides()); + EXPECT_EQ(g_convolution->get_pads_begin(), conv->get_pads_begin()); + EXPECT_EQ(g_convolution->get_pads_end(), conv->get_pads_end()); + EXPECT_EQ(g_convolution->get_dilations(), conv->get_dilations()); + EXPECT_EQ(g_convolution->get_auto_pad(), conv->get_auto_pad()); + EXPECT_EQ(g_convolution->get_mode(), conv->get_mode()); + EXPECT_EQ(g_convolution->get_pad_value(), conv->get_pad_value()); +}