13 #include <doctest/doctest.h> 17 template<
typename armnn::DataType DataType>
22 using namespace armnn;
31 Connect(input, prelu, inputInfo, 0, 0);
32 Connect(alpha, prelu, alphaInfo, 0, 1);
33 Connect(prelu, output, outputInfo, 0, 0);
38 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
39 void PreluEndToEnd(
const std::vector<BackendId>& backends,
40 const std::vector<T>& inputData,
41 const std::vector<T>& alphaData,
42 const std::vector<T>& expectedOutputData,
44 const int32_t qOffset)
46 using namespace armnn;
61 INetworkPtr net = CreatePreluNetwork<ArmnnType>(inputInfo, alphaInfo, outputInfo);
65 std::map<int, std::vector<T>> inputTensorData = { { 0, inputData }, { 1, alphaData} };
66 std::map<int, std::vector<T>> expectedOutputTensorData = { { 0, expectedOutputData } };
68 EndToEndLayerTestImpl<ArmnnType, ArmnnType>(move(net),
70 expectedOutputTensorData,
74 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
75 void PreluEndToEndPositiveTest(
const std::vector<BackendId>& backends,
const float qScale = 1.0f,
76 const int32_t qOffset = 2)
78 std::vector<T> inputData{ 1, 2, 3, 4, 5, 6, 7, 8 };
79 std::vector<T> alphaData{ 2, 1, 1, 1 };
81 std::vector<T> expectedOutputData{ 2, 2, 3, 4, 5, 6, 7, 8 };
83 PreluEndToEnd<ArmnnType>(backends, inputData, alphaData, expectedOutputData, qScale, qOffset);
86 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
87 void PreluEndToEndNegativeTest(
const std::vector<BackendId>& backends,
const float qScale = 1.0f,
88 const int32_t qOffset = 0)
90 std::vector<T> inputData{ 1, -2, 3, 4, 5, 6, 7, 8 };
91 std::vector<T> alphaData{ 1, 2, 1, 1 };
93 std::vector<T> expectedOutputData{ 1, -4, 3, 4, 5, 6, 7, 8 };
95 PreluEndToEnd<ArmnnType>(backends, inputData, alphaData, expectedOutputData, qScale, qOffset);
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Copyright (c) 2021 ARM Limited and Contributors.
void SetQuantizationScale(float scale)
void SetConstant(const bool IsConstant=true)
Marks the data corresponding to this tensor info as constant.
void SetQuantizationOffset(int32_t offset)
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(NetworkOptions networkOptions={})