| 37 | } |
| 38 | |
| 39 | se::DeviceMemoryBase WrapRedzoneBestEffort( |
| 40 | se::cuda::RedzoneAllocator* rz_allocator, se::DeviceMemoryBase buffer) { |
| 41 | if (RedzoneCheckDisabled()) { |
| 42 | return buffer; |
| 43 | } |
| 44 | se::DeviceMemoryBase output_tensor; |
| 45 | auto output_rz_or = rz_allocator->AllocateBytes(buffer.size()); |
| 46 | if (!output_rz_or.ok()) { |
| 47 | static std::once_flag rz_allocation_failure_logged; |
| 48 | std::call_once(rz_allocation_failure_logged, []() { |
| 49 | LOG(WARNING) << "Failed to allocate memory for convolution redzone " |
| 50 | << "checking; skipping this check. This is benign and only " |
| 51 | << "means that we won't check cudnn for out-of-bounds reads " |
| 52 | << "and writes. This message will only be printed once."; |
| 53 | }); |
| 54 | return buffer; |
| 55 | } |
| 56 | return se::DeviceMemoryBase(output_rz_or.ValueOrDie()); |
| 57 | } |
| 58 | |
| 59 | template<typename T> |
| 60 | void CheckRedzones(const se::cuda::RedzoneAllocator& rz_allocator, |
no test coverage detected