Not yet public PiperOrigin-RevId: 360155373
diff --git a/tensorflow_lite_support/cc/port/default/tflite_wrapper.cc b/tensorflow_lite_support/cc/port/default/tflite_wrapper.cc index 2d18394..15279b1 100644 --- a/tensorflow_lite_support/cc/port/default/tflite_wrapper.cc +++ b/tensorflow_lite_support/cc/port/default/tflite_wrapper.cc
@@ -35,6 +35,7 @@ constexpr char kGpuPluginName[] = "GpuPlugin"; constexpr char kHexagonPluginName[] = "HexagonPlugin"; constexpr char kNnApiPluginName[] = "NnapiPlugin"; +constexpr char kXnnPackPluginName[] = "XNNPackPlugin"; } // namespace /* static */ @@ -42,7 +43,8 @@ const ComputeSettings& compute_settings) { Delegate delegate = compute_settings.tflite_settings().delegate(); if (delegate != Delegate::NONE && delegate != Delegate::GPU && - delegate != Delegate::HEXAGON && delegate != Delegate::NNAPI) { + delegate != Delegate::HEXAGON && delegate != Delegate::NNAPI && + delegate != Delegate::XNNPACK) { return absl::UnimplementedError(absl::StrFormat( "Using delegate '%s' is not supported.", Delegate_Name(delegate))); } @@ -188,6 +190,16 @@ } delegate_ = delegate_plugin_->Create(); break; + case Delegate::XNNPACK: + delegate_plugin_ = DelegatePluginRegistry::CreateByName( + kXnnPackPluginName, *compute_settings->tflite_settings()); + if (!delegate_plugin_) { + return absl::NotFoundError( + "Unable to find XNNPACK delegate plugin. Have you linked in the " + "`xnnpack_plugin` target?"); + } + delegate_ = delegate_plugin_->Create(); + break; default: // Nothing to do: this should be caught by sanity checks beforehand, and // will anyway cause the code below to throw an InternalError.