npu_data.h Source File

npu_data.h Source File#

SDK qb Runtime Library: npu_data.h Source File
SDK qb Runtime Library v1.5
MCS001-KR
npu_data.h
Go to the documentation of this file.
1// Copyright ⓒ 2019- Mobilint, Inc. All rights reserved.
5
6#ifndef QBRUNTIME_NPU_DATA_H_
7#define QBRUNTIME_NPU_DATA_H_
8
9#include <cstdint>
10#include <memory>
11#include <string>
12#include <vector>
13
14#include "qbruntime/export.h"
16#include "qbruntime/type.h"
17
18namespace mobilint {
19
20class Accelerator;
21class Model;
22class ModelImpl;
24class NPUDataImpl;
25
30
59class QBRUNTIME_EXPORT NPUData {
60public:
61 NPUData(const NPUData& other) = default;
62 NPUData& operator=(const NPUData& rhs) = default;
63 NPUData(NPUData&& other) noexcept = default;
64 NPUData& operator=(NPUData&& rhs) noexcept = default;
65 ~NPUData() = default;
66
76
85
95 StatusCode copyFrom(NPUData& src);
96
108 template <typename T>
109 T* data(StatusCode& sc) const {
110 return reinterpret_cast<T*>(rawData(sc));
111 }
112
118 const std::vector<int64_t>& shape() const;
119
126
134 int devNo() const;
135
148 std::string deviceName() const;
149
150private:
151 explicit NPUData(std::shared_ptr<NPUDataImpl> impl);
152
153 void* rawData(StatusCode& sc) const;
154
155 std::shared_ptr<NPUDataImpl> mImpl;
156
157 friend class Model;
158 friend class ModelImpl;
159 friend class ModelVariantHandle;
160};
161
163
164} // namespace mobilint
165
166#endif // QBRUNTIME_NPU_DATA_H_
Represents an accelerator, i.e., an NPU, used for executing models.
Definition acc.h:40
Handle to a specific variant of a loaded model.
Represents an AI model loaded from an MXQ file.
Definition model.h:42
StatusCode launch(Accelerator &acc)
Uploads the data to the NPU memory associated with the given accelerator.
DataType dataType() const
Returns the element data type of the data.
std::string deviceName() const
Returns the hardware name (device type) of the accelerator the data resides on.
const std::vector< int64_t > & shape() const
Returns the shape of the data.
StatusCode copyFrom(NPUData &src)
Copies the data from another NPUData.
int devNo() const
Returns the device number of the accelerator the data resides on.
T * data(StatusCode &sc) const
Returns a typed pointer to the host (CPU) data.
Definition npu_data.h:109
StatusCode cpu()
Brings the data back to host (CPU) memory.
DataType
DataType.
Definition type.h:514
StatusCode
Enumerates status codes for the qbruntime.
Definition status_code.h:28