15 #include <doctest/doctest.h> 22 template<armnn::DataType ArmnnTypeInput>
23 INetworkPtr CreateElementwiseUnaryNetwork(
const TensorShape& inputShape,
24 const TensorShape& outputShape,
26 const float qScale = 1.0f,
27 const int32_t qOffset = 0)
29 using namespace armnn;
34 IConnectableLayer* elementwiseUnaryLayer = net->AddElementwiseUnaryLayer(descriptor,
"elementwiseUnary");
36 TensorInfo inputTensorInfo(inputShape, ArmnnTypeInput, qScale, qOffset);
37 IConnectableLayer* input = net->AddInputLayer(armnn::numeric_cast<LayerBindingId>(0));
38 Connect(input, elementwiseUnaryLayer, inputTensorInfo, 0, 0);
40 TensorInfo outputTensorInfo(outputShape, ArmnnTypeInput, qScale, qOffset);
42 Connect(elementwiseUnaryLayer, output, outputTensorInfo, 0, 0);
49 void ElementwiseUnarySimpleEndToEnd(
const std::vector<BackendId>& backends,
51 const std::vector<float> expectedOutput)
53 using namespace armnn;
55 const float qScale = IsQuantizedType<TInput>() ? 0.25f : 1.0f;
56 const int32_t qOffset = IsQuantizedType<TInput>() ? 50 : 0;
62 INetworkPtr net = CreateElementwiseUnaryNetwork<ArmnnInType>(inputShape, outputShape, operation, qScale, qOffset);
66 const std::vector<float> input({ 1, -1, 1, 1, 5, -5, 5, 5,
67 -3, 3, 3, 3, 4, 4, -4, 4 });
70 std::vector<TInput> qInputData = armnnUtils::QuantizedVector<TInput>(input, qScale, qOffset);
71 std::vector<TInput> qExpectedOutput = armnnUtils::QuantizedVector<TInput>(expectedOutput, qScale, qOffset);
73 std::map<int, std::vector<TInput>> inputTensorData = {{ 0, qInputData }};
74 std::map<int, std::vector<TInput>> expectedOutputData = {{ 0, qExpectedOutput }};
76 EndToEndLayerTestImpl<ArmnnInType, ArmnnInType>(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.
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
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={})