MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / _alloc_bounce_buffer

Method _alloc_bounce_buffer

csrc/aio/py_lib/deepspeed_cpu_op.cpp:91–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91void 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
109void cpu_op_desc_t::_free_bounce_buffer()
110{

Callers

nothing calls this directly

Calls 6

allocMethod · 0.80
deviceMethod · 0.45
dtypeMethod · 0.45
pin_memoryMethod · 0.45
numelMethod · 0.45
sizesMethod · 0.45

Tested by

no test coverage detected