MCPcopy Create free account
hub / github.com/ARM-software/armnn / SoftmaxTest

Function SoftmaxTest

delegate/test/SoftmaxTestHelper.hpp:98–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98void SoftmaxTest(tflite::BuiltinOperator softmaxOperatorCode,
99 tflite::TensorType tensorType,
100 std::vector<int32_t>& shape,
101 std::vector<float>& inputValues,
102 std::vector<float>& expectedOutputValues,
103 const std::vector<armnn::BackendId>& backends = {},
104 float beta = 0)
105{
106 using namespace delegateTestInterpreter;
107 std::vector<char> modelBuffer = CreateSoftmaxTfLiteModel(softmaxOperatorCode,
108 tensorType,
109 shape,
110 beta);
111
112 // Setup interpreter with just TFLite Runtime.
113 auto tfLiteInterpreter = DelegateTestInterpreter(modelBuffer);
114 CHECK(tfLiteInterpreter.AllocateTensors() == kTfLiteOk);
115 CHECK(tfLiteInterpreter.FillInputTensor<float>(inputValues, 0) == kTfLiteOk);
116 CHECK(tfLiteInterpreter.Invoke() == kTfLiteOk);
117 std::vector<float> tfLiteOutputValues = tfLiteInterpreter.GetOutputResult<float>(0);
118 std::vector<int32_t> tfLiteOutputShape = tfLiteInterpreter.GetOutputShape(0);
119
120 // Setup interpreter with Arm NN Delegate applied.
121 auto armnnInterpreter = DelegateTestInterpreter(modelBuffer, CaptureAvailableBackends(backends));
122 CHECK(armnnInterpreter.AllocateTensors() == kTfLiteOk);
123 CHECK(armnnInterpreter.FillInputTensor<float>(inputValues, 0) == kTfLiteOk);
124 CHECK(armnnInterpreter.Invoke() == kTfLiteOk);
125 std::vector<float> armnnOutputValues = armnnInterpreter.GetOutputResult<float>(0);
126 std::vector<int32_t> armnnOutputShape = armnnInterpreter.GetOutputShape(0);
127
128 armnnDelegate::CompareOutputData<float>(tfLiteOutputValues, armnnOutputValues, expectedOutputValues);
129 armnnDelegate::CompareOutputShape(tfLiteOutputShape, armnnOutputShape, shape);
130
131 tfLiteInterpreter.Cleanup();
132 armnnInterpreter.Cleanup();
133}
134
135
136/// Convenience function to run softmax and log-softmax test cases

Callers 1

SoftmaxTestCaseFunction · 0.85

Calls 8

CreateSoftmaxTfLiteModelFunction · 0.85
CaptureAvailableBackendsFunction · 0.85
CompareOutputShapeFunction · 0.85
AllocateTensorsMethod · 0.80
InvokeMethod · 0.45
GetOutputShapeMethod · 0.45
CleanupMethod · 0.45

Tested by

no test coverage detected