Skip to content

Commit ccdd0fb

Browse files
update to master
1 parent 4e14b98 commit ccdd0fb

File tree

2 files changed

+64
-63
lines changed

2 files changed

+64
-63
lines changed

demos/common/cpp/utils/include/utils/common.hpp

Lines changed: 64 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,30 @@
99

1010
#pragma once
1111

12-
#include <algorithm>
13-
#include <fstream>
14-
#include <functional>
15-
#include <iomanip>
16-
#include <iostream>
17-
#include <list>
18-
#include <limits>
19-
#include <map>
2012
#include <string>
21-
#include <random>
13+
#include <map>
2214
#include <vector>
15+
#include <list>
16+
#include <limits>
17+
#include <functional>
18+
#include <fstream>
19+
#include <iomanip>
2320
#include <utility>
21+
#include <algorithm>
22+
#include <random>
23+
#include <iostream>
2424

2525
#include <inference_engine.hpp>
2626
#include "openvino/openvino.hpp"
2727
#include "utils/slog.hpp"
2828
#include "utils/args_helper.hpp"
2929

3030
#ifndef UNUSED
31-
#ifdef _WIN32
32-
#define UNUSED
33-
#else
34-
#define UNUSED __attribute__((unused))
35-
#endif
31+
#ifdef _WIN32
32+
#define UNUSED
33+
#else
34+
#define UNUSED __attribute__((unused))
35+
#endif
3636
#endif
3737

3838
template <typename T, std::size_t N>
@@ -86,8 +86,8 @@ class Color {
8686
* @param b - value for blue channel
8787
*/
8888
Color(unsigned char r,
89-
unsigned char g,
90-
unsigned char b) : _r(r), _g(g), _b(b) {}
89+
unsigned char g,
90+
unsigned char b) : _r(r), _g(g), _b(b) {}
9191

