17 #include <boost/test/unit_test.hpp> 31 using namespace armnn;
36 network->AddTransposeConvolution2dLayer(descriptor, weights, biases,
"transposeConvolution2d");
39 Connect(input, transposeConvolution2d, inputInfo, 0, 0);
40 Connect(transposeConvolution2d, output, outputInfo, 0, 0);
47 template<armnn::DataType ArmnnType, armnn::DataType ArmnnBType>
51 using namespace armnn;
54 constexpr
unsigned int batches = 1u;
55 constexpr
unsigned int channels = 1u;
57 constexpr
unsigned int wInput = 3u;
58 constexpr
unsigned int hInput = wInput;
60 constexpr
unsigned int wOutput = 5u;
61 constexpr
unsigned int hOutput = wOutput;
63 constexpr
unsigned int wWeights = 3u;
64 constexpr
unsigned int hWeights = wWeights;
70 const float qScale = IsQuantizedType<T>() ? 0.25f : 1.0f;
71 const int32_t qOffset = IsQuantizedType<T>() ? 50 : 0;
73 TensorInfo inputInfo(inputShape, ArmnnType, qScale, qOffset);
74 TensorInfo outputInfo(outputShape, ArmnnType, qScale, qOffset);
75 TensorInfo weightsInfo(weightsShape, ArmnnType, qScale, qOffset);
76 TensorInfo biasesInfo({ channels }, ArmnnBType, qScale * qScale, 0);
78 std::vector<float> inputData =
85 std::vector<float> weightsData =
92 std::vector<float> biasesData = { 1.f };
94 std::vector<float> expectedOutputData =
96 6.f, 11.f, 6.f, 11.f, 6.f,
97 11.f, 21.f, 11.f, 21.f, 11.f,
98 6.f, 11.f, 6.f, 11.f, 6.f,
99 11.f, 21.f, 11.f, 21.f, 11.f,
100 6.f, 11.f, 6.f, 11.f, 6.f
116 constexpr
size_t dataTypeSize =
sizeof(float);
119 std::vector<float> tmp(inputData.size());
120 armnnUtils::Permute(inputInfo.GetShape(), nchwToNhwc, inputData.data(), tmp.data(), dataTypeSize);
123 tmp.resize(weightsData.size());
127 tmp.resize(expectedOutputData.size());
129 expectedOutputData = tmp;
133 std::vector<T> qInputData = armnnUtils::QuantizedVector<T>(inputData, qScale, qOffset);
134 std::vector<T> qWeightsData = armnnUtils::QuantizedVector<T>(weightsData, qScale, qOffset);
135 std::vector<T> qExpectedOutputData = armnnUtils::QuantizedVector<T>(expectedOutputData, qScale, qOffset);
138 std::vector<BT> qBiasesData = armnnUtils::QuantizedVector<BT>(biasesData, qScale * qScale, 0);
143 INetworkPtr network = CreateTransposeConvolution2dNetwork(descriptor,
150 EndToEndLayerTestImpl<ArmnnType, ArmnnType>(std::move(network),
151 { { 0, qInputData } },
152 { { 0, qExpectedOutputData } },
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
const TensorShape & GetShape() const
bool m_BiasEnabled
Enable/disable bias.
typename ResolveTypeImpl< DT >::Type ResolveType
Copyright (c) 2020 ARM Limited.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
void TransposeConvolution2dEndToEnd(const std::vector< armnn::BackendId > &backends, armnn::DataLayout dataLayout)
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
uint32_t m_PadTop
Padding top value in the height dimension.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
uint32_t m_PadRight
Padding right value in the width dimension.
void Connect(armnn::IConnectableLayer *from, armnn::IConnectableLayer *to, const armnn::TensorInfo &tensorInfo, unsigned int fromIndex, unsigned int toIndex)
armnn::TensorShape MakeTensorShape(unsigned int batches, unsigned int channels, unsigned int height, unsigned int width, armnn::DataLayout layout)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
static INetworkPtr Create()