diff --git a/tensorflow/core/common_runtime/bfc_allocator.h b/tensorflow/core/common_runtime/bfc_allocator.h index 94506bb3b7e..2917f8f63dc 100644 --- a/tensorflow/core/common_runtime/bfc_allocator.h +++ b/tensorflow/core/common_runtime/bfc_allocator.h @@ -124,12 +124,12 @@ class BFCAllocator : public Allocator { // A ChunkHandle is an index into the chunks_ vector in BFCAllocator // kInvalidChunkHandle means an invalid chunk typedef size_t ChunkHandle; - static const int kInvalidChunkHandle = -1; + static constexpr int kInvalidChunkHandle = -1; typedef int BinNum; - static const int kInvalidBinNum = -1; + static constexpr int kInvalidBinNum = -1; // The following means that the largest bin'd chunk size is 256 << 21 = 512MB. - static const int kNumBins = 21; + static constexpr int kNumBins = 21; // A Chunk points to a piece of memory that's either entirely free or entirely // in use by one user memory allocation. @@ -243,8 +243,8 @@ class BFCAllocator : public Allocator { : bin_size(bs), free_chunks(ChunkComparator(allocator)) {} }; - static const size_t kMinAllocationBits = 8; - static const size_t kMinAllocationSize = 1 << kMinAllocationBits; + static constexpr size_t kMinAllocationBits = 8; + static constexpr size_t kMinAllocationSize = 1 << kMinAllocationBits; // BFCAllocator allocates memory into a collection of disjoint // AllocationRegions. Each AllocationRegion corresponds to one call to diff --git a/tensorflow/core/common_runtime/build_graph_options.h b/tensorflow/core/common_runtime/build_graph_options.h index 24b71cc741d..4bc953d5ce4 100644 --- a/tensorflow/core/common_runtime/build_graph_options.h +++ b/tensorflow/core/common_runtime/build_graph_options.h @@ -32,7 +32,7 @@ struct BuildGraphOptions { // TODO(mrry): Remove this when the distributed runtime supports Arg/Retval. bool use_function_convention = false; - static const int64 kNoCollectiveGraphKey = 0; + static constexpr int64 kNoCollectiveGraphKey = 0; int64 collective_graph_key = kNoCollectiveGraphKey; // If not `kNone`, order all CollectiveReduce operations statically and diff --git a/tensorflow/core/common_runtime/executor.cc b/tensorflow/core/common_runtime/executor.cc index ebed9569309..1f2a364258f 100644 --- a/tensorflow/core/common_runtime/executor.cc +++ b/tensorflow/core/common_runtime/executor.cc @@ -200,9 +200,9 @@ class ExecutorImpl : public Executor { // Initial time (in CPU cycles) we expect an operation to take. Used to // determine whether an operation should be place in a threadpool. // Operations start out "expensive". - static const uint64 kInitialCostEstimateCycles = 100 * 1000 * 1000; - static const uint64 kOpIsExpensiveThresholdCycles = 5000; - static const uint64 kCostDecay = 10; + static constexpr uint64 kInitialCostEstimateCycles = 100 * 1000 * 1000; + static constexpr uint64 kOpIsExpensiveThresholdCycles = 5000; + static constexpr uint64 kCostDecay = 10; std::unique_ptr[]> is_expensive_; std::unique_ptr cost_estimates_; diff --git a/tensorflow/core/common_runtime/pending_counts.h b/tensorflow/core/common_runtime/pending_counts.h index b4338af6fde..46b6509390f 100644 --- a/tensorflow/core/common_runtime/pending_counts.h +++ b/tensorflow/core/common_runtime/pending_counts.h @@ -261,7 +261,7 @@ class PendingCounts { // Each frame in this subgraph has its own PendingCounts. // We use 3 bits each for dead_count and pending. - static const int kMaxCountForPackedCounts = 7; + static constexpr int kMaxCountForPackedCounts = 7; // Most counts are small, so we pack a pending count and a dead // count into 3 bits each, use 1 bit to indicate that the node has diff --git a/tensorflow/core/common_runtime/process_state.h b/tensorflow/core/common_runtime/process_state.h index a106a934677..a833c22db1c 100644 --- a/tensorflow/core/common_runtime/process_state.h +++ b/tensorflow/core/common_runtime/process_state.h @@ -84,8 +84,8 @@ class ProcessState : public ProcessStateInterface { // If these flags need to be runtime configurable consider adding // them to ConfigProto. - static const bool FLAGS_brain_mem_reg_gpu_dma = true; - static const bool FLAGS_brain_gpu_record_mem_types = false; + static constexpr bool FLAGS_brain_mem_reg_gpu_dma = true; + static constexpr bool FLAGS_brain_gpu_record_mem_types = false; // Helper method for unit tests to reset the ProcessState singleton by // cleaning up everything. Never use in production. diff --git a/tensorflow/core/common_runtime/scoped_allocator.h b/tensorflow/core/common_runtime/scoped_allocator.h index 8ab5ee038c8..f25bee45b01 100644 --- a/tensorflow/core/common_runtime/scoped_allocator.h +++ b/tensorflow/core/common_runtime/scoped_allocator.h @@ -27,8 +27,8 @@ class ScopedAllocatorInstance; // Manages a single backing tensor and a collection of aliases. class ScopedAllocator { public: - static const int32 kInvalidId = 0; - static const size_t kMaxAlignment = 64; + static constexpr int32 kInvalidId = 0; + static constexpr size_t kMaxAlignment = 64; // A subrange of the TensorBuffer associated with this object that // will be the backing memory for one aliased tensor. @@ -39,7 +39,7 @@ class ScopedAllocator { size_t bytes_allocated; }; // Field index that refers to backing tensor, not any aliased field. - static const int32 kBackingIndex = -1; + static constexpr int32 kBackingIndex = -1; // backing_tensor is expected to be newly allocated by a ScopedAllocatorOp // instance. It must be large enough to back all of the specified diff --git a/tensorflow/core/common_runtime/step_stats_collector.h b/tensorflow/core/common_runtime/step_stats_collector.h index f2789c729b9..32df65f6482 100644 --- a/tensorflow/core/common_runtime/step_stats_collector.h +++ b/tensorflow/core/common_runtime/step_stats_collector.h @@ -188,7 +188,7 @@ class StepStatsCollector : public StepStatsCollectorInterface { private: // TODO(suharshs): Make this configurable if its not possible to find a value // that works for all cases. - static const uint64 kMaxCollectedNodes = 1 << 20; + static constexpr uint64 kMaxCollectedNodes = 1 << 20; typedef std::vector> NodeStatsVector; typedef std::unordered_map ThreadNamesMap;