chore: import upstream snapshot with attribution
cffconvert / validate (push) Has been skipped
License Check / license-check (push) Failing after 2s

This commit is contained in:
wehub-resource-sync
2026-07-13 12:14:16 +08:00
commit 8a852e4b4e
36502 changed files with 9277225 additions and 0 deletions
@@ -0,0 +1,224 @@
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
# buildifier: disable=out-of-order-load
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@flatbuffers//:build_defs.bzl", "DEFAULT_FLATC_ARGS", "flatbuffer_android_library", "flatbuffer_cc_library", "flatbuffer_java_library")
load("//tensorflow:tensorflow.default.bzl", "get_compatible_with_portable")
load("//tensorflow/lite:build_def.bzl", "tflite_copts", "tflite_copts_warnings")
load("//tensorflow/lite:special_rules.bzl", "nnapi_plugin_impl_visibility_allowlist", "tflite_portable_test_suite")
load("//tensorflow/lite/core/shims:cc_library_with_tflite.bzl", "cc_library_with_tflite")
# copybara:uncomment load("//tools/build_defs/proto/cpp:cc_proto_library.bzl", "cc_proto_library")
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:LICENSE"],
default_visibility = [
"//visibility:public",
],
licenses = ["notice"],
)
# Generate a C++ header containing the contents of the FlatBuffer schema
# as a char array literal. This is potentially useful for embedding in programs
# (e.g. for JSON parsing using that schema).
genrule(
name = "configuration_fbs_contents_cc",
srcs = ["configuration.fbs"],
outs = ["configuration_fbs_contents-inl.h"],
cmd = """
echo 'constexpr char configuration_fbs_contents[] = R"Delimiter(' > $(@)
cat < $(<) >> $(@)
echo ')Delimiter";' >> $(@)
""",
compatible_with = get_compatible_with_portable(),
)
genrule(
name = "configuration.fbs-backwards-compat-stub",
srcs = ["//tensorflow/lite/acceleration/configuration:configuration.fbs"],
outs = ["configuration.fbs"],
cmd = "cp $< $@",
compatible_with = get_compatible_with_portable(),
)
proto_library(
name = "configuration_proto",
srcs = ["configuration.proto"],
exports = ["//tensorflow/lite/acceleration/configuration:configuration_proto"],
deps = ["//tensorflow/lite/acceleration/configuration:configuration_proto"],
)
alias(
name = "configuration_java_proto_lite",
actual = "//tensorflow/lite/acceleration/configuration:configuration_java_proto_lite",
)
cc_proto_library(
name = "configuration_cc_proto",
deps = [":configuration_proto"],
)
flatbuffer_cc_library(
name = "configuration_fbs",
srcs = [":configuration.fbs"],
compatible_with = get_compatible_with_portable(),
flatc_args = DEFAULT_FLATC_ARGS + ["--gen-compare"],
)
flatbuffer_java_library(
name = "configuration_fbs_java",
srcs = [":configuration.fbs"],
)
flatbuffer_android_library(
name = "configuration_fbs_android",
srcs = [":configuration.fbs"],
)
cc_library(
name = "proto_to_flatbuffer",
hdrs = ["proto_to_flatbuffer.h"],
deps = [
"//tensorflow/lite/acceleration/configuration:proto_to_flatbuffer",
],
)
cc_library(
name = "flatbuffer_to_proto",
hdrs = ["flatbuffer_to_proto.h"],
deps = [
"//tensorflow/lite/acceleration/configuration:flatbuffer_to_proto",
],
)
cc_library_with_tflite(
name = "delegate_registry",
hdrs = ["delegate_registry.h"],
compatible_with = get_compatible_with_portable(),
tflite_deps = [
"//tensorflow/lite/acceleration/configuration:delegate_registry",
],
)
cc_library_with_tflite(
name = "delegate_plugin_converter",
hdrs = ["delegate_plugin_converter.h"],
tflite_deps = [
"//tensorflow/lite/acceleration/configuration:delegate_plugin_converter",
],
)
cc_library(
name = "nnapi_plugin",
compatible_with = get_compatible_with_portable(),
deps = [
":nnapi_plugin_impl",
],
)
cc_library(
name = "nnapi_plugin_impl",
hdrs = ["nnapi_plugin.h"],
compatible_with = get_compatible_with_portable(),
visibility = nnapi_plugin_impl_visibility_allowlist(),
deps = [
"//tensorflow/lite/core/acceleration/configuration:nnapi_plugin",
],
)
cc_library(
name = "hexagon_plugin",
srcs = ["hexagon_plugin.cc"],
deps = [
":configuration_fbs",
"//tensorflow/lite/core/acceleration/configuration:delegate_registry",
"@com_google_absl//absl/memory",
] + select({
"@platforms//cpu:aarch64": [
"//tensorflow/lite/delegates/hexagon:hexagon_delegate",
],
"@platforms//cpu:armv7": [
"//tensorflow/lite/delegates/hexagon:hexagon_delegate",
],
"//conditions:default": [],
}),
alwayslink = 1, # For registration to always run.
)
cc_library(
name = "gpu_plugin",
deps = [
":gpu_plugin_impl",
],
)
common_copts = tflite_copts() + tflite_copts_warnings()
cc_library(
name = "gpu_plugin_impl",
hdrs = ["gpu_plugin.h"],
copts = common_copts + select({
"//tensorflow:ios": [
"-xobjective-c++",
],
"//tensorflow:macos_arm64": [
"-xobjective-c++",
],
"//conditions:default": [],
}),
deps = [
"//tensorflow/lite/acceleration/configuration:gpu_plugin_impl",
],
)
cc_library(
name = "xnnpack_plugin",
deps = [
"//tensorflow/lite/acceleration/configuration:xnnpack_plugin",
],
)
cc_library(
name = "coreml_plugin",
srcs = ["coreml_plugin.cc"],
deps = [
":configuration_fbs",
"//tensorflow/lite:minimal_logging",
"//tensorflow/lite/core/acceleration/configuration:delegate_registry",
"@com_google_absl//absl/memory",
] + select({
"//tensorflow:macos": [
"//tensorflow/lite/delegates/coreml:coreml_delegate",
],
"//tensorflow:ios": [
"//tensorflow/lite/delegates/coreml:coreml_delegate",
],
"//conditions:default": [],
}),
alwayslink = 1, # For registration to always run.
)
# TODO(b/260582614): Add support for TF Lite in Play Services.
cc_library(
name = "stable_delegate_plugin",
hdrs = ["stable_delegate_plugin.h"],
deps = [
"//tensorflow/lite/acceleration/configuration:stable_delegate_plugin",
],
)
tflite_portable_test_suite()
@@ -0,0 +1,43 @@
# Copyright 2022 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Build macros for checking ABI compatibility."""
load("@flatbuffers//:build_defs.bzl", "flatc_path")
def flatbuffer_schema_compat_test(name, ref_schema, schema):
"""Generates a test for schema binary compatibility.
Generates a test that the specified schema file is binary backwards
compatible with a reference schema (e.g. a previous version of the
schema).
Note: currently this build macro requires that the schema be a single
fully self-contained .fbs file; it does not yet support includes.
"""
native.genrule(
name = name + "_gen",
srcs = [ref_schema, schema],
outs = [name + "_test.sh"],
tools = [flatc_path],
cmd = ("echo $(rootpath {}) --conform $(rootpath {}) $(rootpath {}) > $@"
.format(flatc_path, ref_schema, schema)),
)
native.sh_test(
name = name,
srcs = [name + "_test.sh"],
data = [flatc_path, ref_schema, schema],
)
@@ -0,0 +1,76 @@
# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
# C API for delegate plugins.
load("//tensorflow:tensorflow.default.bzl", "get_compatible_with_portable")
load(
"//tensorflow/lite/core/shims:cc_library_with_tflite.bzl",
"cc_library_with_tflite_with_c_headers_test",
)
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:LICENSE"],
default_visibility = ["//visibility:private"],
licenses = ["notice"],
)
cc_library_with_tflite_with_c_headers_test(
name = "delegate_plugin",
hdrs = ["delegate_plugin.h"],
compatible_with = get_compatible_with_portable(),
generate_opaque_delegate_target = True,
tflite_deps = [
"//tensorflow/lite/acceleration/configuration/c:delegate_plugin",
],
visibility = ["//visibility:public"],
)
cc_library_with_tflite_with_c_headers_test(
name = "nnapi_plugin",
hdrs = ["nnapi_plugin.h"],
tflite_deps = [
"//tensorflow/lite/acceleration/configuration/c:nnapi_plugin",
],
visibility = ["//visibility:public"],
)
cc_library_with_tflite_with_c_headers_test(
name = "gpu_plugin",
hdrs = ["gpu_plugin.h"],
tflite_deps = [
"//tensorflow/lite/acceleration/configuration/c:gpu_plugin",
],
visibility = ["//visibility:public"],
)
cc_library_with_tflite_with_c_headers_test(
name = "xnnpack_plugin",
hdrs = ["xnnpack_plugin.h"],
tflite_deps = [
"//tensorflow/lite/acceleration/configuration/c:xnnpack_plugin",
],
visibility = ["//visibility:public"],
)
cc_library_with_tflite_with_c_headers_test(
name = "stable_delegate",
hdrs = ["stable_delegate.h"],
generate_opaque_delegate_target = True,
tflite_deps = [
"//tensorflow/lite/acceleration/configuration/c:stable_delegate",
],
visibility = ["//visibility:public"],
)
@@ -0,0 +1,25 @@
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_DELEGATE_PLUGIN_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_DELEGATE_PLUGIN_H_
// This header file is no longer experimental.
// Please use the non-experimental file instead.
#include "tensorflow/lite/acceleration/configuration/c/delegate_plugin.h" // IWYU pragma: export
// IWYU pragma: private, include "third_party/tensorflow/lite/acceleration/configuration/c/delegate_plugin.h"
#endif // TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_DELEGATE_PLUGIN_H_
@@ -0,0 +1,25 @@
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_GPU_PLUGIN_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_GPU_PLUGIN_H_
// This header file is no longer experimental.
// Please use the non-experimental file instead.
#include "tensorflow/lite/acceleration/configuration/c/gpu_plugin.h" // IWYU pragma: export
// IWYU pragma: private, include "third_party/tensorflow/lite/acceleration/configuration/c/gpu_plugin.h"
#endif // TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_GPU_PLUGIN_H_
@@ -0,0 +1,25 @@
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_NNAPI_PLUGIN_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_NNAPI_PLUGIN_H_
// This header file is no longer experimental.
// Please use the non-experimental file instead.
#include "tensorflow/lite/acceleration/configuration/c/nnapi_plugin.h" // IWYU pragma: export
// IWYU pragma: private, include "third_party/tensorflow/lite/acceleration/configuration/c/nnapi_plugin.h"
#endif // TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_NNAPI_PLUGIN_H_
@@ -0,0 +1,25 @@
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_STABLE_DELEGATE_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_STABLE_DELEGATE_H_
// This header file is no longer experimental.
// Please use the non-experimental file instead.
#include "tensorflow/lite/acceleration/configuration/c/stable_delegate.h" // IWYU pragma: export
// IWYU pragma: private, include "third_party/tensorflow/lite/acceleration/configuration/c/stable_delegate.h"
#endif // TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_STABLE_DELEGATE_H_
@@ -0,0 +1,25 @@
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_XNNPACK_PLUGIN_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_XNNPACK_PLUGIN_H_
// This header file is no longer experimental.
// Please use the non-experimental file instead.
#include "tensorflow/lite/acceleration/configuration/c/xnnpack_plugin.h" // IWYU pragma: export
// IWYU pragma: private, include "third_party/tensorflow/lite/acceleration/configuration/c/xnnpack_plugin.h"
#endif // TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_C_XNNPACK_PLUGIN_H_
@@ -0,0 +1,20 @@
// Copyright 2026 The TensorFlow Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ==============================================================================
syntax = "proto2";
package tflite.proto;
import public "tensorflow/lite/acceleration/configuration/configuration.proto";
@@ -0,0 +1,73 @@
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include <memory>
#include "absl/memory/memory.h"
#include "tensorflow/lite/acceleration/configuration/configuration_generated.h"
#include "tensorflow/lite/core/acceleration/configuration/delegate_registry.h"
#include "tensorflow/lite/minimal_logging.h"
// Guarding anyway although this file not expected to be compiled for non-Apple.
#if defined(__APPLE__)
#include "tensorflow/lite/delegates/coreml/coreml_delegate.h"
namespace tflite {
namespace delegates {
class CoreMLPlugin : public DelegatePluginInterface {
public:
TfLiteDelegatePtr Create() override {
TfLiteDelegate* delegate_ptr = TfLiteCoreMlDelegateCreate(&options_);
TfLiteDelegatePtr delegate(delegate_ptr, [](TfLiteDelegate* delegate) {
TfLiteCoreMlDelegateDelete(delegate);
});
return delegate;
}
int GetDelegateErrno(TfLiteDelegate* /* from_delegate */) override {
return 0;
}
static std::unique_ptr<CoreMLPlugin> New(
const TFLiteSettings& tflite_settings) {
return absl::make_unique<CoreMLPlugin>(tflite_settings);
}
explicit CoreMLPlugin(const TFLiteSettings& tflite_settings) {
const CoreMLSettings* settings = tflite_settings.coreml_settings();
options_ = TfLiteCoreMlDelegateOptions({});
// Using the proto defaults if the settings were not set.
switch (settings->enabled_devices()) {
case tflite::CoreMLSettings_::EnabledDevices_DEVICES_ALL:
options_.enabled_devices = TfLiteCoreMlDelegateAllDevices;
break;
case tflite::CoreMLSettings_::EnabledDevices_DEVICES_WITH_NEURAL_ENGINE:
options_.enabled_devices = TfLiteCoreMlDelegateDevicesWithNeuralEngine;
break;
default:
TFLITE_LOG_PROD(TFLITE_LOG_ERROR, "Invalid devices enum: %d",
settings->enabled_devices());
}
options_.coreml_version = settings->coreml_version();
options_.max_delegated_partitions = settings->max_delegated_partitions();
options_.min_nodes_per_partition = settings->min_nodes_per_partition();
}
private:
TfLiteCoreMlDelegateOptions options_;
};
TFLITE_REGISTER_DELEGATE_FACTORY_FUNCTION(CoreMLPlugin, CoreMLPlugin::New);
} // namespace delegates
} // namespace tflite
#endif // __APPLE__
@@ -0,0 +1,25 @@
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_DELEGATE_PLUGIN_CONVERTER_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_DELEGATE_PLUGIN_CONVERTER_H_
// This header file is no longer experimental.
// Please use the non-experimental file instead.
#include "tensorflow/lite/acceleration/configuration/delegate_plugin_converter.h" // IWYU pragma: export
// IWYU pragma: private, include "third_party/tensorflow/lite/acceleration/configuration/delegate_plugin_converter.h"
#endif // TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_DELEGATE_PLUGIN_CONVERTER_H_
@@ -0,0 +1,25 @@
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_DELEGATE_REGISTRY_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_DELEGATE_REGISTRY_H_
// This header file is no longer experimental.
// Please use the non-experimental file instead.
#include "tensorflow/lite/acceleration/configuration/delegate_registry.h" // IWYU pragma: export
// IWYU pragma: private, include "third_party/tensorflow/lite/acceleration/configuration/delegate_registry.h"
#endif // TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_DELEGATE_REGISTRY_H_
@@ -0,0 +1,25 @@
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_FLATBUFFER_TO_PROTO_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_FLATBUFFER_TO_PROTO_H_
// This header file is no longer experimental.
// Please use the non-experimental file instead.
#include "tensorflow/lite/acceleration/configuration/flatbuffer_to_proto.h" // IWYU pragma: export
// IWYU pragma: private, include "third_party/tensorflow/lite/acceleration/configuration/flatbuffer_to_proto.h"
#endif // TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_FLATBUFFER_TO_PROTO_H_
@@ -0,0 +1,25 @@
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_GPU_PLUGIN_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_GPU_PLUGIN_H_
// This header file is no longer experimental.
// Please use the non-experimental file instead.
#include "tensorflow/lite/acceleration/configuration/gpu_plugin.h" // IWYU pragma: export
// IWYU pragma: private, include "third_party/tensorflow/lite/acceleration/configuration/gpu_plugin.h"
#endif // TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_GPU_PLUGIN_H_
@@ -0,0 +1,77 @@
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include <memory>
#include "absl/memory/memory.h"
#include "tensorflow/lite/acceleration/configuration/configuration_generated.h"
#include "tensorflow/lite/core/acceleration/configuration/delegate_registry.h"
#if defined(__ARM_ARCH)
#include "tensorflow/lite/delegates/hexagon/hexagon_delegate.h"
#endif
namespace tflite {
namespace delegates {
class HexagonPlugin : public DelegatePluginInterface {
public:
TfLiteDelegatePtr Create() override {
#if defined(__ARM_ARCH)
TfLiteHexagonInit();
auto* delegate_ptr = TfLiteHexagonDelegateCreate(&options_);
TfLiteDelegatePtr delegate(delegate_ptr, [](TfLiteDelegate* delegate) {
TfLiteHexagonDelegateDelete(delegate);
TfLiteHexagonTearDown();
});
return delegate;
#else // !defined(__ARM_ARCH)
return TfLiteDelegatePtr(nullptr, [](TfLiteDelegate*) {});
#endif // defined(__ARM_ARCH)
}
int GetDelegateErrno(TfLiteDelegate* /* from_delegate */) override {
return 0;
}
static std::unique_ptr<HexagonPlugin> New(
const TFLiteSettings& tflite_settings) {
return std::make_unique<HexagonPlugin>(tflite_settings);
}
explicit HexagonPlugin(const TFLiteSettings& tflite_settings) {
const HexagonSettings* settings = tflite_settings.hexagon_settings();
#if defined(__ARM_ARCH)
options_ = TfLiteHexagonDelegateOptions({0});
if (settings) {
options_.debug_level = settings->debug_level();
options_.powersave_level = settings->powersave_level();
options_.print_graph_profile = settings->print_graph_profile();
options_.print_graph_debug = settings->print_graph_debug();
if (tflite_settings.max_delegated_partitions() >= 0) {
options_.max_delegated_partitions =
tflite_settings.max_delegated_partitions();
}
}
#else
(void)settings;
#endif
}
private:
#if defined(__ARM_ARCH)
TfLiteHexagonDelegateOptions options_;
#endif
};
TFLITE_REGISTER_DELEGATE_FACTORY_FUNCTION(HexagonPlugin, HexagonPlugin::New);
} // namespace delegates
} // namespace tflite
@@ -0,0 +1,25 @@
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_NNAPI_PLUGIN_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_NNAPI_PLUGIN_H_
// This header file is no longer experimental.
// Please use the non-experimental file instead.
#include "tensorflow/lite/core/acceleration/configuration/nnapi_plugin.h" // IWYU pragma: export
// IWYU pragma: private, include "third_party/tensorflow/lite/core/acceleration/configuration/nnapi_plugin.h"
#endif // TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_NNAPI_PLUGIN_H_
@@ -0,0 +1,25 @@
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_PROTO_TO_FLATBUFFER_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_PROTO_TO_FLATBUFFER_H_
// This header file is no longer experimental.
// Please use the non-experimental file instead.
#include "tensorflow/lite/acceleration/configuration/proto_to_flatbuffer.h" // IWYU pragma: export
// IWYU pragma: private, include "third_party/tensorflow/lite/acceleration/configuration/proto_to_flatbuffer.h"
#endif // TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_PROTO_TO_FLATBUFFER_H_
@@ -0,0 +1,25 @@
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_STABLE_DELEGATE_PLUGIN_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_STABLE_DELEGATE_PLUGIN_H_
// This header file is no longer experimental.
// Please use the non-experimental file instead.
#include "tensorflow/lite/acceleration/configuration/stable_delegate_plugin.h" // IWYU pragma: export
// IWYU pragma: private, include "third_party/tensorflow/lite/acceleration/configuration/stable_delegate_plugin.h"
#endif // TENSORFLOW_LITE_EXPERIMENTAL_ACCELERATION_CONFIGURATION_STABLE_DELEGATE_PLUGIN_H_