X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=documentation%2F_n_e_o_n_2_deconvolution_layer_8cpp_source.xhtml;h=5a695e6b0fbebaff15f2a06dd0c803151e045e1d;hb=HEAD;hp=b7ea4dc6b4064f11034967409144e8590395be32;hpb=c3f34a43ffb5d52ee4a4e9f7b1bf4c6c002aeebb;p=platform%2Fupstream%2Farmcl.git diff --git a/documentation/_n_e_o_n_2_deconvolution_layer_8cpp_source.xhtml b/documentation/_n_e_o_n_2_deconvolution_layer_8cpp_source.xhtml index b7ea4dc..5a695e6 100644 --- a/documentation/_n_e_o_n_2_deconvolution_layer_8cpp_source.xhtml +++ b/documentation/_n_e_o_n_2_deconvolution_layer_8cpp_source.xhtml @@ -40,7 +40,7 @@
Compute Library -  18.03 +  18.05
@@ -117,30 +117,52 @@ $(document).ready(function(){initNavTree('_n_e_o_n_2_deconvolution_layer_8cpp_so
DeconvolutionLayer.cpp
-Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2018 ARM Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "arm_compute/core/Types.h"
28 #include "tests/NEON/Accessor.h"
32 #include "tests/framework/Macros.h"
36 
37 namespace arm_compute
38 {
39 namespace test
40 {
41 namespace validation
42 {
43 namespace
44 {
45 constexpr AbsoluteTolerance<float> tolerance_fp32(0.001f);
47 const auto data4x4 = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 4) * framework::dataset::make("StrideY", 1, 4) * framework::dataset::make("PadX", 0, 3)
48  * framework::dataset::make("PadY", 0, 3) * framework::dataset::make("ax", 0) * framework::dataset::make("ay", 0) * framework::dataset::make("NumKernels", { 1, 3 });
49 
50 const auto data3x3 = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 4) * framework::dataset::make("StrideY", 1, 4) * framework::dataset::make("PadX", 0, 2)
51  * framework::dataset::make("PadY", 0, 2) * framework::dataset::make("ax", 0) * framework::dataset::make("ay", 0) * framework::dataset::make("NumKernels", { 1, 3 });
52 
53 const auto data1x1 = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 4) * framework::dataset::make("StrideY", 1, 4) * framework::dataset::make("PadX", 0, 1)
54  * framework::dataset::make("PadY", 0, 1) * framework::dataset::make("ax", 0) * framework::dataset::make("ay", 0) * framework::dataset::make("NumKernels", { 1, 3 });
55 
56 } // namespace
57 
58 TEST_SUITE(NEON)
59 TEST_SUITE(DeconvolutionLayer)
60 
61 template <typename T>
63 
64 template <typename T>
65 using NEDeconvolutionLayerFixture3x3 = DeconvolutionValidationFixture<Tensor, Accessor, NEDeconvolutionLayer, T, 3, 3>;
66 
67 template <typename T>
68 using NEDeconvolutionLayerFixture1x1 = DeconvolutionValidationFixture<Tensor, Accessor, NEDeconvolutionLayer, T, 1, 1>;
69 
70 TEST_SUITE(Float)
71 
72 TEST_SUITE(FP32)
73 TEST_SUITE(W4x4)
74 
75 FIXTURE_DATA_TEST_CASE(Run, NEDeconvolutionLayerFixture4x4<float>, framework::DatasetMode::ALL, combine(data4x4, framework::dataset::make("DataType", DataType::F32)))
76 {
77  // Validate output
78  validate(Accessor(_target), _reference, tolerance_fp32);
79 }
81 
82 TEST_SUITE(W3x3)
83 
84 FIXTURE_DATA_TEST_CASE(Run, NEDeconvolutionLayerFixture3x3<float>, framework::DatasetMode::ALL, combine(data3x3, framework::dataset::make("DataType", DataType::F32)))
85 {
86  // Validate output
87  validate(Accessor(_target), _reference, tolerance_fp32);
88 }
90 
91 TEST_SUITE(W1x1)
92 FIXTURE_DATA_TEST_CASE(Run, NEDeconvolutionLayerFixture1x1<float>, framework::DatasetMode::ALL, combine(data1x1, framework::dataset::make("DataType", DataType::F32)))
93 {
94  // Validate output
95  validate(Accessor(_target), _reference, tolerance_fp32);
96 }
98 
101 
104 } // namespace validation
105 } // namespace test
106 } // namespace arm_compute
-
Function to run the deconvolution layer.
- +Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2018 ARM Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "arm_compute/core/Types.h"
28 #include "tests/NEON/Accessor.h"
30 #include "tests/datasets/ShapeDatasets.h"
32 #include "tests/framework/Macros.h"
35 #include "tests/validation/fixtures/DeconvolutionLayerFixture.h"
36 
37 namespace arm_compute
38 {
39 namespace test
40 {
41 namespace validation
42 {
43 namespace
44 {
45 constexpr AbsoluteTolerance<float> tolerance_fp32(0.001f);
47 const auto data4x4 = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 4) * framework::dataset::make("StrideY", 1, 4) * framework::dataset::make("PadX", 0, 3)
48  * framework::dataset::make("PadY", 0, 3) * framework::dataset::make("ax", 0) * framework::dataset::make("ay", 0) * framework::dataset::make("NumKernels", { 1, 3 });
49 
50 const auto data3x3 = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 4) * framework::dataset::make("StrideY", 1, 4) * framework::dataset::make("PadX", 0, 2)
51  * framework::dataset::make("PadY", 0, 2) * framework::dataset::make("ax", 0) * framework::dataset::make("ay", 0) * framework::dataset::make("NumKernels", { 1, 3 });
52 
53 const auto data1x1 = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 4) * framework::dataset::make("StrideY", 1, 4) * framework::dataset::make("PadX", 0, 1)
54  * framework::dataset::make("PadY", 0, 1) * framework::dataset::make("ax", 0) * framework::dataset::make("ay", 0) * framework::dataset::make("NumKernels", { 1, 3 });
55 
56 } // namespace
57 
58 TEST_SUITE(NEON)
59 TEST_SUITE(DeconvolutionLayer)
60 
61 DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, (combine(datasets::SmallDeconvolutionShapes(), framework::dataset::make("DataType", DataType::F32))),
62  input_shape, data_type)
63 {
64  // Create shapes
65  const unsigned int kernel_size_x = 3;
66  const unsigned int kernel_size_y = 3;
67  const unsigned int num_kernels = 1;
68  const TensorShape weights_shape(kernel_size_x, kernel_size_y, input_shape.z(), num_kernels);
69  const TensorShape bias_shape(num_kernels);
70  auto out_dim = deconvolution_output_dimensions(input_shape.x(), input_shape.y(), kernel_size_x, kernel_size_y, 1, 1, 0, 0, 1, 1);
71  TensorShape output_shape = deconvolution_output_shape(out_dim, input_shape, weights_shape);
72 
73  // Create tensors
74  Tensor src = create_tensor<Tensor>(input_shape, data_type, 1);
75  Tensor weights = create_tensor<Tensor>(weights_shape, data_type, 1);
76  Tensor bias = create_tensor<Tensor>(bias_shape, data_type, 1);
77  Tensor dst = create_tensor<Tensor>(output_shape, data_type, 1);
78 
79  ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
80  ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS);
81  ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
82  ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
83 
84  // Create and configure function
85  NEDeconvolutionLayer deconv;
86  deconv.configure(&src, &weights, &bias, &dst, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), 0, 0);
87 
88  // Validate valid region
89  const ValidRegion src_valid_region = shape_to_valid_region(input_shape);
90  const ValidRegion weights_valid_region = shape_to_valid_region(weights_shape);
91  const ValidRegion bias_valid_region = shape_to_valid_region(bias_shape);
92  const ValidRegion dst_valid_region = shape_to_valid_region(output_shape);
93 
94  validate(src.info()->valid_region(), src_valid_region);
95  validate(weights.info()->valid_region(), weights_valid_region);
96  validate(bias.info()->valid_region(), bias_valid_region);
97  validate(dst.info()->valid_region(), dst_valid_region);
98 }
99 
100 // *INDENT-OFF*
101 // clang-format off
103  framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Mismatching data type
104  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 0), // Invalid weights shape
105  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QS8, 4), // Non supported data type
106  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, 11), // Invalid bias shape
107  TensorInfo(TensorShape(13U, 11U, 4U, 3U), 1, DataType::F32, 0), // Window shrink
108  TensorInfo(TensorShape(32U, 16U, 2U), 1, DataType::F32, 0),
109  }),
110  framework::dataset::make("WeightsInfo", { TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F16, 0),
111  TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32, 0),
112  TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::QS8, 5),
113  TensorInfo(TensorShape(3U, 2U, 2U, 2U), 1, DataType::F32, 11),
114  TensorInfo(TensorShape(3U, 3U, 4U), 1, DataType::F32, 0),
115  TensorInfo(TensorShape(1U, 1U, 2U, 4U), 1, DataType::F32, 0),
116  })),
117  framework::dataset::make("BiasInfo", { TensorInfo(TensorShape(1U), 1, DataType::F16, 0),
118  TensorInfo(TensorShape(1U), 1, DataType::F32, 0),
119  TensorInfo(TensorShape(1U), 1, DataType::F32, 5),
120  TensorInfo(TensorShape(25U, 11U), 1, DataType::F32, 11),
121  TensorInfo(TensorShape(1U), 1, DataType::F32, 0),
122  TensorInfo(TensorShape(4U), 1, DataType::F32, 0),
123  })),
124  framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F16, 0),
125  TensorInfo(TensorShape(25U, 10U, 2U), 1, DataType::F32, 0),
126  TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32, 5),
127  TensorInfo(TensorShape(13U, 13U, 2U), 1, DataType::F32, 0),
128  TensorInfo(TensorShape(11U, 9U, 1U, 3U), 1, DataType::F32, 0),
129  TensorInfo(TensorShape(32U, 16U, 4U), 1, DataType::F32, 0),
130  })),
131  framework::dataset::make("PadStrideInfo", { PadStrideInfo(1, 1, 0, 0),
132  PadStrideInfo(1, 1, 0, 0),
133  PadStrideInfo(1, 1, 0, 0),
134  PadStrideInfo(1, 1, 0, 0),
135  PadStrideInfo(1, 1, 1, 1),
136  PadStrideInfo(1, 1, 0, 0),
137  })),
138  framework::dataset::make("ax", { 1U,
139  1U,
140  1U,
141  1U,
142  0U,
143  0U,
144  })),
145  framework::dataset::make("ay", { 1U,
146  1U,
147  1U,
148  1U,
149  0U,
150  0U,
151  })),
152  framework::dataset::make("Expected", { false, false, false, false, false, true })),
153  input_info, weights_info, bias_info, output_info, pad_info, ax, ay, expected)
154 {
155  bool is_valid = bool(NEDeconvolutionLayer::validate(&input_info.clone()->set_is_resizable(false), &weights_info.clone()->set_is_resizable(false), &bias_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), pad_info, ax, ay));
157 }
158 // clang-format on
159 // *INDENT-ON*
160 
161 template <typename T>
162 using NEDeconvolutionLayerFixture4x4 = DeconvolutionValidationFixture<Tensor, Accessor, NEDeconvolutionLayer, T, 4, 4>;
163 
164 template <typename T>
165 using NEDeconvolutionLayerFixture3x3 = DeconvolutionValidationFixture<Tensor, Accessor, NEDeconvolutionLayer, T, 3, 3>;
166 
167 template <typename T>
168 using NEDeconvolutionLayerFixture1x1 = DeconvolutionValidationFixture<Tensor, Accessor, NEDeconvolutionLayer, T, 1, 1>;
169 
170 TEST_SUITE(Float)
171 
172 TEST_SUITE(FP32)
173 TEST_SUITE(W4x4)
174 
175 FIXTURE_DATA_TEST_CASE(Run, NEDeconvolutionLayerFixture4x4<float>, framework::DatasetMode::ALL, combine(data4x4, framework::dataset::make("DataType", DataType::F32)))
176 {
177  // Validate output
178  validate(Accessor(_target), _reference, tolerance_fp32);
179 }
181 
182 TEST_SUITE(W3x3)
183 
184 FIXTURE_DATA_TEST_CASE(Run, NEDeconvolutionLayerFixture3x3<float>, framework::DatasetMode::ALL, combine(data3x3, framework::dataset::make("DataType", DataType::F32)))
185 {
186  // Validate output
187  validate(Accessor(_target), _reference, tolerance_fp32);
188 }
190 
191 TEST_SUITE(W1x1)
192 FIXTURE_DATA_TEST_CASE(Run, NEDeconvolutionLayerFixture1x1<float>, framework::DatasetMode::ALL, combine(data1x1, framework::dataset::make("DataType", DataType::F32)))
193 {
194  // Validate output
195  validate(Accessor(_target), _reference, tolerance_fp32);
196 }
198 
201 
204 } // namespace validation
205 } // namespace test
206 } // namespace arm_compute
+
const std::pair< unsigned int, unsigned int > deconvolution_output_dimensions(unsigned int in_width, unsigned int in_height, unsigned int kernel_width, unsigned int kernel_height, unsigned int padx, unsigned int pady, unsigned int inner_border_right, unsigned int inner_border_top, unsigned int stride_x, unsigned int stride_y)
Returns expected width and height of the deconvolution&#39;s output tensor.
+
TensorShape deconvolution_output_shape(const std::pair< unsigned int, unsigned int > &out_dims, TensorShape input, TensorShape weights)
Returns expected shape for the deconvolution output tensor.
+
quantized, symmetric fixed-point 8-bit number
+ + +
DeconvolutionValidationFixture< Tensor, Accessor, NEDeconvolutionLayer, T, 3, 3 > NEDeconvolutionLayerFixture3x3
+ - -
std::enable_if< is_container< T >::value, ContainerDataset< T > >::type make(std::string name, T &&values)
Helper function to create a ContainerDataset.
+
1 channel, 1 F32 per channel
+ +
std::enable_if< is_container< T >::value, ContainerDataset< T > >::type make(std::string name, T &&values)
Helper function to create a ContainerDataset.
This file contains all available output stages for GEMMLowp on OpenCL.
- +
1 channel, 1 F16 per channel
#define TEST_SUITE(SUITE_NAME)
Definition: Macros.h:34
+ +
DeconvolutionValidationFixture< Tensor, Accessor, NEDeconvolutionLayer, T, 1, 1 > NEDeconvolutionLayerFixture1x1
FIXTURE_DATA_TEST_CASE(RunSmall, CLAbsoluteDifferenceFixture< uint8_t >, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), AbsoluteDifferenceU8Dataset))
validate(dst.info() ->valid_region(), dst_valid_region)
Accessor implementation for Tensor objects.
Definition: Accessor.h:35
DatasetMode
Possible dataset modes.
Definition: DatasetModes.h:40
+ -
Basic implementation of the tensor interface.
Definition: Tensor.h:37
+ + + + +
DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), AbsoluteDifferenceU8Dataset), shape, data_type0, data_type1, output_data_type)
TEST_SUITE_END() DATA_TEST_CASE(Configuration
+
const ValidRegion dst_valid_region
+
ARM_COMPUTE_EXPECT(src.info() ->is_resizable(), framework::LogLevel::ERRORS)
+ +
static Status validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *bias, const ITensorInfo *output, const PadStrideInfo &info, unsigned int inner_border_right, unsigned int inner_border_top)
Static function to check if given info will lead to a valid configuration of NEDeconvolutionLayer.
combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType",{DataType::U8, DataType::S16})), datasets::BorderModes()), framework::dataset::make("filter_size",{5}))
+ +
DeconvolutionValidationFixture< Tensor, Accessor, NEDeconvolutionLayer, T, 4, 4 > NEDeconvolutionLayerFixture4x4
DataType
Available data types.
Definition: Types.h:72
+
zip(zip(zip(framework::dataset::make("InputInfo",{TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::F16), TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::QASYMM8), TensorInfo(TensorShape(5U, 5U, 5U, 3U), 1, DataType::F32), TensorInfo(TensorShape(3U, 3U), 1, DataType::F32), TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::F32), TensorInfo(TensorShape(3U, 3U, 37U, 2U), 1, DataType::F32), TensorInfo(TensorShape(3U, 3U, 37U, 22U), 1, DataType::F32)}), framework::dataset::make("OutputInfo",{TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F16), TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::QASYMM8), TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F32), TensorInfo(TensorShape(1U, 1U, 16U), 1, DataType::F32), TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F32), TensorInfo(TensorShape(2U, 37U, 16U), 1, DataType::F32), TensorInfo(TensorShape(22U, 37U, 36U), 1, DataType::F32)})), framework::dataset::make("WinogradInfo",{WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(), PadStrideInfo(), DataLayout::NCHW), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(), PadStrideInfo(), DataLayout::NCHW), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(), PadStrideInfo(), DataLayout::NCHW), WinogradInfo(Size2D(3U, 3U), Size2D(3U, 3U), Size2D(), PadStrideInfo(), DataLayout::NCHW), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(), PadStrideInfo(), DataLayout::NCHW), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(), PadStrideInfo(), DataLayout::NCHW), WinogradInfo(Size2D(4U, 4U), Size2D(3U, 3U), Size2D(), PadStrideInfo(), DataLayout::NCHW)})), framework::dataset::make("Expected",{false, false, false, false, true, true, true}))
+
convolution configure & src
+
ValidRegion shape_to_valid_region(const TensorShape &a_shape, bool border_undefined=false, BorderSize border_size=BorderSize(0))
Create a valid region based on tensor shape, border mode and border size.
Definition: Utils.h:222
@@ -148,7 +170,7 @@ $(document).ready(function(){initNavTree('_n_e_o_n_2_deconvolution_layer_8cpp_so