1 /* Copyright 2019 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #ifndef TENSORFLOW_STREAM_EXECUTOR_ALLOCATOR_STATS_H_ 17 #define TENSORFLOW_STREAM_EXECUTOR_ALLOCATOR_STATS_H_ 18 19 #include <string> 20 21 #include "absl/types/optional.h" 22 #include "tensorflow/stream_executor/platform/port.h" 23 24 namespace stream_executor { 25 26 // Runtime statistics collected by an allocator. Exactly the same as 27 // tensorflow::AllocatorStats, but independently defined to preserve the mutual 28 // independence of StreamExecutor and TensorFlow. 29 struct AllocatorStats { 30 int64 num_allocs; // Number of allocations. 31 int64 bytes_in_use; // Number of bytes in use. 32 int64 peak_bytes_in_use; // The peak bytes in use. 33 int64 largest_alloc_size; // The largest single allocation seen. 34 35 // The upper limit of bytes of user allocatable device memory, if such a limit 36 // is known. 37 absl::optional<int64> bytes_limit; 38 AllocatorStatsAllocatorStats39 AllocatorStats() 40 : num_allocs(0), 41 bytes_in_use(0), 42 peak_bytes_in_use(0), 43 largest_alloc_size(0) {} 44 45 string DebugString() const; 46 }; 47 48 } // namespace stream_executor 49 50 #endif // TENSORFLOW_STREAM_EXECUTOR_ALLOCATOR_STATS_H_ 51