| 40 | } |
| 41 | |
| 42 | torch::Tensor deepspeed_pin_tensor_t::alloc(const int64_t num_elem, |
| 43 | const torch::TensorOptions& options) |
| 44 | { |
| 45 | const auto scalar_dtype = torch::typeMetaToScalarType(options.dtype()); |
| 46 | const auto num_bytes = num_elem * torch::elementSize(scalar_dtype); |
| 47 | auto pinned_buffer = ds_page_aligned_alloc(num_bytes, true); |
| 48 | assert(nullptr != pinned_buffer); |
| 49 | |
| 50 | { |
| 51 | std::lock_guard<std::mutex> guard(_mutex); |
| 52 | _locked_tensors[pinned_buffer] = num_bytes; |
| 53 | } |
| 54 | |
| 55 | return at::from_blob(pinned_buffer, static_cast<int64_t>(num_elem), options); |
| 56 | } |
| 57 | |
| 58 | torch::Tensor deepspeed_pin_tensor_t::alloc(const int64_t num_elem, const at::ScalarType& elem_type) |
| 59 | { |
no test coverage detected