diff --git a/RELEASE.md b/RELEASE.md index ce7830667da..c31c105919c 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -8,6 +8,14 @@ * * +* `LiteRT`, a.k.a. `tf.lite`: + * C++ API: + * The public constants `tflite::Interpreter:kTensorsReservedCapacity` + and `tflite::Interpreter:kTensorsCapacityHeadroom` are now const + references, rather than `constexpr` compile-time constants. + (This is to enable better API compatibility for TFLite in Play services + while preserving the implementation flexibility to change the values of + these constants in the future.) ### Known Caveats diff --git a/tensorflow/lite/core/interpreter.cc b/tensorflow/lite/core/interpreter.cc index 00f1a93ec65..c722beeafc4 100644 --- a/tensorflow/lite/core/interpreter.cc +++ b/tensorflow/lite/core/interpreter.cc @@ -66,6 +66,9 @@ static_assert(sizeof(TfLiteFloat16) == sizeof(uint16_t), namespace tflite { +const int& Interpreter::kTensorsReservedCapacity = 128; +const int& Interpreter::kTensorsCapacityHeadroom = 16; + namespace { // Gets the current TfLiteQuantization from the legacy TfLiteQuantizationParams. diff --git a/tensorflow/lite/core/interpreter.h b/tensorflow/lite/core/interpreter.h index feb4995b0e9..9c233ab275a 100644 --- a/tensorflow/lite/core/interpreter.h +++ b/tensorflow/lite/core/interpreter.h @@ -693,13 +693,14 @@ class Interpreter { /// \brief Gets the profiler used for op tracing. Profiler* GetProfiler(); - // The default capacity of `tensors_` vector. - static constexpr int kTensorsReservedCapacity = 128; - /// The capacity headroom of `tensors_` vector before calling ops' - /// `prepare` and `invoke` function. In these functions, it's guaranteed - /// allocating up to `kTensorsCapacityHeadroom` more tensors won't invalidate + /// The default capacity of the tensors vector. + static const int& kTensorsReservedCapacity; + + /// The capacity headroom of the tensors vector before calling ops' + /// `prepare` and `invoke` function. In those functions, it's guaranteed + /// allocating up to this many more tensors won't invalidate /// pointers to existing tensors. - static constexpr int kTensorsCapacityHeadroom = 16; + static const int& kTensorsCapacityHeadroom; /// \warning This is an experimental API and subject to change. \n /// \brief Set if buffer handle output is allowed.