windows build
diff --git a/tensorflow/lite/CMakeLists.txt b/tensorflow/lite/CMakeLists.txt
index 74f1dc8..641122d 100644
--- a/tensorflow/lite/CMakeLists.txt
+++ b/tensorflow/lite/CMakeLists.txt
@@ -415,6 +415,11 @@
ruy
${TFLITE_TARGET_DEPENDENCIES}
)
+
+if (BUILD_SHARED_LIBS)
+ list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "TFL_SHARED_LIBRARY_BUILD")
+endif()
+
target_compile_options(tensorflow-lite
PUBLIC ${TFLITE_TARGET_PUBLIC_OPTIONS}
PRIVATE ${TFLITE_TARGET_PRIVATE_OPTIONS}
diff --git a/tensorflow/lite/c/c_api_types.h b/tensorflow/lite/c/c_api_types.h
index 0128477..f591f9b 100644
--- a/tensorflow/lite/c/c_api_types.h
+++ b/tensorflow/lite/c/c_api_types.h
@@ -30,6 +30,7 @@
#ifdef SWIG
#define TFL_CAPI_EXPORT
#else
+#ifdef TFL_SHARED_LIBRARY_BUILD
#if defined(_WIN32)
#ifdef TFL_COMPILE_LIBRARY
#define TFL_CAPI_EXPORT __declspec(dllexport)
@@ -39,6 +40,9 @@
#else
#define TFL_CAPI_EXPORT __attribute__((visibility("default")))
#endif // _WIN32
+#else // TFL_SHARED_LIBRARY_BUILD
+#define TFL_CAPI_EXPORT
+#endif // TFL_SHARED_LIBRARY_BUILD
#endif // SWIG
typedef enum TfLiteStatus {
diff --git a/tensorflow/lite/delegates/gpu/common/task/weights_conversion.h b/tensorflow/lite/delegates/gpu/common/task/weights_conversion.h
index 9549a76..c258b49 100644
--- a/tensorflow/lite/delegates/gpu/common/task/weights_conversion.h
+++ b/tensorflow/lite/delegates/gpu/common/task/weights_conversion.h
@@ -32,6 +32,8 @@
namespace tflite {
namespace gpu {
+using uint = unsigned int;
+
template <DataType S, typename T>
void RearrangeWeightsToOHWIOGroupI4O4(
const tflite::gpu::Tensor<OHWI, S>& weights, int out_group_size,
diff --git a/tensorflow/lite/delegates/gpu/common/workgroup_selection.cc b/tensorflow/lite/delegates/gpu/common/workgroup_selection.cc
index 157a899..1ef8c02 100644
--- a/tensorflow/lite/delegates/gpu/common/workgroup_selection.cc
+++ b/tensorflow/lite/delegates/gpu/common/workgroup_selection.cc
@@ -17,6 +17,7 @@
#include <math.h>
+#include <cmath>
#include <set>
#include <vector>
diff --git a/tensorflow/lite/delegates/gpu/delegate.cc b/tensorflow/lite/delegates/gpu/delegate.cc
index 98303b5..767657c 100644
--- a/tensorflow/lite/delegates/gpu/delegate.cc
+++ b/tensorflow/lite/delegates/gpu/delegate.cc
@@ -76,6 +76,12 @@
public:
explicit Delegate(const TfLiteGpuDelegateOptionsV2* options)
: num_delegate_kernels_(0) {
+ delegate_.data_ = reinterpret_cast<void*>(this);
+ delegate_.Prepare = DelegatePrepare;
+ delegate_.CopyFromBufferHandle = nullptr;
+ delegate_.CopyToBufferHandle = nullptr;
+ delegate_.FreeBufferHandle = nullptr;
+ delegate_.flags = kTfLiteDelegateFlagsNone;
options_ = options ? *options : TfLiteGpuDelegateOptionsV2Default();
if (options_.max_delegated_partitions <= 0) {
options_.max_delegated_partitions = 1;
@@ -95,15 +101,7 @@
int num_delegate_kernels() const { return num_delegate_kernels_; }
private:
- TfLiteDelegate delegate_ = {
- .data_ = reinterpret_cast<void*>(this),
- .Prepare = DelegatePrepare,
- .CopyFromBufferHandle = nullptr,
- .CopyToBufferHandle = nullptr,
- .FreeBufferHandle = nullptr,
- .flags = kTfLiteDelegateFlagsNone,
- };
-
+ TfLiteDelegate delegate_;
TfLiteGpuDelegateOptionsV2 options_;
int num_delegate_kernels_ = 0;
@@ -334,8 +332,10 @@
enforce_same_thread_ = true;
TFLITE_LOG_PROD_ONCE(tflite::TFLITE_LOG_INFO,
"Initialized OpenGL-based API.");
-#endif
return absl::OkStatus();
+#else
+ return absl::UnavailableError("OpenGL-based API disabled");
+#endif
}
// The Delegate instance that's shared across all DelegateKernel instances.
@@ -440,17 +440,15 @@
} // namespace tflite
TfLiteGpuDelegateOptionsV2 TfLiteGpuDelegateOptionsV2Default() {
- TfLiteGpuDelegateOptionsV2 options = {
- // set it to -1 to detect whether it was later adjusted.
- .is_precision_loss_allowed = -1,
- .inference_preference =
- TFLITE_GPU_INFERENCE_PREFERENCE_FAST_SINGLE_ANSWER,
- .inference_priority1 = TFLITE_GPU_INFERENCE_PRIORITY_MAX_PRECISION,
- .inference_priority2 = TFLITE_GPU_INFERENCE_PRIORITY_AUTO,
- .inference_priority3 = TFLITE_GPU_INFERENCE_PRIORITY_AUTO,
- .experimental_flags = TFLITE_GPU_EXPERIMENTAL_FLAGS_ENABLE_QUANT,
- .max_delegated_partitions = 1,
- };
+ TfLiteGpuDelegateOptionsV2 options;
+ // set it to -1 to detect whether it was later adjusted.
+ options.is_precision_loss_allowed = -1;
+ options.inference_preference = TFLITE_GPU_INFERENCE_PREFERENCE_FAST_SINGLE_ANSWER;
+ options.inference_priority1 = TFLITE_GPU_INFERENCE_PRIORITY_MAX_PRECISION;
+ options.inference_priority2 = TFLITE_GPU_INFERENCE_PRIORITY_AUTO;
+ options.inference_priority3 = TFLITE_GPU_INFERENCE_PRIORITY_AUTO;
+ options.experimental_flags = TFLITE_GPU_EXPERIMENTAL_FLAGS_ENABLE_QUANT;
+ options.max_delegated_partitions = 1;
return options;
}