Explicitly cast printed integer types to the primitive type so as to not implicitly rely on whether int64 is long or long long.
PiperOrigin-RevId: 316793291 Change-Id: I6eb74c5d7987fd7ece10e8eef26397e6dd58cf33
This commit is contained in:
parent
afb849aa36
commit
2bab28aecc
@ -2822,7 +2822,7 @@ class StatefulOutputRequiredOp : public OpKernel {
|
||||
void Compute(OpKernelContext* ctx) override {
|
||||
// The op counts the number of outputs required in the current subgraph,
|
||||
// and emits that number on each of its required outputs.
|
||||
Tensor count_outputs_required_t(0LL);
|
||||
Tensor count_outputs_required_t(int64{0});
|
||||
int64& count_outputs_required = count_outputs_required_t.scalar<int64>()();
|
||||
for (int i = 0; i < num_outputs(); ++i) {
|
||||
if (ctx->output_required(i)) ++count_outputs_required;
|
||||
|
@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
|
||||
#include "tensorflow/core/platform/env.h"
|
||||
@ -70,17 +71,18 @@ void PrintChunk(const MemChunk& mc, const uint64 ac_offset, bool freed_at,
|
||||
// A size class corresponding approximately to log base 100.
|
||||
int size_class = floor(0.5 * log10(static_cast<double>(mc.size())));
|
||||
*cumulative_bytes += mc.size();
|
||||
printf(" %c %d %p bin=%d bytes=%llu %3.1f%%", mc.in_use() ? 'U' : 'F',
|
||||
printf(" %c %d %p bin=%d bytes=%" PRIu64 " %3.1f%%", mc.in_use() ? 'U' : 'F',
|
||||
size_class, reinterpret_cast<const void*>(mc.address()), mc.bin(),
|
||||
mc.size(),
|
||||
static_cast<uint64_t>(mc.size()),
|
||||
100 * (*cumulative_bytes / static_cast<float>(total_bytes)));
|
||||
if (freed_at) {
|
||||
printf(" freed_at=%llu", mc.freed_at_count());
|
||||
printf(" freed_at=%" PRIu64, static_cast<uint64_t>(mc.freed_at_count()));
|
||||
}
|
||||
if (ac_offset > 0) {
|
||||
printf(" age=%llu", ac_offset - mc.action_count());
|
||||
printf(" age=%" PRIu64,
|
||||
static_cast<uint64_t>(ac_offset - mc.action_count()));
|
||||
} else {
|
||||
printf(" ac=%llu", mc.action_count());
|
||||
printf(" ac=%" PRIu64, static_cast<uint64_t>(mc.action_count()));
|
||||
}
|
||||
// step_ids are random, so save space by showing only low 16 bits.
|
||||
printf(" step=%x op=%s\n", static_cast<uint>(0xFFFF & mc.step_id()),
|
||||
@ -90,18 +92,24 @@ void PrintChunk(const MemChunk& mc, const uint64 ac_offset, bool freed_at,
|
||||
void PrintSummary(const MemoryDump& md) {
|
||||
printf("MemoryMap for allocator %s\n", md.allocator_name().c_str());
|
||||
for (auto& it : md.bin_summary()) {
|
||||
printf(
|
||||
" Bin %2d total bytes=%10lld \tin use=%10lld \ttotal_chunks=%6lld "
|
||||
"\tin_use=%6lld\n",
|
||||
it.bin(), it.total_bytes_in_bin(), it.total_bytes_in_use(),
|
||||
it.total_chunks_in_bin(), it.total_chunks_in_use());
|
||||
printf(" Bin %2d total bytes=%10" PRId64 " \tin use=%10" PRId64
|
||||
" \ttotal_chunks=%6" PRId64
|
||||
" "
|
||||
"\tin_use=%6" PRId64 "\n",
|
||||
it.bin(), static_cast<int64_t>(it.total_bytes_in_bin()),
|
||||
static_cast<int64_t>(it.total_bytes_in_use()),
|
||||
static_cast<int64_t>(it.total_chunks_in_bin()),
|
||||
static_cast<int64_t>(it.total_chunks_in_use()));
|
||||
}
|
||||
printf(
|
||||
"Total num_allocs: %lld, bytes_in_use: %lld, peak_bytes_in_use: %lld,\n"
|
||||
"largest_alloc_size: %lld, fragmentation: %f\n",
|
||||
md.stats().num_allocs(), md.stats().bytes_in_use(),
|
||||
md.stats().peak_bytes_in_use(), md.stats().largest_alloc_size(),
|
||||
md.stats().fragmentation_metric());
|
||||
printf("Total num_allocs: %" PRId64 ", bytes_in_use: %" PRId64
|
||||
", peak_bytes_in_use: %" PRId64
|
||||
",\n"
|
||||
"largest_alloc_size: %" PRId64 ", fragmentation: %f\n",
|
||||
static_cast<int64_t>(md.stats().num_allocs()),
|
||||
static_cast<int64_t>(md.stats().bytes_in_use()),
|
||||
static_cast<int64_t>(md.stats().peak_bytes_in_use()),
|
||||
static_cast<int64_t>(md.stats().largest_alloc_size()),
|
||||
md.stats().fragmentation_metric());
|
||||
}
|
||||
|
||||
void PrintSortedChunks(
|
||||
@ -125,10 +133,10 @@ void PrintSortedChunks(
|
||||
for (int i = 0; i < chunks.size(); ++i) {
|
||||
const MemChunk* c = chunks[i];
|
||||
if (by_addr && i > 0 && last_end != c->address()) {
|
||||
printf(" empty range from %p to %p (%lld)\n",
|
||||
printf(" empty range from %p to %p (%" PRId64 ")\n",
|
||||
reinterpret_cast<const void*>(last_end),
|
||||
reinterpret_cast<const void*>(c->address()),
|
||||
(c->address() - last_end));
|
||||
static_cast<int64_t>(c->address() - last_end));
|
||||
}
|
||||
PrintChunk(*c, max_action_count, freed_at, total_bytes, &cumulative_bytes);
|
||||
last_end = c->address() + c->size();
|
||||
@ -182,8 +190,8 @@ void PrintChunksByOpName(const MemoryDump& md, const string& op_name,
|
||||
total_bytes += it.size();
|
||||
}
|
||||
}
|
||||
printf("\t%d matching Chunks of total size %llu bytes:\n",
|
||||
filtered.chunk_size(), total_bytes);
|
||||
printf("\t%d matching Chunks of total size %" PRIu64 " bytes:\n",
|
||||
filtered.chunk_size(), static_cast<uint64_t>(total_bytes));
|
||||
PrintSortedChunks(
|
||||
filtered,
|
||||
[](const MemChunk* a, const MemChunk* b) {
|
||||
@ -205,10 +213,13 @@ void PrintSizeHistory(const MemoryDump& md, bool by_age) {
|
||||
}
|
||||
for (auto& it : md.snap_shot()) {
|
||||
if (by_age) {
|
||||
printf("\tage=%llu, size=%lld\n", max_action_count - it.action_count(),
|
||||
it.size());
|
||||
printf("\tage=%" PRIu64 ", size=%" PRId64 "\n",
|
||||
static_cast<uint64_t>(max_action_count - it.action_count()),
|
||||
static_cast<int64_t>(it.size()));
|
||||
} else {
|
||||
printf("\tac=%llu, size=%lld\n", it.action_count(), it.size());
|
||||
printf("\tac=%" PRIu64 ", size=%" PRId64 "\n",
|
||||
static_cast<uint64_t>(it.action_count()),
|
||||
static_cast<int64_t>(it.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,8 @@ Status SaveDatasetOp::WriteMetadataFile(Env* env, const std::string& path,
|
||||
uint64 num_elements, bool finalized) {
|
||||
SnapshotMetadataRecord metadata;
|
||||
metadata.set_creation_timestamp(EnvTime::NowMicros());
|
||||
metadata.set_run_id(strings::Printf("%llu", run_id));
|
||||
metadata.set_run_id(
|
||||
strings::Printf("%llu", static_cast<unsigned long long>(run_id)));
|
||||
metadata.set_version(kFileFormatVersion);
|
||||
for (const auto& output_dtype : output_dtypes) {
|
||||
metadata.add_dtype(output_dtype);
|
||||
|
@ -302,9 +302,11 @@ class MapAndBatchDatasetOp::Dataset : public DatasetBase {
|
||||
}
|
||||
auto result = dataset()->traceme_metadata_;
|
||||
result.push_back(std::make_pair(
|
||||
"max_batch_results", strings::Printf("%lld", max_batch_results)));
|
||||
result.push_back(
|
||||
std::make_pair("parallelism", strings::Printf("%lld", parallelism)));
|
||||
"max_batch_results",
|
||||
strings::Printf("%lld", static_cast<long long>(max_batch_results))));
|
||||
result.push_back(std::make_pair(
|
||||
"parallelism",
|
||||
strings::Printf("%lld", static_cast<long long>(parallelism))));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -50,11 +50,14 @@ namespace snapshot_util {
|
||||
CustomReader::kSnappyReaderOutputBufferSizeBytes;
|
||||
|
||||
std::string HashDirectory(const std::string& path, uint64 hash) {
|
||||
return io::JoinPath(path, strings::Printf("%llu", hash));
|
||||
return io::JoinPath(
|
||||
path, strings::Printf("%llu", static_cast<unsigned long long>(hash)));
|
||||
}
|
||||
|
||||
std::string RunDirectory(const std::string& hash_directory, uint64 run_id) {
|
||||
return RunDirectory(hash_directory, strings::Printf("%llu", run_id));
|
||||
return RunDirectory(
|
||||
hash_directory,
|
||||
strings::Printf("%llu", static_cast<unsigned long long>(run_id)));
|
||||
}
|
||||
|
||||
std::string RunDirectory(const std::string& hash_directory,
|
||||
@ -63,13 +66,17 @@ std::string RunDirectory(const std::string& hash_directory,
|
||||
}
|
||||
|
||||
std::string ShardDirectory(const std::string& run_directory, int64 shard_id) {
|
||||
return io::JoinPath(run_directory, strings::Printf("%08llu%s", shard_id,
|
||||
kShardDirectorySuffix));
|
||||
return io::JoinPath(
|
||||
run_directory,
|
||||
strings::Printf("%08llu%s", static_cast<unsigned long long>(shard_id),
|
||||
kShardDirectorySuffix));
|
||||
}
|
||||
std::string GetCheckpointFileName(const std::string& shard_directory,
|
||||
uint64 checkpoint_id) {
|
||||
return io::JoinPath(shard_directory,
|
||||
strings::Printf("%08llu.snapshot", checkpoint_id));
|
||||
return io::JoinPath(
|
||||
shard_directory,
|
||||
strings::Printf("%08llu.snapshot",
|
||||
static_cast<unsigned long long>(checkpoint_id)));
|
||||
}
|
||||
|
||||
Status Writer::Create(Env* env, const std::string& filename,
|
||||
|
@ -486,7 +486,7 @@ class CuptiTraceCollectorImpl : public CuptiTraceCollector {
|
||||
// Times 2 because HBM is DDR memory; it gets two data bits per each
|
||||
// data lane.
|
||||
auto memory_bandwidth =
|
||||
2ULL * (*mem_clock_khz) * 1000 * (*mem_bus_width_bits) / 8;
|
||||
uint64{2} * (*mem_clock_khz) * 1000 * (*mem_bus_width_bits) / 8;
|
||||
device_plane->AddStatValue(
|
||||
*device_plane->GetOrCreateStatMetadata(
|
||||
GetStatTypeStr(StatType::kDevCapMemoryBandwidth)),
|
||||
|
Loading…
Reference in New Issue
Block a user