15 #include <doctest/doctest.h> 22 template<
typename armnn::DataType DataType>
23 INetworkPtr CreateConcatNetwork(
const std::vector<TensorShape>& inputShapes,
24 const TensorShape &outputShape,
25 unsigned int concatAxis,
26 const float qScale = 1.0f,
27 const int32_t qOffset = 0)
29 using namespace armnn;
40 for (
unsigned int i = 0; i < inputShapes.size(); ++i)
43 IConnectableLayer* input = net->AddInputLayer(armnn::numeric_cast<LayerBindingId>(i));
44 Connect(input, concat, inputTensorInfo, 0, i);
49 Connect(concat, output, outputTensorInfo, 0, 0);
54 template<armnn::DataType ArmnnType>
55 void ConcatDim0EndToEnd(
const std::vector<BackendId>& backends)
57 using namespace armnn;
60 unsigned int concatAxis = 0;
61 const std::vector<TensorShape> inputShapes{{ 2, 3, 2, 2 }, { 2, 3, 2, 2 }};
65 INetworkPtr net = CreateConcatNetwork<ArmnnType>(inputShapes, outputShape, concatAxis);
70 std::vector<T> inputData{
85 std::vector<T> expectedOutput{
112 std::map<int, std::vector<T>> inputTensorData = {{ 0,inputData }, { 1,inputData }};
113 std::map<int, std::vector<T>> expectedOutputData = {{ 0,expectedOutput }};
115 EndToEndLayerTestImpl<ArmnnType, ArmnnType>(move(net), inputTensorData, expectedOutputData, backends);
118 template<armnn::DataType ArmnnType>
119 void ConcatDim1EndToEnd(
const std::vector<BackendId>& backends)
121 using namespace armnn;
124 unsigned int concatAxis = 1;
125 const std::vector<TensorShape> inputShapes{{ 2, 3, 2, 2 }, { 2, 3, 2, 2 }};
129 INetworkPtr net = CreateConcatNetwork<ArmnnType>(inputShapes, outputShape, concatAxis);
132 std::vector<T> inputData{
147 std::vector<T> expectedOutput{
174 std::map<int, std::vector<T>> inputTensorData = {{ 0,inputData }, { 1,inputData }};
175 std::map<int, std::vector<T>> expectedOutputData = {{ 0,expectedOutput }};
177 EndToEndLayerTestImpl<ArmnnType, ArmnnType>(move(net), inputTensorData, expectedOutputData, backends);
180 template<armnn::DataType ArmnnType>
181 void ConcatDim2EndToEnd(
const std::vector<BackendId>& backends)
183 using namespace armnn;
186 unsigned int concatAxis = 2;
187 const std::vector<TensorShape> inputShapes{{ 2, 3, 2, 2 }, { 2, 3, 2, 2 }};
191 INetworkPtr net = CreateConcatNetwork<ArmnnType>(inputShapes, outputShape, concatAxis);
194 std::vector<T> inputData{
209 std::vector<T> expectedOutput{
236 std::map<int, std::vector<T>> inputTensorData = {{ 0,inputData }, { 1,inputData }};
237 std::map<int, std::vector<T>> expectedOutputData = {{ 0,expectedOutput }};
239 EndToEndLayerTestImpl<ArmnnType, ArmnnType>(move(net), inputTensorData, expectedOutputData, backends);
242 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
243 void ConcatDim3EndToEnd(
const std::vector<BackendId>& backends)
245 using namespace armnn;
247 unsigned int concatAxis = 3;
248 const std::vector<TensorShape> inputShapes{{ 2, 3, 2, 2 }, { 2, 3, 2, 2 }};
252 INetworkPtr net = CreateConcatNetwork<ArmnnType>(inputShapes, outputShape, concatAxis);
255 std::vector<T> inputData{
270 std::vector<T> expectedOutput{
297 std::map<int, std::vector<T>> inputTensorData = {{ 0,inputData }, { 1,inputData }};
298 std::map<int, std::vector<T>> expectedOutputData = {{ 0,expectedOutput }};
300 EndToEndLayerTestImpl<ArmnnType, ArmnnType>(move(net), inputTensorData, expectedOutputData, backends);
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
typename ResolveTypeImpl< DT >::Type ResolveType
Copyright (c) 2021 ARM Limited and Contributors.
An OriginsDescriptor for the ConcatLayer.
void Connect(armnn::IConnectableLayer *from, armnn::IConnectableLayer *to, const armnn::TensorInfo &tensorInfo, unsigned int fromIndex, unsigned int toIndex)
OriginsDescriptor CreateDescriptorForConcatenation(TensorShapeIt first, TensorShapeIt last, unsigned int concatenationDimension)
Convenience template to create an OriginsDescriptor to use when creating a ConcatLayer for performing...
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
static INetworkPtr Create(NetworkOptions networkOptions={})