Compute Library  18.05
TensorShape.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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 "tests/framework/Macros.h"
27 
28 namespace arm_compute
29 {
30 namespace test
31 {
32 namespace validation
33 {
34 TEST_SUITE(UNIT)
35 TEST_SUITE(TensorShapeValidation)
36 
37 // *INDENT-OFF*
38 // clang-format off
39 DATA_TEST_CASE(Construction, framework::DatasetMode::ALL, zip(zip(
40  framework::dataset::make("TensorShape", {
41  TensorShape{},
42  TensorShape{ 1U },
43  TensorShape{ 2U },
44  TensorShape{ 2U, 3U },
45  TensorShape{ 2U, 3U, 5U },
46  TensorShape{ 2U, 3U, 5U, 7U },
47  TensorShape{ 2U, 3U, 5U, 7U, 11U },
48  TensorShape{ 2U, 3U, 5U, 7U, 11U, 13U }}),
49  framework::dataset::make("NumDimensions", { 0U, 1U, 1U, 2U, 3U, 4U, 5U, 6U })),
50  framework::dataset::make("TotalSize", { 0U, 1U, 2U, 6U, 30U, 210U, 2310U, 30030U })),
51  shape, num_dimensions, total_size)
52 {
53  ARM_COMPUTE_EXPECT(shape.num_dimensions() == num_dimensions, framework::LogLevel::ERRORS);
54  ARM_COMPUTE_EXPECT(shape.total_size() == total_size, framework::LogLevel::ERRORS);
55 }
56 // clang-format on
57 // *INDENT-ON*
58 
59 DATA_TEST_CASE(SetEmpty, framework::DatasetMode::ALL, framework::dataset::make("Dimension", { 0U, 1U, 2U, 3U, 4U, 5U }), dimension)
60 {
62 
63  shape.set(dimension, 10);
64 
67 }
68 
69 TEST_SUITE_END() // TensorShapeValidation
71 } // namespace validation
72 } // namespace test
73 } // namespace arm_compute
Shape of a tensor.
Definition: TensorShape.h:39
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.
#define TEST_SUITE(SUITE_NAME)
Definition: Macros.h:34
DatasetMode
Possible dataset modes.
Definition: DatasetModes.h:40
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
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Definition: Dimensions.h:122
ARM_COMPUTE_EXPECT(src.info() ->is_resizable(), framework::LogLevel::ERRORS)
TensorShape & set(size_t dimension, size_t value, bool apply_dim_correction=true)
Accessor to set the value of one of the dimensions.
Definition: TensorShape.h:78
size_t total_size() const
Collapses all dimensions to a single linear total size.
Definition: TensorShape.h:157
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}))