diff --git a/tensorflow/compiler/jit/xla_compilation_cache.cc b/tensorflow/compiler/jit/xla_compilation_cache.cc index d5a1ab0850c..bff4cc57ee1 100644 --- a/tensorflow/compiler/jit/xla_compilation_cache.cc +++ b/tensorflow/compiler/jit/xla_compilation_cache.cc @@ -62,7 +62,7 @@ XlaCompilationCache::~XlaCompilationCache() { // about? } -string XlaCompilationCache::DebugString() { +string XlaCompilationCache::DebugString() const { return "XLA JIT compilation cache"; } diff --git a/tensorflow/compiler/jit/xla_compilation_cache.h b/tensorflow/compiler/jit/xla_compilation_cache.h index 846d0c963db..02aa8f8839e 100644 --- a/tensorflow/compiler/jit/xla_compilation_cache.h +++ b/tensorflow/compiler/jit/xla_compilation_cache.h @@ -88,7 +88,7 @@ class XlaCompilationCache : public ResourceBase { xla::LocalClient* client() const { return client_; } const DeviceType& device_type() const { return device_type_; } - string DebugString() override; + string DebugString() const override; // Describes the types, shapes and any compile-time constant arguments // to a kernel. Key that uniquely identifies a compilation output. diff --git a/tensorflow/compiler/tf2xla/xla_compiler_test.cc b/tensorflow/compiler/tf2xla/xla_compiler_test.cc index 32a43018409..492010f7317 100644 --- a/tensorflow/compiler/tf2xla/xla_compiler_test.cc +++ b/tensorflow/compiler/tf2xla/xla_compiler_test.cc @@ -82,7 +82,7 @@ namespace { // compiled kernels. class DummyResourceForTest : public ResourceBase { public: - string DebugString() override { return "dummy"; } + string DebugString() const override { return "dummy"; } void Increment() { ++value_; } int Get() { return value_; } diff --git a/tensorflow/compiler/tf2xla/xla_context.cc b/tensorflow/compiler/tf2xla/xla_context.cc index a69af705033..6139bf3cea0 100644 --- a/tensorflow/compiler/tf2xla/xla_context.cc +++ b/tensorflow/compiler/tf2xla/xla_context.cc @@ -61,7 +61,7 @@ void XlaContext::set_args(std::vector args) { XlaContext::XlaContext(XlaCompiler* compiler, xla::XlaBuilder* builder) : compiler_(compiler), builder_(builder) {} -string XlaContext::DebugString() { return "XLA JIT context"; } +string XlaContext::DebugString() const { return "XLA JIT context"; } void XlaContext::SetRetval(int index, const XlaExpression& expression) { if (retvals_.size() <= index) { diff --git a/tensorflow/compiler/tf2xla/xla_context.h b/tensorflow/compiler/tf2xla/xla_context.h index 0767d1faac1..eb4ad3fe6a1 100644 --- a/tensorflow/compiler/tf2xla/xla_context.h +++ b/tensorflow/compiler/tf2xla/xla_context.h @@ -47,7 +47,7 @@ class XlaContext : public ResourceBase { XlaContext(XlaCompiler* compiler, xla::XlaBuilder* builder); // Virtual method defined by ResourceBase. - string DebugString() override; + string DebugString() const override; XlaCompiler* compiler() const { return compiler_; } diff --git a/tensorflow/compiler/xrt/xrt_compilation_cache.cc b/tensorflow/compiler/xrt/xrt_compilation_cache.cc index d1405eae468..8bf0f28d223 100644 --- a/tensorflow/compiler/xrt/xrt_compilation_cache.cc +++ b/tensorflow/compiler/xrt/xrt_compilation_cache.cc @@ -273,6 +273,8 @@ Status XRTCompilationCache::Lookup( return Status::OK(); } -string XRTCompilationCache::DebugString() { return "XRTCompilationCache"; } +string XRTCompilationCache::DebugString() const { + return "XRTCompilationCache"; +} } // namespace tensorflow diff --git a/tensorflow/compiler/xrt/xrt_compilation_cache.h b/tensorflow/compiler/xrt/xrt_compilation_cache.h index c43d0fc4787..7398e847d8b 100644 --- a/tensorflow/compiler/xrt/xrt_compilation_cache.h +++ b/tensorflow/compiler/xrt/xrt_compilation_cache.h @@ -118,7 +118,7 @@ class XRTCompilationCache : public ResourceBase { // EntryRef holding the program is returned in entry. Status Lookup(int64 uid, std::unique_ptr* entry); - string DebugString() override; + string DebugString() const override; private: // An entry in the compilation cache. The entry is deleted once it has been diff --git a/tensorflow/compiler/xrt/xrt_state.h b/tensorflow/compiler/xrt/xrt_state.h index 3e3d5024124..4aac37737ea 100644 --- a/tensorflow/compiler/xrt/xrt_state.h +++ b/tensorflow/compiler/xrt/xrt_state.h @@ -172,7 +172,7 @@ class XRTTupleAllocation : public ResourceBase { // ownership of the device memory is transferred to the result. xla::ShapeTree ToDeviceMemoryTree(bool release); - string DebugString() override { return "XLA allocation handle"; } + string DebugString() const override { return "XLA allocation handle"; } private: // Creates a new handle with (tuple) shape. diff --git a/tensorflow/contrib/bigtable/kernels/bigtable_lib.h b/tensorflow/contrib/bigtable/kernels/bigtable_lib.h index 4652021feca..e3b4535bac4 100644 --- a/tensorflow/contrib/bigtable/kernels/bigtable_lib.h +++ b/tensorflow/contrib/bigtable/kernels/bigtable_lib.h @@ -42,7 +42,7 @@ class BigtableClientResource : public ResourceBase { return client_; } - string DebugString() override { + string DebugString() const override { return strings::StrCat("BigtableClientResource(project_id: ", project_id_, ", instance_id: ", instance_id_, ")"); } @@ -67,7 +67,7 @@ class BigtableTableResource : public ResourceBase { ::google::cloud::bigtable::noex::Table& table() { return table_; } - string DebugString() override { + string DebugString() const override { return strings::StrCat( "BigtableTableResource(client: ", client_->DebugString(), ", table: ", table_name_, ")"); diff --git a/tensorflow/contrib/boosted_trees/kernels/stats_accumulator_ops.cc b/tensorflow/contrib/boosted_trees/kernels/stats_accumulator_ops.cc index e446c411a8d..6faf6963011 100644 --- a/tensorflow/contrib/boosted_trees/kernels/stats_accumulator_ops.cc +++ b/tensorflow/contrib/boosted_trees/kernels/stats_accumulator_ops.cc @@ -96,7 +96,7 @@ class StatsAccumulatorResource : public boosted_trees::StampedResource { TensorShapeUtils::IsScalar(hessian_shape)); } - string DebugString() override { + string DebugString() const override { return strings::StrCat("StatsAccumulatorResource[size=", values_.size(), "]"); } diff --git a/tensorflow/contrib/boosted_trees/resources/decision_tree_ensemble_resource.h b/tensorflow/contrib/boosted_trees/resources/decision_tree_ensemble_resource.h index 94aeb2c7bb4..0fe57c0a4e8 100644 --- a/tensorflow/contrib/boosted_trees/resources/decision_tree_ensemble_resource.h +++ b/tensorflow/contrib/boosted_trees/resources/decision_tree_ensemble_resource.h @@ -34,7 +34,7 @@ class DecisionTreeEnsembleResource : public StampedResource { protobuf::Arena::CreateMessage< boosted_trees::trees::DecisionTreeEnsembleConfig>(&arena_)) {} - string DebugString() override { + string DebugString() const override { return strings::StrCat("GTFlowDecisionTreeEnsemble[size=", decision_tree_ensemble_->trees_size(), "]"); } diff --git a/tensorflow/contrib/boosted_trees/resources/quantile_stream_resource.h b/tensorflow/contrib/boosted_trees/resources/quantile_stream_resource.h index fdaaae7f472..574e3065e7f 100644 --- a/tensorflow/contrib/boosted_trees/resources/quantile_stream_resource.h +++ b/tensorflow/contrib/boosted_trees/resources/quantile_stream_resource.h @@ -43,7 +43,7 @@ class QuantileStreamResource : public StampedResource { set_stamp(stamp_token); } - string DebugString() override { return "QuantileStreamResource"; } + string DebugString() const override { return "QuantileStreamResource"; } tensorflow::mutex* mutex() { return &mu_; } diff --git a/tensorflow/contrib/tensor_forest/kernels/v4/decision-tree-resource.h b/tensorflow/contrib/tensor_forest/kernels/v4/decision-tree-resource.h index d3edb437337..3100a5a0e5d 100644 --- a/tensorflow/contrib/tensor_forest/kernels/v4/decision-tree-resource.h +++ b/tensorflow/contrib/tensor_forest/kernels/v4/decision-tree-resource.h @@ -32,7 +32,7 @@ class DecisionTreeResource : public ResourceBase { // Constructor. explicit DecisionTreeResource(const TensorForestParams& params); - string DebugString() override { + string DebugString() const override { return strings::StrCat("DecisionTree[size=", decision_tree_->decision_tree().nodes_size(), "]"); } diff --git a/tensorflow/contrib/tensor_forest/kernels/v4/fertile-stats-resource.h b/tensorflow/contrib/tensor_forest/kernels/v4/fertile-stats-resource.h index eea0be27caf..44f2b3f473b 100644 --- a/tensorflow/contrib/tensor_forest/kernels/v4/fertile-stats-resource.h +++ b/tensorflow/contrib/tensor_forest/kernels/v4/fertile-stats-resource.h @@ -40,7 +40,7 @@ class FertileStatsResource : public ResourceBase { model_op_ = LeafModelOperatorFactory::CreateLeafModelOperator(params_); } - string DebugString() override { return "FertileStats"; } + string DebugString() const override { return "FertileStats"; } void ExtractFromProto(const FertileStats& stats); diff --git a/tensorflow/contrib/tensorrt/resources/trt_resources.h b/tensorflow/contrib/tensorrt/resources/trt_resources.h index aac9e5c7bd7..8d877b392fa 100644 --- a/tensorflow/contrib/tensorrt/resources/trt_resources.h +++ b/tensorflow/contrib/tensorrt/resources/trt_resources.h @@ -48,7 +48,7 @@ class TRTCalibrationResource : public tensorflow::ResourceBase { allocator_.reset(); } - string DebugString() override { + string DebugString() const override { std::stringstream oss; using std::dec; using std::endl; diff --git a/tensorflow/core/framework/lookup_interface.h b/tensorflow/core/framework/lookup_interface.h index d33945fd1b0..7e5dbe5632b 100644 --- a/tensorflow/core/framework/lookup_interface.h +++ b/tensorflow/core/framework/lookup_interface.h @@ -131,7 +131,7 @@ class LookupInterface : public ResourceBase { // - the default_value tensor shape matches the table's value shape. Status CheckFindArguments(const Tensor& keys, const Tensor& default_value); - string DebugString() override { + string DebugString() const override { return strings::StrCat("A lookup table of size: ", size()); } diff --git a/tensorflow/core/framework/queue_interface.h b/tensorflow/core/framework/queue_interface.h index 4ca4416c5ac..9395cce1644 100644 --- a/tensorflow/core/framework/queue_interface.h +++ b/tensorflow/core/framework/queue_interface.h @@ -85,11 +85,11 @@ class QueueInterface : public ResourceBase { virtual Status MatchesNodeDef(const NodeDef& node_def) = 0; // Returns the number of elements in the queue. - virtual int32 size() = 0; + virtual int32 size() const = 0; virtual const DataTypeVector& component_dtypes() const = 0; - string DebugString() override { + string DebugString() const override { return strings::StrCat("A Queue of size: ", size()); } diff --git a/tensorflow/core/framework/reader_interface.h b/tensorflow/core/framework/reader_interface.h index f894acbe1d5..e47644cb8f2 100644 --- a/tensorflow/core/framework/reader_interface.h +++ b/tensorflow/core/framework/reader_interface.h @@ -76,7 +76,7 @@ class ReaderInterface : public ResourceBase { // Note: Must Reset on error. virtual Status RestoreState(const string& state) = 0; - string DebugString() override { return "a reader"; } + string DebugString() const override { return "a reader"; } protected: virtual ~ReaderInterface() {} diff --git a/tensorflow/core/framework/resource_mgr.h b/tensorflow/core/framework/resource_mgr.h index 8a7c25da921..9c381e7d6b4 100644 --- a/tensorflow/core/framework/resource_mgr.h +++ b/tensorflow/core/framework/resource_mgr.h @@ -77,7 +77,7 @@ namespace tensorflow { class ResourceBase : public core::RefCounted { public: // Returns a debug string for *this. - virtual string DebugString() = 0; + virtual string DebugString() const = 0; // Returns memory used by this resource. virtual int64 MemoryUsed() const { return 0; } diff --git a/tensorflow/core/framework/resource_mgr_test.cc b/tensorflow/core/framework/resource_mgr_test.cc index 7c7f0af0ce4..1c785736e60 100644 --- a/tensorflow/core/framework/resource_mgr_test.cc +++ b/tensorflow/core/framework/resource_mgr_test.cc @@ -32,7 +32,7 @@ class Resource : public ResourceBase { explicit Resource(const string& label) : label_(label) {} ~Resource() override {} - string DebugString() override { return strings::StrCat("R/", label_); } + string DebugString() const override { return strings::StrCat("R/", label_); } private: string label_; @@ -43,7 +43,7 @@ class Other : public ResourceBase { explicit Other(const string& label) : label_(label) {} ~Other() override {} - string DebugString() override { return strings::StrCat("O/", label_); } + string DebugString() const override { return strings::StrCat("O/", label_); } private: string label_; @@ -245,7 +245,7 @@ class StubDevice : public DeviceBase { // Empty stub resource for testing resource handles. class StubResource : public ResourceBase { public: - string DebugString() override { return ""; } + string DebugString() const override { return ""; } int value_{0}; }; @@ -305,7 +305,7 @@ TEST(ResourceHandleTest, DifferentDevice) { // Other stub resource to test type-checking of resource handles. class OtherStubResource : public ResourceBase { public: - string DebugString() override { return ""; } + string DebugString() const override { return ""; } }; TEST(ResourceHandleTest, DifferentType) { diff --git a/tensorflow/core/framework/resource_op_kernel_test.cc b/tensorflow/core/framework/resource_op_kernel_test.cc index c1e503dc576..7a2a87045bf 100644 --- a/tensorflow/core/framework/resource_op_kernel_test.cc +++ b/tensorflow/core/framework/resource_op_kernel_test.cc @@ -46,7 +46,7 @@ class StubDevice : public DeviceBase { // Stub resource for testing resource op kernel. class StubResource : public ResourceBase { public: - string DebugString() override { return ""; } + string DebugString() const override { return ""; } int code; }; diff --git a/tensorflow/core/framework/resource_var.h b/tensorflow/core/framework/resource_var.h index f5de5dba885..9387b6c23c7 100644 --- a/tensorflow/core/framework/resource_var.h +++ b/tensorflow/core/framework/resource_var.h @@ -67,7 +67,7 @@ class Var : public ResourceBase { mutex* mu() { return &mu_; } Tensor* tensor() { return &tensor_; } - string DebugString() override { + string DebugString() const override { return strings::StrCat(DataTypeString(tensor_.dtype()), "/", tensor_.shape().DebugString()); } diff --git a/tensorflow/core/framework/stats_aggregator.h b/tensorflow/core/framework/stats_aggregator.h index af53ed0a3ca..7c960840d74 100644 --- a/tensorflow/core/framework/stats_aggregator.h +++ b/tensorflow/core/framework/stats_aggregator.h @@ -83,7 +83,7 @@ class StatsAggregatorResource : public ResourceBase { return stats_aggregator_; } - string DebugString() { return "StatsAggregatorResource"; } + string DebugString() const override { return "StatsAggregatorResource"; } private: const std::shared_ptr stats_aggregator_; diff --git a/tensorflow/core/kernels/barrier_ops.cc b/tensorflow/core/kernels/barrier_ops.cc index aa912358221..d5bd36b4cea 100644 --- a/tensorflow/core/kernels/barrier_ops.cc +++ b/tensorflow/core/kernels/barrier_ops.cc @@ -300,7 +300,7 @@ class Barrier : public ResourceBase { ready_queue_->Unref(); } - string DebugString() override { return "A barrier"; } + string DebugString() const override { return "A barrier"; } protected: template diff --git a/tensorflow/core/kernels/batch_kernels.cc b/tensorflow/core/kernels/batch_kernels.cc index 35ddda0ec04..5ba461aa9de 100644 --- a/tensorflow/core/kernels/batch_kernels.cc +++ b/tensorflow/core/kernels/batch_kernels.cc @@ -233,7 +233,7 @@ class BatchResource : public ResourceBase { return Status::OK(); } - string DebugString() final { return "BatchResource"; } + string DebugString() const final { return "BatchResource"; } // Ingests data from one invocation of the batch op. The data is enqueued to // be combined with others into a batch, asynchronously. @@ -878,7 +878,7 @@ class UnbatchResource : public ResourceBase { timeout_enforcer_ = nullptr; } - string DebugString() final { return "UnbatchResource"; } + string DebugString() const final { return "UnbatchResource"; } Status Compute(OpKernelContext* context, AsyncOpKernel::DoneCallback done) { const Tensor& data_t = context->input(0); @@ -1094,7 +1094,7 @@ class UnbatchGradResource : public ResourceBase { public: UnbatchGradResource() {} - string DebugString() final { return "UnbatchGradResource"; } + string DebugString() const final { return "UnbatchGradResource"; } // Flushes the information for one batch, given its context and done // callback. Clears all information about it from the available_tensors_. diff --git a/tensorflow/core/kernels/boosted_trees/quantiles/quantile_stream_resource.h b/tensorflow/core/kernels/boosted_trees/quantiles/quantile_stream_resource.h index 1c31724272a..965bf2c924c 100644 --- a/tensorflow/core/kernels/boosted_trees/quantiles/quantile_stream_resource.h +++ b/tensorflow/core/kernels/boosted_trees/quantiles/quantile_stream_resource.h @@ -37,15 +37,15 @@ class BoostedTreesQuantileStreamResource : public ResourceBase { epsilon_(epsilon), num_streams_(num_streams), max_elements_(max_elements) { - streams_.reserve(num_streams_); - boundaries_.reserve(num_streams_); - for (int64 idx = 0; idx < num_streams; ++idx) { - streams_.push_back(QuantileStream(epsilon, max_elements)); - boundaries_.push_back(std::vector()); - } - } + streams_.reserve(num_streams_); + boundaries_.reserve(num_streams_); + for (int64 idx = 0; idx < num_streams; ++idx) { + streams_.push_back(QuantileStream(epsilon, max_elements)); + boundaries_.push_back(std::vector()); + } + } - string DebugString() override { return "QuantileStreamResource"; } + string DebugString() const override { return "QuantileStreamResource"; } tensorflow::mutex* mutex() { return &mu_; } diff --git a/tensorflow/core/kernels/boosted_trees/resources.cc b/tensorflow/core/kernels/boosted_trees/resources.cc index 27987225362..42df4848815 100644 --- a/tensorflow/core/kernels/boosted_trees/resources.cc +++ b/tensorflow/core/kernels/boosted_trees/resources.cc @@ -31,7 +31,7 @@ BoostedTreesEnsembleResource::BoostedTreesEnsembleResource() protobuf::Arena::CreateMessage( &arena_)) {} -string BoostedTreesEnsembleResource::DebugString() { +string BoostedTreesEnsembleResource::DebugString() const { return strings::StrCat("TreeEnsemble[size=", tree_ensemble_->trees_size(), "]"); } diff --git a/tensorflow/core/kernels/boosted_trees/resources.h b/tensorflow/core/kernels/boosted_trees/resources.h index f961ed38142..3c7b2df9b08 100644 --- a/tensorflow/core/kernels/boosted_trees/resources.h +++ b/tensorflow/core/kernels/boosted_trees/resources.h @@ -48,7 +48,7 @@ class BoostedTreesEnsembleResource : public StampedResource { public: BoostedTreesEnsembleResource(); - string DebugString() override; + string DebugString() const override; bool InitFromSerialized(const string& serialized, const int64 stamp_token); diff --git a/tensorflow/core/kernels/conditional_accumulator_base.h b/tensorflow/core/kernels/conditional_accumulator_base.h index 4a5ec6f0fb3..2618ffbb099 100644 --- a/tensorflow/core/kernels/conditional_accumulator_base.h +++ b/tensorflow/core/kernels/conditional_accumulator_base.h @@ -68,7 +68,7 @@ class ConditionalAccumulatorBase : public ResourceBase { const DataType& dtype() const { return dtype_; } - string DebugString() override { return "A conditional accumulator"; } + string DebugString() const override { return "A conditional accumulator"; } // SetGlobalStep is a modifier method for current_global_step. // It returns an InvalidArgument error if the new_global_step is less than diff --git a/tensorflow/core/kernels/conv_ops.h b/tensorflow/core/kernels/conv_ops.h index 7ec878e0b2f..7ccbaf4bf23 100644 --- a/tensorflow/core/kernels/conv_ops.h +++ b/tensorflow/core/kernels/conv_ops.h @@ -63,7 +63,7 @@ struct Im2ColBufferResource : public ResourceBase { // the buffer memory held by this resource. mutex mu; T* data; - string DebugString() { return "Im2ColBufferResource"; } + string DebugString() const { return "Im2ColBufferResource"; } }; // Convolution parameters specified by Op attributes. diff --git a/tensorflow/core/kernels/data/cache_dataset_ops.cc b/tensorflow/core/kernels/data/cache_dataset_ops.cc index f00b38e732a..535f49cff80 100644 --- a/tensorflow/core/kernels/data/cache_dataset_ops.cc +++ b/tensorflow/core/kernels/data/cache_dataset_ops.cc @@ -614,7 +614,9 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { public: MemoryCache() = default; - string DebugString() override { return "CacheDataset::MemoryCache"; } + string DebugString() const override { + return "CacheDataset::MemoryCache"; + } // Marks the cache as completed. void Complete() { diff --git a/tensorflow/core/kernels/data/experimental/indexed_dataset_op.cc b/tensorflow/core/kernels/data/experimental/indexed_dataset_op.cc index a07eaebdf9d..83eeed7892b 100644 --- a/tensorflow/core/kernels/data/experimental/indexed_dataset_op.cc +++ b/tensorflow/core/kernels/data/experimental/indexed_dataset_op.cc @@ -106,7 +106,7 @@ class MaterializedDatasetResource : public ResourceBase { const std::vector& output_shapes) : output_dtypes_(output_dtypes), output_shapes_(output_shapes) {} - string DebugString() override { + string DebugString() const override { return "Materialized IndexedDataset resource"; } diff --git a/tensorflow/core/kernels/data/experimental/threadpool_dataset_op.cc b/tensorflow/core/kernels/data/experimental/threadpool_dataset_op.cc index 8ae45ed5c9d..fab3cab7da5 100644 --- a/tensorflow/core/kernels/data/experimental/threadpool_dataset_op.cc +++ b/tensorflow/core/kernels/data/experimental/threadpool_dataset_op.cc @@ -51,7 +51,7 @@ class ThreadPoolResource : public ResourceBase { int32 NumThreads() { return thread_pool_.NumThreads(); } - string DebugString() override { return "ThreadPoolResource"; } + string DebugString() const override { return "ThreadPoolResource"; } private: thread::ThreadPool thread_pool_; diff --git a/tensorflow/core/kernels/data/iterator_ops.cc b/tensorflow/core/kernels/data/iterator_ops.cc index 9f5881563b5..81e26d35c06 100644 --- a/tensorflow/core/kernels/data/iterator_ops.cc +++ b/tensorflow/core/kernels/data/iterator_ops.cc @@ -231,7 +231,7 @@ class IteratorResource : public ResourceBase { return Status::OK(); } - string DebugString() override { return "Iterator resource"; } + string DebugString() const override { return "Iterator resource"; } const DataTypeVector& output_dtypes() const { return output_dtypes_; } diff --git a/tensorflow/core/kernels/data/multi_device_iterator_ops.cc b/tensorflow/core/kernels/data/multi_device_iterator_ops.cc index ba2125a66eb..05528e0ee09 100644 --- a/tensorflow/core/kernels/data/multi_device_iterator_ops.cc +++ b/tensorflow/core/kernels/data/multi_device_iterator_ops.cc @@ -59,7 +59,7 @@ class MultiDeviceIterator : public ResourceBase { DCHECK(lib_ != nullptr); } - string DebugString() override { + string DebugString() const override { return strings::StrCat("MultiDeviceIterator for ", devices_.size(), " devices"); } diff --git a/tensorflow/core/kernels/data/shuffle_dataset_op.cc b/tensorflow/core/kernels/data/shuffle_dataset_op.cc index db0cc6fa4db..4c380c1fa2c 100644 --- a/tensorflow/core/kernels/data/shuffle_dataset_op.cc +++ b/tensorflow/core/kernels/data/shuffle_dataset_op.cc @@ -412,7 +412,7 @@ class ShuffleDatasetOp : public ShuffleDatasetOpBase { parent_generator_(seed, seed2), generator_(&parent_generator_) {} - string DebugString() override { + string DebugString() const override { return "ReshufflingDataset::RandomSeedGenerator"; } diff --git a/tensorflow/core/kernels/fifo_queue.h b/tensorflow/core/kernels/fifo_queue.h index 697ee81c39b..4d3a7c19712 100644 --- a/tensorflow/core/kernels/fifo_queue.h +++ b/tensorflow/core/kernels/fifo_queue.h @@ -49,7 +49,7 @@ class FIFOQueue : public TypedQueue > { CallbackWithTuple callback) override; Status MatchesNodeDef(const NodeDef& node_def) override; - int32 size() override { + int32 size() const override { mutex_lock lock(mu_); return queues_[0].size(); } diff --git a/tensorflow/core/kernels/map_stage_op.cc b/tensorflow/core/kernels/map_stage_op.cc index dd89597369b..27a8696e546 100644 --- a/tensorflow/core/kernels/map_stage_op.cc +++ b/tensorflow/core/kernels/map_stage_op.cc @@ -480,7 +480,7 @@ class StagingMap : public ResourceBase { return map_.size(); } - string DebugString() override { return "StagingMap"; } + string DebugString() const override { return "StagingMap"; } }; template diff --git a/tensorflow/core/kernels/meta_support.cc b/tensorflow/core/kernels/meta_support.cc index 39e60c9fcef..44f2997e182 100644 --- a/tensorflow/core/kernels/meta_support.cc +++ b/tensorflow/core/kernels/meta_support.cc @@ -54,7 +54,7 @@ class Scratch : public ResourceBase { uint8_t* buffer() { return scratch_32_aligned_; } - string DebugString() { return "MetaGemmScratchResource"; } + string DebugString() const override { return "MetaGemmScratchResource"; } private: std::unique_ptr scratch_; diff --git a/tensorflow/core/kernels/mutex_ops.cc b/tensorflow/core/kernels/mutex_ops.cc index ddb7a606c1a..1603a2aa869 100644 --- a/tensorflow/core/kernels/mutex_ops.cc +++ b/tensorflow/core/kernels/mutex_ops.cc @@ -45,7 +45,9 @@ class Mutex : public ResourceBase { VLOG(2) << "Creating mutex with name " << name << ": " << this; } - string DebugString() override { return strings::StrCat("Mutex ", name_); } + string DebugString() const override { + return strings::StrCat("Mutex ", name_); + } class LockReleaser { public: diff --git a/tensorflow/core/kernels/priority_queue.h b/tensorflow/core/kernels/priority_queue.h index 8e69b5b6990..a719c518c3e 100644 --- a/tensorflow/core/kernels/priority_queue.h +++ b/tensorflow/core/kernels/priority_queue.h @@ -68,7 +68,7 @@ class PriorityQueue Status MatchesPriorityNodeDefTypes(const NodeDef& node_def) const; Status MatchesPriorityNodeDefShapes(const NodeDef& node_def) const; - int32 size() override { + int32 size() const override { mutex_lock lock(mu_); return queues_[0].size(); } diff --git a/tensorflow/core/kernels/random_shuffle_queue_op.cc b/tensorflow/core/kernels/random_shuffle_queue_op.cc index 31e8ce944fe..02b9b022fdc 100644 --- a/tensorflow/core/kernels/random_shuffle_queue_op.cc +++ b/tensorflow/core/kernels/random_shuffle_queue_op.cc @@ -59,7 +59,7 @@ class RandomShuffleQueue : public TypedQueue > { CallbackWithTuple callback) override; Status MatchesNodeDef(const NodeDef& node_def) override; - int32 size() override { + int32 size() const override { mutex_lock lock(mu_); return queues_[0].size(); } diff --git a/tensorflow/core/kernels/sparse_tensors_map_ops.cc b/tensorflow/core/kernels/sparse_tensors_map_ops.cc index 74fa3a15f06..939638b3705 100644 --- a/tensorflow/core/kernels/sparse_tensors_map_ops.cc +++ b/tensorflow/core/kernels/sparse_tensors_map_ops.cc @@ -43,7 +43,7 @@ class SparseTensorsMap : public ResourceBase { public: explicit SparseTensorsMap(const string& name) : name_(name), counter_(0) {} - string DebugString() override { return "A SparseTensorsMap"; } + string DebugString() const override { return "A SparseTensorsMap"; } typedef struct { PersistentTensor indices; diff --git a/tensorflow/core/kernels/stack.cc b/tensorflow/core/kernels/stack.cc index 5c70a2d62d3..2af6b4b8148 100644 --- a/tensorflow/core/kernels/stack.cc +++ b/tensorflow/core/kernels/stack.cc @@ -96,7 +96,7 @@ class Stack : public ResourceBase { DataType ElemType() { return elem_type_; } - string DebugString() override { + string DebugString() const override { mutex_lock l(mu_); return strings::StrCat("Stack[", stack_name_, "]"); } diff --git a/tensorflow/core/kernels/stage_op.cc b/tensorflow/core/kernels/stage_op.cc index c91bdc43cf4..65174e163c1 100644 --- a/tensorflow/core/kernels/stage_op.cc +++ b/tensorflow/core/kernels/stage_op.cc @@ -132,7 +132,7 @@ class Buffer : public ResourceBase { notify_inserters_if_bounded(&lock); } - string DebugString() override { + string DebugString() const override { std::unique_lock lock(mu_); return strings::StrCat("Staging size: ", buf_.size()); } @@ -170,7 +170,7 @@ class Buffer : public ResourceBase { std::size_t capacity_; std::size_t memory_limit_; std::size_t current_bytes_; - std::mutex mu_; + mutable std::mutex mu_; std::condition_variable non_empty_cond_var_; std::condition_variable full_cond_var_; std::deque buf_; diff --git a/tensorflow/core/kernels/summary_op.cc b/tensorflow/core/kernels/summary_op.cc index 1f4e3418f48..1053aa7d53a 100644 --- a/tensorflow/core/kernels/summary_op.cc +++ b/tensorflow/core/kernels/summary_op.cc @@ -124,7 +124,9 @@ TF_CALL_REAL_NUMBER_TYPES(REGISTER) struct HistogramResource : public ResourceBase { histogram::ThreadSafeHistogram histogram; - string DebugString() override { return "A histogram summary. Stats ..."; } + string DebugString() const override { + return "A histogram summary. Stats ..."; + } }; class SummaryMergeOp : public OpKernel { diff --git a/tensorflow/core/kernels/tensor_array.h b/tensorflow/core/kernels/tensor_array.h index 384a63e9453..507ab459ca5 100644 --- a/tensorflow/core/kernels/tensor_array.h +++ b/tensorflow/core/kernels/tensor_array.h @@ -261,7 +261,7 @@ class TensorArray : public ResourceBase { return Status::OK(); } - string DebugString() override { + string DebugString() const override { mutex_lock l(mu_); CHECK(!closed_); return strings::StrCat("TensorArray[", tensors_.size(), "]"); @@ -376,7 +376,7 @@ class TensorArray : public ResourceBase { const DataType dtype_; Tensor handle_; - mutex mu_; + mutable mutex mu_; // Marks that the tensor_array_ has been cleared. bool closed_ GUARDED_BY(mu_); diff --git a/tensorflow/core/kernels/tensor_forest/resources.h b/tensorflow/core/kernels/tensor_forest/resources.h index da258e5017c..f0a78f97264 100644 --- a/tensorflow/core/kernels/tensor_forest/resources.h +++ b/tensorflow/core/kernels/tensor_forest/resources.h @@ -34,7 +34,7 @@ class TensorForestTreeResource : public ResourceBase { public: TensorForestTreeResource(); - string DebugString() override { + string DebugString() const override { return strings::StrCat("TensorForestTree[size=", get_size(), "]"); } diff --git a/tensorflow/core/kernels/variable_ops.cc b/tensorflow/core/kernels/variable_ops.cc index eadea18f760..00994bbe8e7 100644 --- a/tensorflow/core/kernels/variable_ops.cc +++ b/tensorflow/core/kernels/variable_ops.cc @@ -35,7 +35,7 @@ class LegacyVar : public ResourceBase { mutex* mu() { return &mu_; } Tensor* tensor() { return &tensor_; } - string DebugString() override { + string DebugString() const override { return strings::StrCat(DataTypeString(tensor_.dtype()), "/", tensor_.shape().DebugString()); } @@ -116,7 +116,7 @@ class TemporaryVariableOp : public OpKernel { mutex mu; Tensor val; string name; - string DebugString() override { return name; } + string DebugString() const override { return name; } ~TmpVar() override { VLOG(3) << "TmpVar " << name << " deleted"; } }; diff --git a/tensorflow/core/summary/summary_db_writer.cc b/tensorflow/core/summary/summary_db_writer.cc index 7a5d796821d..b203d439ccf 100644 --- a/tensorflow/core/summary/summary_db_writer.cc +++ b/tensorflow/core/summary/summary_db_writer.cc @@ -972,7 +972,7 @@ class SummaryDbWriter : public SummaryWriterInterface { return MigrateEvent(std::move(e)); } - string DebugString() override { return "SummaryDbWriter"; } + string DebugString() const override { return "SummaryDbWriter"; } private: Status Write(int64 step, const Tensor& t, const string& tag, diff --git a/tensorflow/core/summary/summary_file_writer.cc b/tensorflow/core/summary/summary_file_writer.cc index 593ccdd6844..711a7d3d100 100644 --- a/tensorflow/core/summary/summary_file_writer.cc +++ b/tensorflow/core/summary/summary_file_writer.cc @@ -148,7 +148,7 @@ class SummaryFileWriter : public SummaryWriterInterface { return Status::OK(); } - string DebugString() override { return "SummaryFileWriter"; } + string DebugString() const override { return "SummaryFileWriter"; } private: double GetWallTime() { diff --git a/tensorflow/python/framework/test_ops.cc b/tensorflow/python/framework/test_ops.cc index 99e184a8acd..1d0145f61c8 100644 --- a/tensorflow/python/framework/test_ops.cc +++ b/tensorflow/python/framework/test_ops.cc @@ -157,7 +157,7 @@ REGISTER_KERNEL_BUILDER(Name("Old").Device(DEVICE_CPU), OldOp); // Stubbed-out resource to test resource handle ops. class StubResource : public ResourceBase { public: - string DebugString() override { return ""; } + string DebugString() const override { return ""; } }; REGISTER_RESOURCE_HANDLE_KERNEL(StubResource);