allocator.hpp 502 Bytes
Newer Older
PanZezhong's avatar
PanZezhong committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef ALLOCATOR_HPP
#define ALLOCATOR_HPP

#include "infinicore_infer.h"

class AllocatorBase {
public:
    virtual void *alloc(size_t size) = 0;
    virtual void release(void *ptr) = 0;
};

class WorkspaceAllocator : public AllocatorBase {
private:
    void *_memory;
    size_t _total_size;
PanZezhong's avatar
PanZezhong committed
16
    size_t _align;
PanZezhong's avatar
PanZezhong committed
17
18
19
20
21
22
23
24
25

public:
    WorkspaceAllocator(size_t intial_size, size_t align = 256);
    ~WorkspaceAllocator();
    void *alloc(size_t size) override;
    void release(void *ptr) override;
};

#endif