Compute Library
 21.02
SubTensorInfo.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 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  */
26 #include "arm_compute/core/Types.h"
28 #include "tests/framework/Macros.h"
30 #include "utils/TypePrinter.h"
31 
32 namespace arm_compute
33 {
34 namespace test
35 {
36 namespace validation
37 {
38 TEST_SUITE(UNIT)
39 TEST_SUITE(SubTensorInfo)
40 
41 /** Validate sub-tensor creation
42  *
43  * Test performed:
44  *
45  * - Negative testing on X indexing
46  * - Negative testing on Y indexing
47  * - Positive testing by indexing on X,Y indexing
48  * */
49 TEST_CASE(SubTensorCreation, framework::DatasetMode::ALL)
50 {
51  // Create tensor info
53 
54  // Negative testing on X
57 
58  // Negative testing on Y
61 
62  // Positive testing on XY indexing
64 }
65 
66 /** Validate when extending padding on sub-tensor
67  *
68  * Tests performed:
69  * - A) Extend padding when SubTensor XY does not match parent tensor should fail
70  * B) Extend with zero padding when SubTensor XY does not match parent tensor should succeed
71  * - C) Extend padding when SubTensor XY matches parent tensor should succeed
72  */
73 TEST_CASE(SubTensorPaddingExpansion, framework::DatasetMode::ALL)
74 {
75  // Test A
76  {
77  TensorInfo tensor_info(TensorShape(23U, 17U, 3U), 1, DataType::F32);
78  SubTensorInfo sub_tensor_info(&tensor_info, TensorShape(4U, 3U, 2U), Coordinates(5, 2, 1));
80  }
81 
82  // Test B
83  {
84  TensorInfo tensor_info(TensorShape(23U, 17U, 3U), 1, DataType::F32);
85  SubTensorInfo sub_tensor_info(&tensor_info, TensorShape(4U, 3U, 1U), Coordinates(5, 2, 1));
88  }
89 
90  // Test C
91  {
92  TensorInfo tensor_info(TensorShape(23U, 17U, 3U), 1, DataType::F32);
93  SubTensorInfo sub_tensor_info(&tensor_info, TensorShape(23U, 17U, 1U), Coordinates(0, 0, 1));
97  }
98 }
99 
100 TEST_SUITE_END() // SubTensorInfo
102 } // namespace validation
103 } // namespace test
104 } // namespace arm_compute
unsigned int top
top of the border
Definition: Types.h:375
Shape of a tensor.
Definition: TensorShape.h:39
#define ARM_COMPUTE_EXPECT_NO_THROW(X, LEVEL)
Definition: Asserts.h:138
bool extend_padding(const PaddingSize &padding) override
Update the offset to the first element, the strides and the total size.
Container for 2D border size.
Definition: Types.h:273
1 channel, 1 F32 per channel
ARM_COMPUTE_EXPECT(has_error==expected, framework::LogLevel::ERRORS)
PaddingSize padding() const override
Padding of tensor.
Definition: TensorInfo.h:282
#define ARM_COMPUTE_EXPECT_THROW(X, LEVEL)
Definition: Asserts.h:156
Store the sub tensor's metadata.
Definition: SubTensorInfo.h:41
Copyright (c) 2017-2021 Arm Limited.
DatasetMode
Possible dataset modes.
Definition: DatasetModes.h:40
TEST_SUITE_END() FIXTURE_DATA_TEST_CASE(RunSmall
[CLActivationLayer Test snippet]
Coordinates of an item.
Definition: Coordinates.h:37
TEST_SUITE(U8_to_S8) FIXTURE_DATA_TEST_CASE(RunSmall
unsigned int right
right of the border
Definition: Types.h:376
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
constexpr bool uniform() const
Check if the border is the same size on all sides.
Definition: Types.h:306
Store the tensor's metadata.
Definition: TensorInfo.h:45
TEST_CASE(FusedActivation, framework::DatasetMode::ALL)
Validate fused activation expecting the following behaviours: