tflite: Refactor core/macros.h, c/c_api.h and c/common.h
- Move TFL_CAPI_EXPORT to c/common.h to make them available for delegates. - Create lite:macros module to make core/macros.h available for delegates. PiperOrigin-RevId: 322532576 Change-Id: I8cef05e5f85592e9b29c778a6c91e87b09f6f7cd
This commit is contained in:
parent
8be37f687b
commit
d42d8c538d
@ -650,10 +650,14 @@ cc_test(
|
|||||||
cc_library(
|
cc_library(
|
||||||
name = "shared_library",
|
name = "shared_library",
|
||||||
hdrs = ["shared_library.h"],
|
hdrs = ["shared_library.h"],
|
||||||
copts = TFLITE_DEFAULT_COPTS,
|
|
||||||
linkopts = if_not_windows(["-ldl"]),
|
linkopts = if_not_windows(["-ldl"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "macros",
|
||||||
|
hdrs = ["core/macros.h"],
|
||||||
|
)
|
||||||
|
|
||||||
# Shared lib target for convenience, pulls in the core runtime and builtin ops.
|
# Shared lib target for convenience, pulls in the core runtime and builtin ops.
|
||||||
# Note: This target is not yet finalized, and the exact set of exported (C/C++)
|
# Note: This target is not yet finalized, and the exact set of exported (C/C++)
|
||||||
# APIs is subject to change. The output library name is platform dependent:
|
# APIs is subject to change. The output library name is platform dependent:
|
||||||
|
@ -66,20 +66,6 @@ limitations under the License.
|
|||||||
/// TfLiteInterpreterOptionsDelete(options);
|
/// TfLiteInterpreterOptionsDelete(options);
|
||||||
/// TfLiteModelDelete(model);
|
/// TfLiteModelDelete(model);
|
||||||
|
|
||||||
#ifdef SWIG
|
|
||||||
#define TFL_CAPI_EXPORT
|
|
||||||
#else
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#ifdef TFL_COMPILE_LIBRARY
|
|
||||||
#define TFL_CAPI_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define TFL_CAPI_EXPORT __declspec(dllimport)
|
|
||||||
#endif // TFL_COMPILE_LIBRARY
|
|
||||||
#else
|
|
||||||
#define TFL_CAPI_EXPORT __attribute__((visibility("default")))
|
|
||||||
#endif // _WIN32
|
|
||||||
#endif // SWIG
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -233,6 +233,22 @@ void TfLiteFloatArrayFree(TfLiteFloatArray* a);
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
// Define TFL_CAPI_EXPORT macro to export a function properly with a shared
|
||||||
|
// library.
|
||||||
|
#ifdef SWIG
|
||||||
|
#define TFL_CAPI_EXPORT
|
||||||
|
#else
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#ifdef TFL_COMPILE_LIBRARY
|
||||||
|
#define TFL_CAPI_EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define TFL_CAPI_EXPORT __declspec(dllimport)
|
||||||
|
#endif // TFL_COMPILE_LIBRARY
|
||||||
|
#else
|
||||||
|
#define TFL_CAPI_EXPORT __attribute__((visibility("default")))
|
||||||
|
#endif // _WIN32
|
||||||
|
#endif // SWIG
|
||||||
|
|
||||||
// Single-precision complex data type compatible with the C99 definition.
|
// Single-precision complex data type compatible with the C99 definition.
|
||||||
typedef struct TfLiteComplex64 {
|
typedef struct TfLiteComplex64 {
|
||||||
float re, im; // real and imaginary parts, respectively.
|
float re, im; // real and imaginary parts, respectively.
|
||||||
|
@ -92,6 +92,7 @@ cc_library(
|
|||||||
"//tensorflow/lite/core/api",
|
"//tensorflow/lite/core/api",
|
||||||
"//tensorflow/lite/c:common",
|
"//tensorflow/lite/c:common",
|
||||||
"//tensorflow/lite:kernel_api",
|
"//tensorflow/lite:kernel_api",
|
||||||
|
"//tensorflow/lite:macros",
|
||||||
"//tensorflow/lite:minimal_logging",
|
"//tensorflow/lite:minimal_logging",
|
||||||
"//tensorflow/lite:string",
|
"//tensorflow/lite:string",
|
||||||
"//tensorflow/lite:string_util",
|
"//tensorflow/lite:string_util",
|
||||||
|
@ -20,6 +20,7 @@ limitations under the License.
|
|||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "tensorflow/core/lib/core/status.h"
|
#include "tensorflow/core/lib/core/status.h"
|
||||||
#include "tensorflow/lite/context_util.h"
|
#include "tensorflow/lite/context_util.h"
|
||||||
|
#include "tensorflow/lite/core/macros.h"
|
||||||
#include "tensorflow/lite/delegates/flex/buffer_map.h"
|
#include "tensorflow/lite/delegates/flex/buffer_map.h"
|
||||||
#include "tensorflow/lite/delegates/flex/kernel.h"
|
#include "tensorflow/lite/delegates/flex/kernel.h"
|
||||||
#include "tensorflow/lite/delegates/flex/util.h"
|
#include "tensorflow/lite/delegates/flex/util.h"
|
||||||
@ -30,7 +31,7 @@ limitations under the License.
|
|||||||
namespace tflite {
|
namespace tflite {
|
||||||
|
|
||||||
// Corresponding weak declaration found in lite/interpreter_builder.cc.
|
// Corresponding weak declaration found in lite/interpreter_builder.cc.
|
||||||
#if !defined(_WIN32)
|
#if TFLITE_HAS_ATTRIBUTE_WEAK
|
||||||
// If weak symbol is not supported (Windows), it can use
|
// If weak symbol is not supported (Windows), it can use
|
||||||
// TF_AcquireFlexDelegate() path instead.
|
// TF_AcquireFlexDelegate() path instead.
|
||||||
TfLiteDelegateUniquePtr AcquireFlexDelegate() {
|
TfLiteDelegateUniquePtr AcquireFlexDelegate() {
|
||||||
|
@ -28,20 +28,6 @@ limitations under the License.
|
|||||||
#include "tensorflow/lite/c/common.h"
|
#include "tensorflow/lite/c/common.h"
|
||||||
#include "tensorflow/lite/delegates/gpu/delegate.h"
|
#include "tensorflow/lite/delegates/gpu/delegate.h"
|
||||||
|
|
||||||
#ifdef SWIG
|
|
||||||
#define TFL_CAPI_EXPORT
|
|
||||||
#else
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#ifdef TFL_COMPILE_LIBRARY
|
|
||||||
#define TFL_CAPI_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define TFL_CAPI_EXPORT __declspec(dllimport)
|
|
||||||
#endif // TFL_COMPILE_LIBRARY
|
|
||||||
#else
|
|
||||||
#define TFL_CAPI_EXPORT __attribute__((visibility("default")))
|
|
||||||
#endif // _WIN32
|
|
||||||
#endif // SWIG
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -20,20 +20,6 @@ limitations under the License.
|
|||||||
|
|
||||||
#include "tensorflow/lite/c/common.h"
|
#include "tensorflow/lite/c/common.h"
|
||||||
|
|
||||||
#ifdef SWIG
|
|
||||||
#define TFL_CAPI_EXPORT
|
|
||||||
#else
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#ifdef TFL_COMPILE_LIBRARY
|
|
||||||
#define TFL_CAPI_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define TFL_CAPI_EXPORT __declspec(dllimport)
|
|
||||||
#endif // TFL_COMPILE_LIBRARY
|
|
||||||
#else
|
|
||||||
#define TFL_CAPI_EXPORT __attribute__((visibility("default")))
|
|
||||||
#endif // _WIN32
|
|
||||||
#endif // SWIG
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -22,20 +22,6 @@ limitations under the License.
|
|||||||
#include "absl/base/macros.h"
|
#include "absl/base/macros.h"
|
||||||
#include "tensorflow/lite/c/common.h"
|
#include "tensorflow/lite/c/common.h"
|
||||||
|
|
||||||
#ifdef SWIG
|
|
||||||
#define TFL_CAPI_EXPORT
|
|
||||||
#else
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#ifdef TFL_COMPILE_LIBRARY
|
|
||||||
#define TFL_CAPI_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define TFL_CAPI_EXPORT __declspec(dllimport)
|
|
||||||
#endif // TFL_COMPILE_LIBRARY
|
|
||||||
#else
|
|
||||||
#define TFL_CAPI_EXPORT __attribute__((visibility("default")))
|
|
||||||
#endif // _WIN32
|
|
||||||
#endif // SWIG
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -16,19 +16,7 @@ limitations under the License.
|
|||||||
#ifndef TENSORFLOW_LITE_DELEGATES_GPU_METAL_DELEGATE_H_
|
#ifndef TENSORFLOW_LITE_DELEGATES_GPU_METAL_DELEGATE_H_
|
||||||
#define TENSORFLOW_LITE_DELEGATES_GPU_METAL_DELEGATE_H_
|
#define TENSORFLOW_LITE_DELEGATES_GPU_METAL_DELEGATE_H_
|
||||||
|
|
||||||
#ifdef SWIG
|
#include "tensorflow/lite/c/common.h"
|
||||||
#define TFL_CAPI_EXPORT
|
|
||||||
#else
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#ifdef TFL_COMPILE_LIBRARY
|
|
||||||
#define TFL_CAPI_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define TFL_CAPI_EXPORT __declspec(dllimport)
|
|
||||||
#endif // TFL_COMPILE_LIBRARY
|
|
||||||
#else
|
|
||||||
#define TFL_CAPI_EXPORT __attribute__((visibility("default")))
|
|
||||||
#endif // _WIN32
|
|
||||||
#endif // SWIG
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -17,20 +17,6 @@ limitations under the License.
|
|||||||
|
|
||||||
#include "tensorflow/lite/c/common.h"
|
#include "tensorflow/lite/c/common.h"
|
||||||
|
|
||||||
#ifdef SWIG
|
|
||||||
#define TFL_CAPI_EXPORT
|
|
||||||
#else
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#ifdef TFL_COMPILE_LIBRARY
|
|
||||||
#define TFL_CAPI_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define TFL_CAPI_EXPORT __declspec(dllimport)
|
|
||||||
#endif // TFL_COMPILE_LIBRARY
|
|
||||||
#else
|
|
||||||
#define TFL_CAPI_EXPORT __attribute__((visibility("default")))
|
|
||||||
#endif // _WIN32
|
|
||||||
#endif // SWIG
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -233,6 +233,22 @@ void TfLiteFloatArrayFree(TfLiteFloatArray* a);
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
// Define TFL_CAPI_EXPORT macro to export a function properly with a shared
|
||||||
|
// library.
|
||||||
|
#ifdef SWIG
|
||||||
|
#define TFL_CAPI_EXPORT
|
||||||
|
#else
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#ifdef TFL_COMPILE_LIBRARY
|
||||||
|
#define TFL_CAPI_EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define TFL_CAPI_EXPORT __declspec(dllimport)
|
||||||
|
#endif // TFL_COMPILE_LIBRARY
|
||||||
|
#else
|
||||||
|
#define TFL_CAPI_EXPORT __attribute__((visibility("default")))
|
||||||
|
#endif // _WIN32
|
||||||
|
#endif // SWIG
|
||||||
|
|
||||||
// Single-precision complex data type compatible with the C99 definition.
|
// Single-precision complex data type compatible with the C99 definition.
|
||||||
typedef struct TfLiteComplex64 {
|
typedef struct TfLiteComplex64 {
|
||||||
float re, im; // real and imaginary parts, respectively.
|
float re, im; // real and imaginary parts, respectively.
|
||||||
|
Loading…
Reference in New Issue
Block a user