move xnnpack delegate to tools/evaluation

This commit is contained in:
Koan-Sin Tan 2020-02-29 17:49:43 +08:00
parent 86f9cfb927
commit 2b39b73a56
4 changed files with 21 additions and 5 deletions

View File

@ -107,11 +107,7 @@ TfLiteDelegatePtrMap GetDelegates(Settings* s) {
TfLiteXNNPackDelegateOptionsDefault();
xnnpack_options.num_threads = s->number_of_threads;
auto xnnpack_delegate = TfLiteXNNPackDelegateCreate(&xnnpack_options);
auto delegate = Interpreter::TfLiteDelegatePtr(
xnnpack_delegate, [](TfLiteDelegate* delegate) {
TfLiteXNNPackDelegateDelete(delegate);
});
auto delegate = evaluation::CreateXNNPACKDelegate(&xnnpack_options);
if (!delegate) {
LOG(INFO) << "XNNPACK acceleration is unsupported on this platform.";
} else {

View File

@ -43,6 +43,7 @@ cc_library(
"//tensorflow/lite:context",
"//tensorflow/lite:framework",
"//tensorflow/lite/delegates/nnapi:nnapi_delegate",
"//tensorflow/lite/delegates/xnnpack:xnnpack_delegate",
] + select({
"//tensorflow:android": [
"//tensorflow/lite/delegates/gpu:delegate",

View File

@ -164,5 +164,19 @@ Interpreter::TfLiteDelegatePtr CreateHexagonDelegate(
#endif // defined(__ANDROID__)
}
Interpreter::TfLiteDelegatePtr CreateXNNPACKDelegate() {
TfLiteXNNPackDelegateOptions xnnpack_options =
TfLiteXNNPackDelegateOptionsDefault();
return CreateXNNPACKDelegate(&xnnpack_options);
}
Interpreter::TfLiteDelegatePtr CreateXNNPACKDelegate(
const TfLiteXNNPackDelegateOptions* xnnpack_options) {
auto xnnpack_delegate = TfLiteXNNPackDelegateCreate(xnnpack_options);
return Interpreter::TfLiteDelegatePtr(
xnnpack_delegate,
[](TfLiteDelegate* delegate) { TfLiteXNNPackDelegateDelete(delegate); });
}
} // namespace evaluation
} // namespace tflite

View File

@ -29,6 +29,7 @@ limitations under the License.
#include "tensorflow/lite/context.h"
#include "tensorflow/lite/delegates/nnapi/nnapi_delegate.h"
#include "tensorflow/lite/delegates/xnnpack/xnnpack_delegate.h"
#include "tensorflow/lite/model.h"
namespace tflite {
@ -64,6 +65,10 @@ Interpreter::TfLiteDelegatePtr CreateGPUDelegate(
Interpreter::TfLiteDelegatePtr CreateHexagonDelegate(
const std::string& library_directory_path, bool profiling);
Interpreter::TfLiteDelegatePtr CreateXNNPACKDelegate();
Interpreter::TfLiteDelegatePtr CreateXNNPACKDelegate(
const TfLiteXNNPackDelegateOptions* options);
} // namespace evaluation
} // namespace tflite