1 /* Copyright 2019 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 #ifndef TENSORFLOW_LITE_DELEGATES_NNAPI_ACCELERATION_TEST_UTIL_H_ 16 #define TENSORFLOW_LITE_DELEGATES_NNAPI_ACCELERATION_TEST_UTIL_H_ 17 18 #include <optional> 19 #include <string> 20 21 #include <gtest/gtest.h> 22 #include "tensorflow/lite/delegates/nnapi/nnapi_delegate_kernel.h" 23 24 namespace tflite { 25 26 // NNAPI specific configuration for the validation allowlist. 27 class NnapiAccelerationTestParams { 28 public: 29 // Content in nnapi_acceleration_test_list.cc. 30 static const char* const kAccelerationTestConfig; 31 32 static NnapiAccelerationTestParams ParseConfigurationLine( 33 const std::string& conf_line); 34 NnapiAccelerationTestParams(int min_android_sdk_version)35 explicit NnapiAccelerationTestParams(int min_android_sdk_version) 36 : min_android_sdk_version_{min_android_sdk_version} {}; 37 NnapiAccelerationTestParams()38 NnapiAccelerationTestParams() 39 : min_android_sdk_version_{delegate::nnapi::kMinSdkVersionForNNAPI} {}; 40 41 // Minimum SDK version to apply the acceleration validation to. MinAndroidSdkVersion()42 int MinAndroidSdkVersion() { return min_android_sdk_version_; } 43 44 private: 45 int min_android_sdk_version_; 46 }; 47 48 // Returns the NNAPI acceleration test configuration for the given test id. 49 std::optional<NnapiAccelerationTestParams> GetNnapiAccelerationTestParam( 50 std::string test_id); 51 52 } // namespace tflite 53 54 #endif // TENSORFLOW_LITE_DELEGATES_NNAPI_ACCELERATION_TEST_UTIL_H_ 55