13 #include <boost/test/unit_test.hpp> 20 template<
typename armnn::DataType DataType>
23 std::vector<unsigned int>& blockShape,
24 std::vector<std::pair<unsigned int, unsigned int>>& crops,
26 const float qScale = 1.0f,
27 const int32_t qOffset = 0)
29 using namespace armnn;
37 batchToSpaceNdDesc.m_DataLayout = dataLayout;
39 IConnectableLayer* batchToSpaceNd = net->AddBatchToSpaceNdLayer(batchToSpaceNdDesc,
"batchToSpaceNd");
43 Connect(batchToSpaceNd, output, outputTensorInfo, 0, 0);
44 Connect(input, batchToSpaceNd, inputTensorInfo, 0, 0);
49 template<armnn::DataType ArmnnType>
50 void BatchToSpaceNdEndToEnd(
const std::vector<BackendId>& backends,
armnn::DataLayout dataLayout)
52 using namespace armnn;
55 std::vector<unsigned int> blockShape {2, 2};
56 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
59 ? std::initializer_list<unsigned int>({ 1, 1, 2, 2 })
60 : std::initializer_list<unsigned int>({ 1, 2, 2, 1 });
63 INetworkPtr net = CreateBatchToSpaceNdNetwork<ArmnnType>(inputShape, outputShape, blockShape, crops, dataLayout);
65 BOOST_TEST_CHECKPOINT(
"create a network");
68 std::vector<T> inputData{ 1, 2, 3, 4 };
70 std::vector<T> expectedOutput{ 1, 2, 3, 4 };
72 std::map<int, std::vector<T>> inputTensorData = { { 0, inputData } };
73 std::map<int, std::vector<T>> expectedOutputData = { { 0, expectedOutput } };
75 EndToEndLayerTestImpl<ArmnnType, ArmnnType>(move(net), inputTensorData, expectedOutputData, backends);
78 template<armnn::DataType ArmnnType>
79 void BatchToSpaceNdComplexEndToEnd(
const std::vector<BackendId>& backends,
armnn::DataLayout dataLayout)
81 using namespace armnn;
84 std::vector<unsigned int> blockShape {2, 2};
85 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {2, 0}};
87 ? std::initializer_list<unsigned int>({ 8, 1, 1, 3 })
88 : std::initializer_list<unsigned int>({ 8, 1, 3, 1 });
90 ? std::initializer_list<unsigned int>({ 2, 1, 2, 4 })
91 : std::initializer_list<unsigned int>({ 2, 2, 4, 1 });
94 INetworkPtr net = CreateBatchToSpaceNdNetwork<ArmnnType>(inputShape, outputShape, blockShape, crops, dataLayout);
96 BOOST_TEST_CHECKPOINT(
"create a network");
99 std::vector<T> inputData{
106 std::vector<T> expectedOutput{
113 std::map<int, std::vector<T>> inputTensorData = { { 0, inputData } };
114 std::map<int, std::vector<T>> expectedOutputData = { { 0, expectedOutput } };
116 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) 2020 ARM Limited.
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
void Connect(armnn::IConnectableLayer *from, armnn::IConnectableLayer *to, const armnn::TensorInfo &tensorInfo, unsigned int fromIndex, unsigned int toIndex)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
static INetworkPtr Create()