blob: 4457e3f387d0cd49872226f20de1b4b55ba95dc1 [file] [log] [blame]
Kristofer Jonsson116a6352020-08-20 17:25:23 +02001/*
Anton Moberg4e5e0562021-03-31 11:11:36 +02002 * Copyright (c) 2020-2021 Arm Limited. All rights reserved.
Kristofer Jonsson116a6352020-08-20 17:25:23 +02003 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
Kristofer Jonssonb74492c2020-09-10 13:26:01 +020019#include "autogen/tflite_schema.hpp"
20
Kristofer Jonsson116a6352020-08-20 17:25:23 +020021#include <ethosu.hpp>
22#include <uapi/ethosu.h>
23
24#include <algorithm>
25#include <exception>
26#include <iostream>
27
Kristofer Jonsson116a6352020-08-20 17:25:23 +020028#include <fcntl.h>
29#include <poll.h>
Kristofer Jonsson79689c52020-10-16 14:42:19 +020030#include <sys/ioctl.h>
31#include <sys/mman.h>
Kristofer Jonsson116a6352020-08-20 17:25:23 +020032#include <unistd.h>
33
34using namespace std;
35
Per Åstrandec3f2b02021-06-09 10:43:38 +020036namespace EthosU {
37__attribute__((weak)) int eioctl(int fd, unsigned long cmd, void *data = nullptr) {
Kristofer Jonsson116a6352020-08-20 17:25:23 +020038 int ret = ::ioctl(fd, cmd, data);
Kristofer Jonsson79689c52020-10-16 14:42:19 +020039 if (ret < 0) {
Kristofer Jonsson116a6352020-08-20 17:25:23 +020040 throw EthosU::Exception("IOCTL failed");
41 }
42
43 return ret;
44}
Kristofer Jonssonb74492c2020-09-10 13:26:01 +020045
Per Åstrandec3f2b02021-06-09 10:43:38 +020046__attribute__((weak)) int eopen(const char *pathname, int flags) {
47 int fd = ::open(pathname, flags);
Per Åstrandec3f2b02021-06-09 10:43:38 +020048 if (fd < 0) {
49 throw Exception("Failed to open device");
50 }
51
52 return fd;
53}
54
55__attribute__((weak)) int epoll(struct pollfd *fds, nfds_t nfds, int timeout) {
Davide Grohmannc90bfab2021-10-19 13:59:27 +020056 int result = ::poll(fds, nfds, timeout);
57 if (result < 0) {
58 throw Exception("Failed to wait for poll event");
59 }
60
61 return result;
Per Åstrandec3f2b02021-06-09 10:43:38 +020062}
63
64__attribute__((weak)) int eclose(int fd) {
Davide Grohmannc90bfab2021-10-19 13:59:27 +020065 int result = ::close(fd);
66 if (result < 0) {
67 throw Exception("Failed to close file");
68 }
69
70 return result;
Per Åstrandec3f2b02021-06-09 10:43:38 +020071}
72__attribute((weak)) void *emmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) {
Davide Grohmannc90bfab2021-10-19 13:59:27 +020073 void *ptr = ::mmap(addr, length, prot, flags, fd, offset);
74 if (ptr == MAP_FAILED) {
75 throw Exception("Failed to mmap file");
76 }
77
78 return ptr;
Per Åstrandec3f2b02021-06-09 10:43:38 +020079}
80
81__attribute__((weak)) int emunmap(void *addr, size_t length) {
Davide Grohmannc90bfab2021-10-19 13:59:27 +020082 int result = ::munmap(addr, length);
83 if (result < 0) {
84 throw Exception("Failed to munmap file");
85 }
86
87 return result;
Per Åstrandec3f2b02021-06-09 10:43:38 +020088}
89
90} // namespace EthosU
91
Kristofer Jonssonb74492c2020-09-10 13:26:01 +020092/****************************************************************************
93 * TFL micro helpers
94 ****************************************************************************/
Per Åstrandec3f2b02021-06-09 10:43:38 +020095namespace {
Kristofer Jonsson79689c52020-10-16 14:42:19 +020096size_t getShapeSize(const flatbuffers::Vector<int32_t> *shape) {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +020097 size_t size = 1;
Kristofer Jonsson79689c52020-10-16 14:42:19 +020098
Jonny Svärd2c017132021-04-12 15:56:44 +020099 if (shape == nullptr) {
100 throw EthosU::Exception("getShapeSize(): nullptr arg");
101 }
102
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200103 for (auto it = shape->begin(); it != shape->end(); ++it) {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200104 size *= *it;
105 }
106
107 return size;
108}
109
Kristofer Jonsson5e632c22020-11-25 10:58:38 +0100110size_t getTensorTypeSize(const enum tflite::TensorType type) {
111 switch (type) {
112 case tflite::TensorType::TensorType_UINT8:
113 case tflite::TensorType::TensorType_INT8:
114 return 1;
115 case tflite::TensorType::TensorType_INT16:
116 return 2;
Henrik Hoglind031f4c12021-03-25 08:32:23 +0100117 case tflite::TensorType::TensorType_FLOAT32:
118 return 4;
Kristofer Jonsson5e632c22020-11-25 10:58:38 +0100119 default:
120 throw EthosU::Exception("Unsupported tensor type");
121 }
122}
123
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200124vector<size_t> getSubGraphDims(const tflite::SubGraph *subgraph, const flatbuffers::Vector<int32_t> *tensorMap) {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200125 vector<size_t> dims;
126
Jonny Svärd2c017132021-04-12 15:56:44 +0200127 if (subgraph == nullptr || tensorMap == nullptr) {
128 throw EthosU::Exception("getSubGraphDims(): nullptr arg(s)");
129 }
130
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200131 for (auto index = tensorMap->begin(); index != tensorMap->end(); ++index) {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200132 auto tensor = subgraph->tensors()->Get(*index);
133 size_t size = getShapeSize(tensor->shape());
Kristofer Jonsson5e632c22020-11-25 10:58:38 +0100134 size *= getTensorTypeSize(tensor->type());
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200135
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200136 if (size > 0) {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200137 dims.push_back(size);
138 }
139 }
140
141 return dims;
142}
143
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200144} // namespace
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200145
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200146namespace EthosU {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200147
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200148/****************************************************************************
149 * Exception
150 ****************************************************************************/
151
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200152Exception::Exception(const char *msg) : msg(msg) {}
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200153
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200154Exception::~Exception() throw() {}
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200155
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200156const char *Exception::what() const throw() {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200157 return msg.c_str();
158}
159
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200160/****************************************************************************
Davide Grohmann35ce6c82021-06-01 15:03:51 +0200161 * Semantic Version
162 ****************************************************************************/
163
164bool SemanticVersion::operator==(const SemanticVersion &other) {
165 return other.major == major && other.minor == minor && other.patch == patch;
166}
167
168bool SemanticVersion::operator<(const SemanticVersion &other) {
169 if (other.major > major)
170 return true;
171 if (other.minor > minor)
172 return true;
173 return other.patch > patch;
174}
175
176bool SemanticVersion::operator<=(const SemanticVersion &other) {
177 return *this < other || *this == other;
178}
179
180bool SemanticVersion::operator!=(const SemanticVersion &other) {
181 return !(*this == other);
182}
183
184bool SemanticVersion::operator>(const SemanticVersion &other) {
185 return !(*this <= other);
186}
187
188bool SemanticVersion::operator>=(const SemanticVersion &other) {
189 return !(*this < other);
190}
191
192ostream &operator<<(ostream &out, const SemanticVersion &v) {
193 return out << "{ major=" << unsigned(v.major) << ", minor=" << unsigned(v.minor) << ", patch=" << unsigned(v.patch)
194 << " }";
195}
196
197/****************************************************************************
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200198 * Device
199 ****************************************************************************/
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200200Device::Device(const char *device) {
Per Åstrandec3f2b02021-06-09 10:43:38 +0200201 fd = eopen(device, O_RDWR | O_NONBLOCK);
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200202}
203
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200204Device::~Device() {
Per Åstrandec3f2b02021-06-09 10:43:38 +0200205 eclose(fd);
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200206}
207
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200208int Device::ioctl(unsigned long cmd, void *data) {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200209 return eioctl(fd, cmd, data);
210}
211
Davide Grohmann35ce6c82021-06-01 15:03:51 +0200212Capabilities Device::capabilities() {
213 ethosu_uapi_device_capabilities uapi;
214 (void)eioctl(fd, ETHOSU_IOCTL_CAPABILITIES_REQ, static_cast<void *>(&uapi));
215
216 Capabilities capabilities(
217 HardwareId(uapi.hw_id.version_status,
218 SemanticVersion(uapi.hw_id.version_major, uapi.hw_id.version_minor),
219 SemanticVersion(uapi.hw_id.product_major),
220 SemanticVersion(uapi.hw_id.arch_major_rev, uapi.hw_id.arch_minor_rev, uapi.hw_id.arch_patch_rev)),
Davide Grohmann40e23d12021-06-17 09:59:40 +0200221 HardwareConfiguration(uapi.hw_cfg.macs_per_cc, uapi.hw_cfg.cmd_stream_version, bool(uapi.hw_cfg.custom_dma)),
Davide Grohmann35ce6c82021-06-01 15:03:51 +0200222 SemanticVersion(uapi.driver_major_rev, uapi.driver_minor_rev, uapi.driver_patch_rev));
223 return capabilities;
224}
225
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200226/****************************************************************************
227 * Buffer
228 ****************************************************************************/
229
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200230Buffer::Buffer(Device &device, const size_t capacity) : fd(-1), dataPtr(nullptr), dataCapacity(capacity) {
231 ethosu_uapi_buffer_create uapi = {static_cast<uint32_t>(dataCapacity)};
232 fd = device.ioctl(ETHOSU_IOCTL_BUFFER_CREATE, static_cast<void *>(&uapi));
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200233
Per Åstrandec3f2b02021-06-09 10:43:38 +0200234 void *d = emmap(nullptr, dataCapacity, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200235 dataPtr = reinterpret_cast<char *>(d);
236}
237
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200238Buffer::~Buffer() {
Per Åstrandec3f2b02021-06-09 10:43:38 +0200239 emunmap(dataPtr, dataCapacity);
240 eclose(fd);
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200241}
242
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200243size_t Buffer::capacity() const {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200244 return dataCapacity;
245}
246
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200247void Buffer::clear() {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200248 resize(0, 0);
249}
250
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200251char *Buffer::data() {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200252 return dataPtr + offset();
253}
254
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200255void Buffer::resize(size_t size, size_t offset) {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200256 ethosu_uapi_buffer uapi;
257 uapi.offset = offset;
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200258 uapi.size = size;
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200259 eioctl(fd, ETHOSU_IOCTL_BUFFER_SET, static_cast<void *>(&uapi));
260}
261
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200262size_t Buffer::offset() const {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200263 ethosu_uapi_buffer uapi;
264 eioctl(fd, ETHOSU_IOCTL_BUFFER_GET, static_cast<void *>(&uapi));
265 return uapi.offset;
266}
267
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200268size_t Buffer::size() const {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200269 ethosu_uapi_buffer uapi;
270 eioctl(fd, ETHOSU_IOCTL_BUFFER_GET, static_cast<void *>(&uapi));
271 return uapi.size;
272}
273
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200274int Buffer::getFd() const {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200275 return fd;
276}
277
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200278/****************************************************************************
279 * Network
280 ****************************************************************************/
281
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200282Network::Network(Device &device, shared_ptr<Buffer> &buffer) : fd(-1), buffer(buffer) {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200283 // Create buffer handle
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200284 ethosu_uapi_network_create uapi;
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200285 uapi.fd = buffer->getFd();
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200286 fd = device.ioctl(ETHOSU_IOCTL_NETWORK_CREATE, static_cast<void *>(&uapi));
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200287
288 // Create model handle
289 const tflite::Model *model = tflite::GetModel(reinterpret_cast<void *>(buffer->data()));
290
Jonny Svärd2c017132021-04-12 15:56:44 +0200291 if (model->subgraphs() == nullptr) {
292 throw EthosU::Exception("Failed to get subgraphs: nullptr");
293 }
294
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200295 // Get input dimensions for first subgraph
296 auto *subgraph = *model->subgraphs()->begin();
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200297 ifmDims = getSubGraphDims(subgraph, subgraph->inputs());
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200298
299 // Get output dimensions for last subgraph
300 subgraph = *model->subgraphs()->rbegin();
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200301 ofmDims = getSubGraphDims(subgraph, subgraph->outputs());
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200302}
303
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200304Network::~Network() {
Per Åstrandec3f2b02021-06-09 10:43:38 +0200305 eclose(fd);
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200306}
307
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200308int Network::ioctl(unsigned long cmd, void *data) {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200309 return eioctl(fd, cmd, data);
310}
311
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200312shared_ptr<Buffer> Network::getBuffer() {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200313 return buffer;
314}
315
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200316const std::vector<size_t> &Network::getIfmDims() const {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200317 return ifmDims;
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200318}
319
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200320size_t Network::getIfmSize() const {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200321 size_t size = 0;
322
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200323 for (auto s : ifmDims) {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200324 size += s;
325 }
326
327 return size;
328}
329
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200330const std::vector<size_t> &Network::getOfmDims() const {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200331 return ofmDims;
332}
333
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200334size_t Network::getOfmSize() const {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200335 size_t size = 0;
336
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200337 for (auto s : ofmDims) {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200338 size += s;
339 }
340
341 return size;
342}
343
344/****************************************************************************
345 * Inference
346 ****************************************************************************/
347
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200348Inference::~Inference() {
Per Åstrandec3f2b02021-06-09 10:43:38 +0200349 eclose(fd);
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200350}
351
Per Åstrand2354d3e2020-10-24 20:17:10 +0200352void Inference::create(std::vector<uint32_t> &counterConfigs, bool cycleCounterEnable = false) {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200353 ethosu_uapi_inference_create uapi;
354
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200355 if (ifmBuffers.size() > ETHOSU_FD_MAX) {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200356 throw Exception("IFM buffer overflow");
357 }
358
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200359 if (ofmBuffers.size() > ETHOSU_FD_MAX) {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200360 throw Exception("OFM buffer overflow");
361 }
362
Per Åstrand2354d3e2020-10-24 20:17:10 +0200363 if (counterConfigs.size() != ETHOSU_PMU_EVENT_MAX) {
364 throw Exception("Wrong size of counter configurations");
365 }
366
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200367 uapi.ifm_count = 0;
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200368 for (auto it : ifmBuffers) {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200369 uapi.ifm_fd[uapi.ifm_count++] = it->getFd();
370 }
371
372 uapi.ofm_count = 0;
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200373 for (auto it : ofmBuffers) {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200374 uapi.ofm_fd[uapi.ofm_count++] = it->getFd();
375 }
376
Per Åstrand2354d3e2020-10-24 20:17:10 +0200377 for (int i = 0; i < ETHOSU_PMU_EVENT_MAX; i++) {
378 uapi.pmu_config.events[i] = counterConfigs[i];
379 }
380
381 uapi.pmu_config.cycle_count = cycleCounterEnable;
382
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200383 fd = network->ioctl(ETHOSU_IOCTL_INFERENCE_CREATE, static_cast<void *>(&uapi));
384}
385
Per Åstrand2354d3e2020-10-24 20:17:10 +0200386std::vector<uint32_t> Inference::initializeCounterConfig() {
387 return std::vector<uint32_t>(ETHOSU_PMU_EVENT_MAX, 0);
388}
389
390uint32_t Inference::getMaxPmuEventCounters() {
391 return ETHOSU_PMU_EVENT_MAX;
392}
393
394int Inference::wait(int timeoutSec) {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200395 pollfd pfd;
396
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200397 pfd.fd = fd;
398 pfd.events = POLLIN | POLLERR;
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200399 pfd.revents = 0;
400
Per Åstrandec3f2b02021-06-09 10:43:38 +0200401 int ret = epoll(&pfd, 1, timeoutSec * 1000);
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200402
403 cout << "Poll. ret=" << ret << ", revents=" << pfd.revents << endl;
Per Åstrand2354d3e2020-10-24 20:17:10 +0200404
405 return ret;
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200406}
407
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200408bool Inference::failed() {
Per Åstrand2354d3e2020-10-24 20:17:10 +0200409 ethosu_uapi_result_status uapi;
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200410
Per Åstrand2354d3e2020-10-24 20:17:10 +0200411 eioctl(fd, ETHOSU_IOCTL_INFERENCE_STATUS, static_cast<void *>(&uapi));
412
413 return uapi.status != ETHOSU_UAPI_STATUS_OK;
414}
415
416const std::vector<uint32_t> Inference::getPmuCounters() {
417 ethosu_uapi_result_status uapi;
418 std::vector<uint32_t> counterValues = std::vector<uint32_t>(ETHOSU_PMU_EVENT_MAX, 0);
419
420 eioctl(fd, ETHOSU_IOCTL_INFERENCE_STATUS, static_cast<void *>(&uapi));
421
422 for (int i = 0; i < ETHOSU_PMU_EVENT_MAX; i++) {
423 if (uapi.pmu_config.events[i]) {
424 counterValues.at(i) = uapi.pmu_count.events[i];
425 }
426 }
427
428 return counterValues;
429}
430
431uint64_t Inference::getCycleCounter() {
432 ethosu_uapi_result_status uapi;
433
434 eioctl(fd, ETHOSU_IOCTL_INFERENCE_STATUS, static_cast<void *>(&uapi));
435
436 return uapi.pmu_count.cycle_count;
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200437}
438
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200439int Inference::getFd() {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200440 return fd;
441}
442
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200443shared_ptr<Network> Inference::getNetwork() {
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200444 return network;
445}
446
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200447vector<shared_ptr<Buffer>> &Inference::getIfmBuffers() {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200448 return ifmBuffers;
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200449}
450
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200451vector<shared_ptr<Buffer>> &Inference::getOfmBuffers() {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200452 return ofmBuffers;
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200453}
454
Kristofer Jonsson79689c52020-10-16 14:42:19 +0200455} // namespace EthosU