deepspeed_pin_tensor.h 722 Bytes
Newer Older
aiss's avatar
aiss committed
1
2
3
4
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0

// DeepSpeed Team
aiss's avatar
aiss committed
5

aiss's avatar
aiss committed
6
/*
aiss's avatar
aiss committed
7
8
Functionality for managing CPU tensors occupying page-locked memory.
TODO: Implement a full-featured manager that
aiss's avatar
aiss committed
9
10
11
1. Avoid page-locked memory leaks
2. Minimize page-locked memory usage by reducing internal fragmentation
Functionality for managing CPU tensors occupying page-locked memory.
aiss's avatar
aiss committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
*/

#include <map>
#include "deepspeed_py_aio.h"

struct deepspeed_pin_tensor_t {
    std::map<void*, size_t> _locked_tensors;

    deepspeed_pin_tensor_t() = default;

    ~deepspeed_pin_tensor_t();

    torch::Tensor alloc(const size_t num_elem, const at::ScalarType& elem_type);

    bool free(torch::Tensor& locked_tensor);
};