Fix MSVC builds for TFLite
Use of std::min/max requires the <algorithm> include w/ MSVC. Move min/max usage in the Subgraph header to the source file, where <algorithm> is already included. PiperOrigin-RevId: 314841660 Change-Id: I7a05569677eb057cd7f52d45e194abf016429560
This commit is contained in:
parent
bcdd8de103
commit
c40d59d7c7
@ -1323,6 +1323,20 @@ TfLiteStatus Subgraph::RemoveAllDelegates() {
|
|||||||
|
|
||||||
bool Subgraph::HasDelegates() { return !delegates_applied_.empty(); }
|
bool Subgraph::HasDelegates() { return !delegates_applied_.empty(); }
|
||||||
|
|
||||||
|
void Subgraph::EnsureTensorsVectorCapacity() {
|
||||||
|
const size_t required_capacity = tensors_.size() + kTensorsCapacityHeadroom;
|
||||||
|
if (required_capacity > tensors_.capacity()) {
|
||||||
|
// Whenever it's required to increase the vector capacity, make it at
|
||||||
|
// least twice bigger. The behavior is consistent with the default
|
||||||
|
// behavior of GCC STL's `std::vector::resize()`. This avoids frequently
|
||||||
|
// allocating and copying the underlying buffer.
|
||||||
|
size_t reserved_capacity =
|
||||||
|
std::max(required_capacity, tensors_.capacity() * 2);
|
||||||
|
tensors_.reserve(reserved_capacity);
|
||||||
|
context_.tensors = tensors_.data();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TfLiteStatus Subgraph::EnsureMemoryAllocations() {
|
TfLiteStatus Subgraph::EnsureMemoryAllocations() {
|
||||||
if (memory_planner_) {
|
if (memory_planner_) {
|
||||||
state_ = kStateUninvokable;
|
state_ = kStateUninvokable;
|
||||||
|
@ -567,19 +567,7 @@ class Subgraph {
|
|||||||
// capacity. Calling this function may invalidate existing pointers to
|
// capacity. Calling this function may invalidate existing pointers to
|
||||||
// tensors. After calling this function, adding `kTensorsCapacityHeadroom`
|
// tensors. After calling this function, adding `kTensorsCapacityHeadroom`
|
||||||
// more tensors won't invalidate the pointer to existing tensors.
|
// more tensors won't invalidate the pointer to existing tensors.
|
||||||
void EnsureTensorsVectorCapacity() {
|
void EnsureTensorsVectorCapacity();
|
||||||
const size_t required_capacity = tensors_.size() + kTensorsCapacityHeadroom;
|
|
||||||
if (required_capacity > tensors_.capacity()) {
|
|
||||||
// Whenever it's required to increase the vector capacity, make it at
|
|
||||||
// least twice bigger. The behavior is consistent with the default
|
|
||||||
// behavior of GCC STL's `std::vector::resize()`. This avoids frequently
|
|
||||||
// allocating and copying the underlying buffer.
|
|
||||||
size_t reserved_capacity =
|
|
||||||
std::max(required_capacity, tensors_.capacity() * 2);
|
|
||||||
tensors_.reserve(reserved_capacity);
|
|
||||||
context_.tensors = tensors_.data();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensures the memory required is planned and allocated.
|
// Ensures the memory required is planned and allocated.
|
||||||
TfLiteStatus EnsureMemoryAllocations();
|
TfLiteStatus EnsureMemoryAllocations();
|
||||||
|
Loading…
Reference in New Issue
Block a user