| 96 | } |
| 97 | |
| 98 | void 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 |
no test coverage detected