MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / MemoryDebugString

Method MemoryDebugString

tensorflow/core/common_runtime/gpu/gpu_util.cc:414–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412}
413
414string GPUUtil::MemoryDebugString(const Device* device, Tensor* tensor) {
415 string ret;
416 CHECK(tensor);
417 const int64 num_bytes = std::min<int64>(
418 FLAGS_brain_gpu_util_debug_string_maxlen, tensor->TotalBytes());
419 void* ptr = (num_bytes > 0) ? GetBase(tensor) : nullptr;
420 strings::Appendf(&ret, "%p:", ptr);
421 if (num_bytes > 0) {
422 auto* dev_info = device->tensorflow_gpu_device_info();
423 if (!dev_info) {
424 strings::StrAppend(
425 &ret, PrintMemory(reinterpret_cast<const char*>(ptr), num_bytes));
426 } else {
427 string buf;
428 buf.resize(num_bytes);
429 DeviceMemoryBase gpu_ptr(ptr, num_bytes);
430 auto s = dev_info->stream->parent()->SynchronousMemcpyD2H(
431 gpu_ptr, num_bytes, gtl::string_as_array(&buf));
432 strings::StrAppend(&ret,
433 PrintMemory(gtl::string_as_array(&buf), num_bytes));
434 }
435 }
436 return ret;
437}
438
439// TODO(pbar) Checksum is called from places without a valid device context.
440uint64 GPUUtil::Checksum(Device* gpu_device,

Callers

nothing calls this directly

Calls 10

AppendfFunction · 0.85
PrintMemoryFunction · 0.85
string_as_arrayFunction · 0.85
GetBaseFunction · 0.70
StrAppendFunction · 0.50
TotalBytesMethod · 0.45
resizeMethod · 0.45
SynchronousMemcpyD2HMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected