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

Method is_managed

csrc/aio/py_lib/deepspeed_pin_tensor.cpp:65–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65bool deepspeed_pin_tensor_t::is_managed(const torch::Tensor& buffer)
66{
67 if (!buffer.is_cpu()) { return false; }
68 std::lock_guard<std::mutex> guard(_mutex);
69 // Range check (not exact base match) so slices/views of a locked buffer are
70 // still recognized as pinned, matching torch's is_pinned() semantics. Require
71 // the buffer's full byte extent to fall within a single locked region; a buffer
72 // that starts inside a region but ends past it would have an unpinned tail.
73 const char* ptr = (char*)buffer.data_ptr();
74 const char* end = ptr + buffer.nbytes();
75 for (const auto& iter : _locked_tensors) {
76 const char* base = (char*)iter.first;
77 if (base <= ptr && end <= base + iter.second) { return true; }
78 }
79 return false;
80};

Callers 2

cpu_op_desc_tMethod · 0.80
is_pinnedMethod · 0.80

Calls 1

data_ptrMethod · 0.45

Tested by

no test coverage detected