| 21 | } |
| 22 | |
| 23 | torch::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 | |
| 36 | torch::Tensor deepspeed_pin_tensor_t::alloc(const int64_t num_elem, const at::ScalarType& elem_type) |
| 37 | { |
no test coverage detected