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

Method alloc

csrc/aio/py_lib/deepspeed_pin_tensor.cpp:23–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23torch::Tensor deepspeed_pin_tensor_t::alloc(const int64_t num_elem,
24 const torch::TensorOptions& options)
25{
26 const auto scalar_dtype = torch::typeMetaToScalarType(options.dtype());
27 const auto num_bytes = num_elem * torch::elementSize(scalar_dtype);
28 auto pinned_buffer = ds_page_aligned_alloc(num_bytes, true);
29 assert(nullptr != pinned_buffer);
30
31 _locked_tensors[pinned_buffer] = num_bytes;
32
33 return at::from_blob(pinned_buffer, static_cast<int64_t>(num_elem), options);
34}
35
36torch::Tensor deepspeed_pin_tensor_t::alloc(const int64_t num_elem, const at::ScalarType& elem_type)
37{

Callers 2

_alloc_bounce_bufferMethod · 0.80
new_cpu_locked_tensorMethod · 0.80

Calls 3

ds_page_aligned_allocFunction · 0.85
dtypeMethod · 0.45
deviceMethod · 0.45

Tested by

no test coverage detected