aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristofer Jonsson <kristofer.jonsson@arm.com>2020-10-16 14:42:19 +0200
committerKristofer Jonsson <kristofer.jonsson@arm.com>2020-10-16 14:42:19 +0200
commit79689c5fefc8c37cc35e43f6e2bcc8402eb56707 (patch)
tree1f64fb48ba4b2734572f50784bb9e0f063e1244f
parentd748336bf17ad9f4f52315294b9eb4ea5132095a (diff)
downloadethos-u-linux-driver-stack-79689c5fefc8c37cc35e43f6e2bcc8402eb56707.tar.gz
Clang format
Change-Id: I2ebac7df9c4716be7fee10ce4cba350e40860ca2
-rw-r--r--.clang-format61
-rw-r--r--driver_library/include/ethosu.hpp30
-rw-r--r--driver_library/src/autogen/.clang-format23
-rw-r--r--driver_library/src/ethosu.cpp176
-rw-r--r--kernel/.clang-format23
-rw-r--r--mailbox/.clang-format23
-rw-r--r--utils/inference_runner/inference_runner.cpp123
7 files changed, 245 insertions, 214 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..6052b78
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,61 @@
+#
+# Copyright (c) 2020 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the License); you may
+# not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an AS IS BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+---
+Language: Cpp
+BasedOnStyle: LLVM
+IndentWidth: 4
+ColumnLimit: 120
+AccessModifierOffset: -4
+PointerAlignment: Right
+
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: true
+AlignConsecutiveMacros: true
+AlignEscapedNewlines: Left
+AlignTrailingComments: true
+
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortFunctionsOnASingleLine: Empty
+AllowShortBlocksOnASingleLine: true
+AlwaysBreakTemplateDeclarations: true
+
+BinPackArguments: false
+BinPackParameters: false
+
+BreakInheritanceList: AfterColon
+BreakConstructorInitializers: AfterColon
+BreakBeforeBraces: Custom
+
+BraceWrapping:
+ AfterClass: false
+ AfterControlStatement: false
+ AfterEnum: false
+ AfterFunction: false
+ AfterNamespace: false
+ AfterObjCDeclaration: true
+ AfterStruct: false
+ AfterUnion: false
+ AfterExternBlock: false
+ BeforeCatch: false
+ BeforeElse: false
+ IndentBraces: false
+ SplitEmptyFunction: false
+ SplitEmptyRecord: false
+ SplitEmptyNamespace: true
+---
diff --git a/driver_library/include/ethosu.hpp b/driver_library/include/ethosu.hpp
index c3a310c..4e45485 100644
--- a/driver_library/include/ethosu.hpp
+++ b/driver_library/include/ethosu.hpp
@@ -25,12 +25,9 @@
#include <string>
#include <vector>
-namespace EthosU
-{
+namespace EthosU {
-class Exception :
- public std::exception
-{
+class Exception : public std::exception {
public:
Exception(const char *msg);
virtual ~Exception() throw();
@@ -40,8 +37,7 @@ private:
std::string msg;
};
-class Device
-{
+class Device {
public:
Device(const char *device = "/dev/ethosu0");
virtual ~Device();
@@ -52,8 +48,7 @@ private:
int fd;
};
-class Buffer
-{
+class Buffer {
public:
Buffer(Device &device, const size_t capacity);
virtual ~Buffer();
@@ -73,8 +68,7 @@ private:
const size_t dataCapacity;
};
-class Network
-{
+class Network {
public:
Network(Device &device, std::shared_ptr<Buffer> &buffer);
virtual ~Network();
@@ -93,13 +87,15 @@ private:
std::vector<size_t> ofmDims;
};
-class Inference
-{
+class Inference {
public:
template <typename T>
- Inference(std::shared_ptr<Network> &network, const T &ifmBegin, const T &ifmEnd, const T &ofmBegin, const T &ofmEnd) :
- network(network)
- {
+ Inference(std::shared_ptr<Network> &network,
+ const T &ifmBegin,
+ const T &ifmEnd,
+ const T &ofmBegin,
+ const T &ofmEnd) :
+ network(network) {
std::copy(ifmBegin, ifmEnd, std::back_inserter(ifmBuffers));
std::copy(ofmBegin, ofmEnd, std::back_inserter(ofmBuffers));
create();
@@ -122,4 +118,4 @@ private:
std::vector<std::shared_ptr<Buffer>> ofmBuffers;
};
-}
+} // namespace EthosU
diff --git a/driver_library/src/autogen/.clang-format b/driver_library/src/autogen/.clang-format
new file mode 100644
index 0000000..e45a760
--- /dev/null
+++ b/driver_library/src/autogen/.clang-format
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2019-2020 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the License); you may
+# not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an AS IS BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+---
+Language: Cpp
+SortIncludes: false
+DisableFormat: true
+---
diff --git a/driver_library/src/ethosu.cpp b/driver_library/src/ethosu.cpp
index 39e39f0..9de26af 100644
--- a/driver_library/src/ethosu.cpp
+++ b/driver_library/src/ethosu.cpp
@@ -25,21 +25,18 @@
#include <exception>
#include <iostream>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
#include <fcntl.h>
#include <poll.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
#include <unistd.h>
using namespace std;
-namespace
-{
-int eioctl(int fd, unsigned long cmd, void *data = nullptr)
-{
+namespace {
+int eioctl(int fd, unsigned long cmd, void *data = nullptr) {
int ret = ::ioctl(fd, cmd, data);
- if (ret < 0)
- {
+ if (ret < 0) {
throw EthosU::Exception("IOCTL failed");
}
@@ -50,29 +47,24 @@ int eioctl(int fd, unsigned long cmd, void *data = nullptr)
* TFL micro helpers
****************************************************************************/
-size_t getShapeSize(const flatbuffers::Vector<int32_t> *shape)
-{
+size_t getShapeSize(const flatbuffers::Vector<int32_t> *shape) {
size_t size = 1;
-
- for (auto it = shape->begin(); it != shape->end(); ++it)
- {
+
+ for (auto it = shape->begin(); it != shape->end(); ++it) {
size *= *it;
}
return size;
}
-vector<size_t> getSubGraphDims(const tflite::SubGraph *subgraph, const flatbuffers::Vector<int32_t> *tensorMap)
-{
+vector<size_t> getSubGraphDims(const tflite::SubGraph *subgraph, const flatbuffers::Vector<int32_t> *tensorMap) {
vector<size_t> dims;
- for (auto index = tensorMap->begin(); index != tensorMap->end(); ++index)
- {
+ for (auto index = tensorMap->begin(); index != tensorMap->end(); ++index) {
auto tensor = subgraph->tensors()->Get(*index);
size_t size = getShapeSize(tensor->shape());
- if (size > 0)
- {
+ if (size > 0) {
dims.push_back(size);
}
}
@@ -80,24 +72,19 @@ vector<size_t> getSubGraphDims(const tflite::SubGraph *subgraph, const flatbuffe
return dims;
}
-}
+} // namespace
-namespace EthosU
-{
+namespace EthosU {
/****************************************************************************
* Exception
****************************************************************************/
-Exception::Exception(const char *msg) :
- msg(msg)
-{}
+Exception::Exception(const char *msg) : msg(msg) {}
-Exception::~Exception() throw()
-{}
+Exception::~Exception() throw() {}
-const char *Exception::what() const throw()
-{
+const char *Exception::what() const throw() {
return msg.c_str();
}
@@ -105,22 +92,18 @@ const char *Exception::what() const throw()
* Device
****************************************************************************/
-Device::Device(const char *device)
-{
+Device::Device(const char *device) {
fd = open(device, O_RDWR | O_NONBLOCK);
- if (fd < 0)
- {
+ if (fd < 0) {
throw Exception("Failed to open device");
}
}
-Device::~Device()
-{
+Device::~Device() {
close(fd);
}
-int Device::ioctl(unsigned long cmd, void *data)
-{
+int Device::ioctl(unsigned long cmd, void *data) {
return eioctl(fd, cmd, data);
}
@@ -128,67 +111,54 @@ int Device::ioctl(unsigned long cmd, void *data)
* Buffer
****************************************************************************/
-Buffer::Buffer(Device &device, const size_t capacity) :
- fd(-1),
- dataPtr(nullptr),
- dataCapacity(capacity)
-{
- ethosu_uapi_buffer_create uapi = { static_cast<uint32_t>(dataCapacity) };
- fd = device.ioctl(ETHOSU_IOCTL_BUFFER_CREATE, static_cast<void *>(&uapi));
+Buffer::Buffer(Device &device, const size_t capacity) : fd(-1), dataPtr(nullptr), dataCapacity(capacity) {
+ ethosu_uapi_buffer_create uapi = {static_cast<uint32_t>(dataCapacity)};
+ fd = device.ioctl(ETHOSU_IOCTL_BUFFER_CREATE, static_cast<void *>(&uapi));
void *d = ::mmap(nullptr, dataCapacity, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if (d == MAP_FAILED)
- {
+ if (d == MAP_FAILED) {
throw Exception("MMap failed");
}
dataPtr = reinterpret_cast<char *>(d);
}
-Buffer::~Buffer()
-{
+Buffer::~Buffer() {
close(fd);
}
-size_t Buffer::capacity() const
-{
+size_t Buffer::capacity() const {
return dataCapacity;
}
-void Buffer::clear()
-{
+void Buffer::clear() {
resize(0, 0);
}
-char *Buffer::data()
-{
+char *Buffer::data() {
return dataPtr + offset();
}
-void Buffer::resize(size_t size, size_t offset)
-{
+void Buffer::resize(size_t size, size_t offset) {
ethosu_uapi_buffer uapi;
uapi.offset = offset;
- uapi.size = size;
+ uapi.size = size;
eioctl(fd, ETHOSU_IOCTL_BUFFER_SET, static_cast<void *>(&uapi));
}
-size_t Buffer::offset() const
-{
+size_t Buffer::offset() const {
ethosu_uapi_buffer uapi;
eioctl(fd, ETHOSU_IOCTL_BUFFER_GET, static_cast<void *>(&uapi));
return uapi.offset;
}
-size_t Buffer::size() const
-{
+size_t Buffer::size() const {
ethosu_uapi_buffer uapi;
eioctl(fd, ETHOSU_IOCTL_BUFFER_GET, static_cast<void *>(&uapi));
return uapi.size;
}
-int Buffer::getFd() const
-{
+int Buffer::getFd() const {
return fd;
}
@@ -196,70 +166,58 @@ int Buffer::getFd() const
* Network
****************************************************************************/
-Network::Network(Device &device, shared_ptr<Buffer> &buffer) :
- fd(-1),
- buffer(buffer)
-{
+Network::Network(Device &device, shared_ptr<Buffer> &buffer) : fd(-1), buffer(buffer) {
// Create buffer handle
ethosu_uapi_network_create uapi;
uapi.fd = buffer->getFd();
- fd = device.ioctl(ETHOSU_IOCTL_NETWORK_CREATE, static_cast<void *>(&uapi));
+ fd = device.ioctl(ETHOSU_IOCTL_NETWORK_CREATE, static_cast<void *>(&uapi));
// Create model handle
const tflite::Model *model = tflite::GetModel(reinterpret_cast<void *>(buffer->data()));
// Get input dimensions for first subgraph
auto *subgraph = *model->subgraphs()->begin();
- ifmDims = getSubGraphDims(subgraph, subgraph->inputs());
+ ifmDims = getSubGraphDims(subgraph, subgraph->inputs());
// Get output dimensions for last subgraph
subgraph = *model->subgraphs()->rbegin();
- ofmDims = getSubGraphDims(subgraph, subgraph->outputs());
+ ofmDims = getSubGraphDims(subgraph, subgraph->outputs());
}
-Network::~Network()
-{
+Network::~Network() {
close(fd);
}
-int Network::ioctl(unsigned long cmd, void *data)
-{
+int Network::ioctl(unsigned long cmd, void *data) {
return eioctl(fd, cmd, data);
}
-shared_ptr<Buffer> Network::getBuffer()
-{
+shared_ptr<Buffer> Network::getBuffer() {
return buffer;
}
-const std::vector<size_t> &Network::getIfmDims() const
-{
+const std::vector<size_t> &Network::getIfmDims() const {
return ifmDims;
}
-size_t Network::getIfmSize() const
-{
+size_t Network::getIfmSize() const {
size_t size = 0;
- for (auto s: ifmDims)
- {
+ for (auto s : ifmDims) {
size += s;
}
return size;
}
-const std::vector<size_t> &Network::getOfmDims() const
-{
+const std::vector<size_t> &Network::getOfmDims() const {
return ofmDims;
}
-size_t Network::getOfmSize() const
-{
+size_t Network::getOfmSize() const {
size_t size = 0;
- for (auto s: ofmDims)
- {
+ for (auto s : ofmDims) {
size += s;
}
@@ -270,46 +228,39 @@ size_t Network::getOfmSize() const
* Inference
****************************************************************************/
-Inference::~Inference()
-{
+Inference::~Inference() {
close(fd);
}
-void Inference::create()
-{
+void Inference::create() {
ethosu_uapi_inference_create uapi;
- if (ifmBuffers.size() > ETHOSU_FD_MAX)
- {
+ if (ifmBuffers.size() > ETHOSU_FD_MAX) {
throw Exception("IFM buffer overflow");
}
- if (ofmBuffers.size() > ETHOSU_FD_MAX)
- {
+ if (ofmBuffers.size() > ETHOSU_FD_MAX) {
throw Exception("OFM buffer overflow");
}
uapi.ifm_count = 0;
- for (auto it: ifmBuffers)
- {
+ for (auto it : ifmBuffers) {
uapi.ifm_fd[uapi.ifm_count++] = it->getFd();
}
uapi.ofm_count = 0;
- for (auto it: ofmBuffers)
- {
+ for (auto it : ofmBuffers) {
uapi.ofm_fd[uapi.ofm_count++] = it->getFd();
}
fd = network->ioctl(ETHOSU_IOCTL_INFERENCE_CREATE, static_cast<void *>(&uapi));
}
-void Inference::wait(int timeoutSec)
-{
+void Inference::wait(int timeoutSec) {
pollfd pfd;
- pfd.fd = fd;
- pfd.events = POLLIN | POLLERR;
+ pfd.fd = fd;
+ pfd.events = POLLIN | POLLERR;
pfd.revents = 0;
int ret = ::poll(&pfd, 1, timeoutSec * 1000);
@@ -317,31 +268,26 @@ void Inference::wait(int timeoutSec)
cout << "Poll. ret=" << ret << ", revents=" << pfd.revents << endl;
}
-bool Inference::failed()
-{
+bool Inference::failed() {
ethosu_uapi_status status = static_cast<ethosu_uapi_status>(eioctl(fd, ETHOSU_IOCTL_INFERENCE_STATUS));
return status != ETHOSU_UAPI_STATUS_OK;
}
-int Inference::getFd()
-{
+int Inference::getFd() {
return fd;
}
-shared_ptr<Network> Inference::getNetwork()
-{
+shared_ptr<Network> Inference::getNetwork() {
return network;
}
-vector<shared_ptr<Buffer>> &Inference::getIfmBuffers()
-{
+vector<shared_ptr<Buffer>> &Inference::getIfmBuffers() {
return ifmBuffers;
}
-vector<shared_ptr<Buffer>> &Inference::getOfmBuffers()
-{
+vector<shared_ptr<Buffer>> &Inference::getOfmBuffers() {
return ofmBuffers;
}
-}
+} // namespace EthosU
diff --git a/kernel/.clang-format b/kernel/.clang-format
new file mode 100644
index 0000000..e45a760
--- /dev/null
+++ b/kernel/.clang-format
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2019-2020 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the License); you may
+# not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an AS IS BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+---
+Language: Cpp
+SortIncludes: false
+DisableFormat: true
+---
diff --git a/mailbox/.clang-format b/mailbox/.clang-format
new file mode 100644
index 0000000..e45a760
--- /dev/null
+++ b/mailbox/.clang-format
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2019-2020 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the License); you may
+# not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an AS IS BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+---
+Language: Cpp
+SortIncludes: false
+DisableFormat: true
+---
diff --git a/utils/inference_runner/inference_runner.cpp b/utils/inference_runner/inference_runner.cpp
index ae8d2a7..c5a62f6 100644
--- a/utils/inference_runner/inference_runner.cpp
+++ b/utils/inference_runner/inference_runner.cpp
@@ -16,26 +16,23 @@
* limitations under the License.
*/
-
#include <ethosu.hpp>
#include <uapi/ethosu.h>
-#include <unistd.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <string>
+#include <unistd.h>
using namespace std;
using namespace EthosU;
-namespace
-{
+namespace {
int defaultTimeout = 60;
-void help(const string exe)
-{
+void help(const string exe) {
cerr << "Usage: " << exe << " [ARGS]\n";
cerr << "\n";
cerr << "Arguments:\n";
@@ -48,20 +45,16 @@ void help(const string exe)
cerr << endl;
}
-void rangeCheck(const int i, const int argc, const string arg)
-{
- if (i >= argc)
- {
+void rangeCheck(const int i, const int argc, const string arg) {
+ if (i >= argc) {
cerr << "Error: Missing argument to '" << arg << "'" << endl;
exit(1);
}
}
-shared_ptr<Buffer> allocAndFill(Device &device, const string filename)
-{
+shared_ptr<Buffer> allocAndFill(Device &device, const string filename) {
ifstream stream(filename, ios::binary);
- if (!stream.is_open())
- {
+ if (!stream.is_open()) {
cerr << "Error: Failed to open '" << filename << "'" << endl;
exit(1);
}
@@ -77,12 +70,10 @@ shared_ptr<Buffer> allocAndFill(Device &device, const string filename)
return buffer;
}
-shared_ptr<Inference> createInference(Device &device, shared_ptr<Network> &network, const string &filename)
-{
+shared_ptr<Inference> createInference(Device &device, shared_ptr<Network> &network, const string &filename) {
// Open IFM file
ifstream stream(filename, ios::binary);
- if (!stream.is_open())
- {
+ if (!stream.is_open()) {
cerr << "Error: Failed to open '" << filename << "'" << endl;
exit(1);
}
@@ -92,22 +83,20 @@ shared_ptr<Inference> createInference(Device &device, shared_ptr<Network> &netwo
size_t size = stream.tellg();
stream.seekg(0, ios_base::beg);
- if (size != network->getIfmSize())
- {
- cerr << "Error: IFM size does not match network size. filename=" << filename << ", size=" << size << ", network=" << network->getIfmSize() << endl;
+ if (size != network->getIfmSize()) {
+ cerr << "Error: IFM size does not match network size. filename=" << filename << ", size=" << size
+ << ", network=" << network->getIfmSize() << endl;
exit(1);
}
// Create IFM buffers
vector<shared_ptr<Buffer>> ifm;
- for (auto size: network->getIfmDims())
- {
+ for (auto size : network->getIfmDims()) {
shared_ptr<Buffer> buffer = make_shared<Buffer>(device, size);
buffer->resize(size);
stream.read(buffer->data(), size);
- if (!stream)
- {
+ if (!stream) {
cerr << "Error: Failed to read IFM" << endl;
exit(1);
}
@@ -117,99 +106,77 @@ shared_ptr<Inference> createInference(Device &device, shared_ptr<Network> &netwo
// Create OFM buffers
vector<shared_ptr<Buffer>> ofm;
- for (auto size: network->getOfmDims())
- {
+ for (auto size : network->getOfmDims()) {
ofm.push_back(make_shared<Buffer>(device, size));
}
return make_shared<Inference>(network, ifm.begin(), ifm.end(), ofm.begin(), ofm.end());
}
-ostream &operator<<(ostream &os, Buffer &buf)
-{
- char *c = buf.data();
+ostream &operator<<(ostream &os, Buffer &buf) {
+ char *c = buf.data();
const char *end = c + buf.size();
- while (c < end)
- {
+ while (c < end) {
os << hex << setw(2) << static_cast<int>(*c++) << " " << dec;
}
return os;
}
-}
+} // namespace
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[]) {
const string exe = argv[0];
string networkArg;
list<string> ifmArg;
string ofmArg;
int timeout = defaultTimeout;
- bool print = false;
+ bool print = false;
- for (int i = 1; i < argc; ++i)
- {
+ for (int i = 1; i < argc; ++i) {
const string arg(argv[i]);
- if (arg == "-h" || arg == "--help")
- {
+ if (arg == "-h" || arg == "--help") {
help(exe);
exit(1);
- }
- else if (arg == "--network" || arg == "-n")
- {
+ } else if (arg == "--network" || arg == "-n") {
rangeCheck(++i, argc, arg);
networkArg = argv[i];
- }
- else if (arg == "--ifm" || arg == "-i")
- {
+ } else if (arg == "--ifm" || arg == "-i") {
rangeCheck(++i, argc, arg);
ifmArg.push_back(argv[i]);
- }
- else if (arg == "--ofm" || arg == "-o")
- {
+ } else if (arg == "--ofm" || arg == "-o") {
rangeCheck(++i, argc, arg);
ofmArg = argv[i];
- }
- else if (arg == "--timeout" || arg == "-t")
- {
+ } else if (arg == "--timeout" || arg == "-t") {
rangeCheck(++i, argc, arg);
timeout = stoi(argv[i]);
- }
- else if (arg == "-p")
- {
+ } else if (arg == "-p") {
print = true;
- }
- else
- {
+ } else {
cerr << "Error: Invalid argument '" << arg << "'" << endl;
help(exe);
exit(1);
}
}
- if (networkArg.empty())
- {
+ if (networkArg.empty()) {
cerr << "Error: Missing 'network' argument" << endl;
exit(1);
}
- if (ifmArg.empty())
- {
+ if (ifmArg.empty()) {
cerr << "Error: Missing 'ifm' argument" << endl;
exit(1);
}
- if (ofmArg.empty())
- {
+ if (ofmArg.empty()) {
cerr << "Error: Missing 'ofm' argument" << endl;
exit(1);
}
- try
- {
+ try {
Device device;
cout << "Send ping" << endl;
@@ -218,12 +185,11 @@ int main(int argc, char *argv[])
/* Create network */
cout << "Create network" << endl;
shared_ptr<Buffer> networkBuffer = allocAndFill(device, networkArg);
- shared_ptr<Network> network = make_shared<Network>(device, networkBuffer);
+ shared_ptr<Network> network = make_shared<Network>(device, networkBuffer);
/* Create one inference per IFM */
list<shared_ptr<Inference>> inferences;
- for (auto &filename: ifmArg)
- {
+ for (auto &filename : ifmArg) {
cout << "Create inference" << endl;
inferences.push_back(createInference(device, network, filename));
}
@@ -231,8 +197,7 @@ int main(int argc, char *argv[])
cout << "Wait for inferences" << endl;
int ofmIndex = 0;
- for (auto &inference: inferences)
- {
+ for (auto &inference : inferences) {
inference->wait(timeout);
string status = inference->failed() ? "failed" : "success";
@@ -240,20 +205,16 @@ int main(int argc, char *argv[])
string ofmFilename = ofmArg + "." + to_string(ofmIndex);
ofstream ofmStream(ofmFilename, ios::binary);
- if (!ofmStream.is_open())
- {
+ if (!ofmStream.is_open()) {
cerr << "Error: Failed to open '" << ofmFilename << "'" << endl;
exit(1);
}
- if (!inference->failed())
- {
- for (auto &ofmBuffer: inference->getOfmBuffers())
- {
+ if (!inference->failed()) {
+ for (auto &ofmBuffer : inference->getOfmBuffers()) {
cout << "OFM size: " << ofmBuffer->size() << endl;
- if (print)
- {
+ if (print) {
cout << "OFM data: " << *ofmBuffer << endl;
}
@@ -263,9 +224,7 @@ int main(int argc, char *argv[])
ofmIndex++;
}
- }
- catch (Exception &e)
- {
+ } catch (Exception &e) {
cerr << "Error: " << e.what() << endl;
return 1;
}