pinned_memory.h Source File

pinned_memory.h Source File#

SDK qb Runtime Library: pinned_memory.h Source File
SDK qb Runtime Library v1.3
MCS001-EN
pinned_memory.h
Go to the documentation of this file.
1// Copyright ⓒ 2019- Mobilint Inc. All rights reserved.
5
6#ifndef QBRUNTIME_PINNED_MEMORY_H_
7#define QBRUNTIME_PINNED_MEMORY_H_
8
9#include <stdint.h>
10
11#include <memory>
12#include <vector>
13
14#include "qbruntime/export.h"
15
16namespace mobilint {
21
22class PinnedMemoryImpl;
23
55template <typename T>
56class QBRUNTIME_EXPORT PinnedMemory {
57public:
58 PinnedMemory() = delete;
59 ~PinnedMemory();
60 PinnedMemory(const PinnedMemory& other);
61 PinnedMemory& operator=(const PinnedMemory& other);
62 PinnedMemory(PinnedMemory&& other) noexcept;
63 PinnedMemory& operator=(PinnedMemory&& other) noexcept;
64
71 T* data() const;
72
79 const std::vector<int64_t>& shape() const;
80
86 uint64_t size() const;
87
96 bool isAvailable() const;
97
99
128 PinnedMemory(const std::vector<int64_t>& shape, uint64_t phys_addr, void* mapped_ptr);
130
131private:
132 PinnedMemory(std::shared_ptr<PinnedMemoryImpl> pinned_memory_impl);
133
134 std::shared_ptr<PinnedMemoryImpl> mImpl;
135
136 friend class PinnedMemoryImpl;
137 friend class ModelImpl;
138 friend class AcceleratorImpl;
139};
140
141} // namespace mobilint
142
143#endif // QBRUNTIME_PINNED_MEMORY_H_
const std::vector< int64_t > & shape() const
Returns the shape of the buffer.
uint64_t size() const
Returns the size of the buffer in bytes.
bool isAvailable() const
Checks whether the buffer is allocated and still usable.
T * data() const
Returns a pointer to the host-mapped buffer.