| 89 | } |
| 90 | |
| 91 | void cpu_op_desc_t::_alloc_bounce_buffer() |
| 92 | { |
| 93 | auto options = torch::TensorOptions() |
| 94 | .dtype(_buffer.dtype()) |
| 95 | .layout(_buffer.layout()) |
| 96 | .device(torch::kCPU) |
| 97 | .requires_grad(false); |
| 98 | |
| 99 | #if defined(__CUDA_ARCH__) |
| 100 | _cpu_buffer = torch::empty(_buffer.numel(), options).pin_memory(); |
| 101 | #else |
| 102 | _is_managed_bounce_buffer = true; |
| 103 | _cpu_buffer = _pinned_tensor_mgr->alloc(_buffer.numel(), options); |
| 104 | #endif |
| 105 | // The copies to and from the buffer need its shape. |
| 106 | _cpu_buffer = _cpu_buffer.view(_buffer.sizes()); |
| 107 | } |
| 108 | |
| 109 | void cpu_op_desc_t::_free_bounce_buffer() |
| 110 | { |