Remove all usages of STLDeleteElements and remove the function from tensorflow/core

PiperOrigin-RevId: 272476237
This commit is contained in:
Gunhan Gulsoy 2019-10-02 11:05:09 -07:00 committed by TensorFlower Gardener
parent 136775e5db
commit 2b0718bbfb
7 changed files with 38 additions and 32 deletions

View File

@ -36,7 +36,6 @@ limitations under the License.
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/kernels/ops_testutil.h"
#include "tensorflow/core/lib/gtl/stl_util.h"
#include "tensorflow/core/platform/test.h"
#if GOOGLE_CUDA
@ -102,7 +101,10 @@ class TRTEngineOpTestBase : public OpsTestBase {
void ResetInputs() {
inputs_.clear();
gtl::STLDeleteElements(&tensors_);
for (auto& temp : tensors_) {
delete temp;
}
tensors_.clear();
}
private:

View File

@ -29,7 +29,6 @@ limitations under the License.
#include "tensorflow/core/framework/tensor_shape.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/kernels/ops_testutil.h"
#include "tensorflow/core/lib/gtl/stl_util.h"
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/lib/io/record_reader.h"
#include "tensorflow/core/platform/env.h"
@ -44,9 +43,15 @@ namespace tensorrt {
class TRTEngineResourceOpsTest : public OpsTestBase {
protected:
void Reset() {
for (auto& temp : tensors_) {
delete temp;
}
for (auto& temp : managed_outputs_) {
delete temp;
}
tensors_.clear();
managed_outputs_.clear();
inputs_.clear();
gtl::STLDeleteElements(&tensors_);
gtl::STLDeleteElements(&managed_outputs_);
}
TrtUniquePtrType<nvinfer1::ICudaEngine> CreateTRTEngine() {

View File

@ -23,7 +23,6 @@ limitations under the License.
#include "tensorflow/core/framework/allocator.h"
#include "tensorflow/core/framework/log_memory.h"
#include "tensorflow/core/framework/tracking_allocator.h"
#include "tensorflow/core/lib/gtl/stl_util.h"
#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/mutex.h"
@ -148,7 +147,10 @@ void ProcessState::TestOnlyReset() {
if (a != default_cpu_allocator) delete a;
}
cpu_allocators_.clear();
gtl::STLDeleteElements(&cpu_al_);
for (Allocator* a : cpu_al_) {
delete a;
}
cpu_al_.clear();
}
} // namespace tensorflow

View File

@ -22,12 +22,16 @@ limitations under the License.
#include "absl/container/flat_hash_set.h"
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/lib/gtl/stl_util.h"
#include "tensorflow/core/util/work_sharder.h"
namespace tensorflow {
DeviceBase::~DeviceBase() { gtl::STLDeleteElements(&eigen_cpu_devices_); }
DeviceBase::~DeviceBase() {
for (auto& temp : eigen_cpu_devices_) {
delete temp;
}
eigen_cpu_devices_.clear();
}
const DeviceAttributes& DeviceBase::attributes() const {
LOG(FATAL) << "Device does not implement attributes()";

View File

@ -37,7 +37,6 @@ limitations under the License.
#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/gtl/inlined_vector.h"
#include "tensorflow/core/lib/gtl/stl_util.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
@ -90,8 +89,14 @@ class OpsTestBase : public ::testing::Test {
}
~OpsTestBase() override {
gtl::STLDeleteElements(&tensors_);
gtl::STLDeleteElements(&managed_outputs_);
for (auto& temp : tensors_) {
delete temp;
}
for (auto& temp : managed_outputs_) {
delete temp;
}
tensors_.clear();
managed_outputs_.clear();
context_.reset(nullptr);
params_.reset(nullptr);
}
@ -177,7 +182,10 @@ class OpsTestBase : public ::testing::Test {
context_.reset(nullptr);
// Delete the output copies from previous runs.
gtl::STLDeleteElements(&managed_outputs_);
for (auto& temp : managed_outputs_) {
delete temp;
}
managed_outputs_.clear();
managed_outputs_.resize(0);
params_.reset(new OpKernelContext::Params);

View File

@ -32,23 +32,6 @@ limitations under the License.
namespace tensorflow {
namespace gtl {
// Deletes all the elements in an STL container and clears the container. This
// function is suitable for use with a vector, set, hash_set, or any other STL
// container which defines sensible begin(), end(), and clear() methods.
//
// If container is NULL, this function is a no-op.
template <typename T>
void STLDeleteElements(T* container) {
if (!container) return;
auto it = container->begin();
while (it != container->end()) {
auto temp = it;
++it;
delete *temp;
}
container->clear();
}
// Given an STL container consisting of (key, value) pairs, STLDeleteValues
// deletes all the "value" components and clears the container. Does nothing in
// the case it's given a NULL pointer.

View File

@ -20,7 +20,6 @@ limitations under the License.
#include <string>
#include <vector>
#include "tensorflow/core/lib/gtl/stl_util.h"
#include "tensorflow/core/lib/random/simple_philox.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/test.h"
@ -184,7 +183,10 @@ TEST(TopNTest, Ptr) {
}
std::vector<string *> extract = ConsumeRawPtr(topn.Extract());
tensorflow::gtl::STLDeleteElements(&extract);
for (auto &temp : extract) {
delete temp;
}
extract.clear();
}
struct PointeeGreater {