9292
inline unsigned char red() const {
9393
return _r;
@@ -132,16 +132,17 @@ inline std::size_t getTensorWidth(const InferenceEngine::TensorDesc& desc) {
132132
const auto& dims = desc.getDims();
133133
const auto& size = dims.size();
134134
if ((size >= 2) &&
135-
(layout == InferenceEngine::Layout::NCHW ||
136-
layout == InferenceEngine::Layout::NHWC ||
137-
layout == InferenceEngine::Layout::NCDHW ||
138-
layout == InferenceEngine::Layout::NDHWC ||
139-
layout == InferenceEngine::Layout::OIHW ||
140-
layout == InferenceEngine::Layout::CHW ||
141-
layout == InferenceEngine::Layout::HW)) {
135+
(layout == InferenceEngine::Layout::NCHW ||
136+
layout == InferenceEngine::Layout::NHWC ||
137+
layout == InferenceEngine::Layout::NCDHW ||
138+
layout == InferenceEngine::Layout::NDHWC ||
139+
layout == InferenceEngine::Layout::OIHW ||
140+
layout == InferenceEngine::Layout::CHW ||
141+
layout == InferenceEngine::Layout::HW)) {
142142
// Regardless of layout, dimensions are stored in fixed order
143143
return dims.back();
144-
} else {
144+
}
145+
else {
145146
throw std::runtime_error("Tensor does not have width dimension");
146147
}
147148
return 0;
@@ -152,72 +153,75 @@ inline std::size_t getTensorHeight(const InferenceEngine::TensorDesc& desc) {
152153
const auto& dims = desc.getDims();
153154
const auto& size = dims.size();
154155
if ((size >= 2) &&
155-
(layout == InferenceEngine::Layout::NCHW ||
156-
layout == InferenceEngine::Layout::NHWC ||
157-
layout == InferenceEngine::Layout::NCDHW ||
158-
layout == InferenceEngine::Layout::NDHWC ||
159-
layout == InferenceEngine::Layout::OIHW ||
160-
layout == InferenceEngine::Layout::CHW ||
161-
layout == InferenceEngine::Layout::HW)) {
156+
(layout == InferenceEngine::Layout::NCHW ||
157+
layout == InferenceEngine::Layout::NHWC ||
158+
layout == InferenceEngine::Layout::NCDHW ||
159+
layout == InferenceEngine::Layout::NDHWC ||
160+
layout == InferenceEngine::Layout::OIHW ||
161+
layout == InferenceEngine::Layout::CHW ||
162+
layout == InferenceEngine::Layout::HW)) {
162163
// Regardless of layout, dimensions are stored in fixed order
163164
return dims.at(size - 2);
164-
} else {
165+
}
166+
else {
165167
throw std::runtime_error("Tensor does not have height dimension");
166168
}
167169
return 0;
168170
}
169171

170172
inline std::size_t getTensorChannels(const InferenceEngine::TensorDesc& desc) {
171173
const auto& layout = desc.getLayout();
172-
if (layout == InferenceEngine::Layout::NCHW ||
173-
layout == InferenceEngine::Layout::NHWC ||
174+
if (layout == InferenceEngine::Layout::NCHW ||
175+
layout == InferenceEngine::Layout::NHWC ||
174176
layout == InferenceEngine::Layout::NCDHW ||
175177
layout == InferenceEngine::Layout::NDHWC ||
176-
layout == InferenceEngine::Layout::C ||
177-
layout == InferenceEngine::Layout::CHW ||
178-
layout == InferenceEngine::Layout::NC ||
178+
layout == InferenceEngine::Layout::C ||
179+
layout == InferenceEngine::Layout::CHW ||
180+
layout == InferenceEngine::Layout::NC ||
179181
layout == InferenceEngine::Layout::CN) {
180182
// Regardless of layout, dimensions are stored in fixed order
181183
const auto& dims = desc.getDims();
182184
switch (desc.getLayoutByDims(dims)) {
183-
case InferenceEngine::Layout::C: return dims.at(0);
184-
case InferenceEngine::Layout::NC: return dims.at(1);
185-
case InferenceEngine::Layout::CHW: return dims.at(0);
186-
case InferenceEngine::Layout::NCHW: return dims.at(1);
187-
case InferenceEngine::Layout::NCDHW: return dims.at(1);
188-
case InferenceEngine::Layout::SCALAR: // [[fallthrough]]
189-
case InferenceEngine::Layout::BLOCKED: // [[fallthrough]]
190-
default:
191-
throw std::runtime_error("Tensor does not have channels dimension");
185+
case InferenceEngine::Layout::C: return dims.at(0);
186+
case InferenceEngine::Layout::NC: return dims.at(1);
187+
case InferenceEngine::Layout::CHW: return dims.at(0);
188+
case InferenceEngine::Layout::NCHW: return dims.at(1);
189+
case InferenceEngine::Layout::NCDHW: return dims.at(1);
190+
case InferenceEngine::Layout::SCALAR: // [[fallthrough]]
191+
case InferenceEngine::Layout::BLOCKED: // [[fallthrough]]
192+
default:
193+
throw std::runtime_error("Tensor does not have channels dimension");
192194
}
193-
} else {
195+
}
196+
else {
194197
throw std::runtime_error("Tensor does not have channels dimension");
195198
}
196199
return 0;
197200
}
198201

199202
inline std::size_t getTensorBatch(const InferenceEngine::TensorDesc& desc) {
200203
const auto& layout = desc.getLayout();
201-
if (layout == InferenceEngine::Layout::NCHW ||
202-
layout == InferenceEngine::Layout::NHWC ||
204+
if (layout == InferenceEngine::Layout::NCHW ||
205+
layout == InferenceEngine::Layout::NHWC ||
203206
layout == InferenceEngine::Layout::NCDHW ||
204207
layout == InferenceEngine::Layout::NDHWC ||
205-
layout == InferenceEngine::Layout::NC ||
208+
layout == InferenceEngine::Layout::NC ||
206209
layout == InferenceEngine::Layout::CN) {
207210
// Regardless of layout, dimensions are stored in fixed order
208211
const auto& dims = desc.getDims();
209212
switch (desc.getLayoutByDims(dims)) {
210-
case InferenceEngine::Layout::NC: return dims.at(0);
211-
case InferenceEngine::Layout::NCHW: return dims.at(0);
212-
case InferenceEngine::Layout::NCDHW: return dims.at(0);
213-
case InferenceEngine::Layout::CHW: // [[fallthrough]]
214-
case InferenceEngine::Layout::C: // [[fallthrough]]
215-
case InferenceEngine::Layout::SCALAR: // [[fallthrough]]
216-
case InferenceEngine::Layout::BLOCKED: // [[fallthrough]]
217-
default:
218-
throw std::runtime_error("Tensor does not have channels dimension");
213+
case InferenceEngine::Layout::NC: return dims.at(0);
214+
case InferenceEngine::Layout::NCHW: return dims.at(0);
215+
case InferenceEngine::Layout::NCDHW: return dims.at(0);
216+
case InferenceEngine::Layout::CHW: // [[fallthrough]]
217+
case InferenceEngine::Layout::C: // [[fallthrough]]
218+
case InferenceEngine::Layout::SCALAR: // [[fallthrough]]
219+
case InferenceEngine::Layout::BLOCKED: // [[fallthrough]]
220+
default:
221+
throw std::runtime_error("Tensor does not have channels dimension");
219222
}
220-
} else {
223+
}
224+
else {
221225
throw std::runtime_error("Tensor does not have channels dimension");
222226
}
223227
return 0;

demos/crossroad_camera_demo/cpp/crossroad_camera_demo.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
///////////////////////////////////////////////////////////////////////////////////////////////////
66
#pragma once
77

8-
#include <string>
9-
#include <vector>
10-
118
#include "gflags/gflags.h"
129
#include "utils/default_flags.hpp"
1310

0 commit comments

Comments
 (0)