Skip to content

Commit eae6181

Browse files
committed
Address compilation errors
1 parent 766a606 commit eae6181

5 files changed

Lines changed: 34 additions & 9 deletions

File tree

include/layers/ConcatLayer.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ class ConcatLayer : public Layer {
1818

1919
static std::string get_name() { return "ConcatLayer"; }
2020

21+
#ifdef ENABLE_STATISTIC_WEIGHTS
22+
Tensor get_weights() override { return Tensor(); }
23+
#endif
24+
2125
private:
2226
int64_t axis_;
2327

include/layers/DropOutLayer.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class DropOutLayer : public Layer {
1414
DropOutLayer(double drop_rate) { drop_rate_ = drop_rate; }
1515
static std::string get_name() { return "DropOut layer"; }
1616
void run(const Tensor& input, Tensor& output) override;
17+
#ifdef ENABLE_STATISTIC_WEIGHTS
18+
Tensor get_weights() override { return Tensor(); }
19+
#endif
1720
};
1821

1922
} // namespace it_lab_ai

include/layers/FlattenLayer.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class FlattenLayer : public Layer {
1717
FlattenLayer(const std::vector<size_t>& order) : order_(order) {}
1818
static std::string get_name() { return "Flatten layer"; }
1919
void run(const Tensor& input, Tensor& output) override;
20+
#ifdef ENABLE_STATISTIC_WEIGHTS
21+
Tensor get_weights() override { return Tensor(); }
22+
#endif
2023
};
2124

2225
template <typename ValueType>

include/layers/ReduceLayer.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ class ReduceLayer : public Layer {
1919

2020
static std::string get_name() { return "ReduceLayer"; }
2121

22+
#ifdef ENABLE_STATISTIC_WEIGHTS
23+
Tensor get_weights() override { return Tensor(); }
24+
#endif
25+
2226
private:
2327
Operation op_;
2428
int64_t keepdims_;

test/inference/test_inference.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <stdexcept>
12
#include <vector>
23

34
#include "graph/graph.hpp"
@@ -42,41 +43,46 @@ TEST(bfs, check_result_vec) {
4243
std::vector<int> res = {81, 81, 81};
4344
#ifdef ENABLE_STATISTIC_TENSORS
4445
std::vector<Tensor> tensors = graph.getTensors();
45-
for (int i = 0; i < tensors.size(); i++) {
46+
for (size_t i = 0; i < tensors.size(); i++) {
4647
std::vector<int> ten = *tensors[i].as<int>();
47-
for (int j = 0; j < ten.size(); j++) {
48+
for (size_t j = 0; j < ten.size(); j++) {
4849
std::cout << ten[j] << ' ';
4950
}
5051
std::cout << '\n';
5152
}
5253
#endif
5354
#ifdef ENABLE_STATISTIC_TIME
5455
std::vector<std::string> times = graph.getTimeInfo();
55-
for (int j = 0; j < times.size(); j++) {
56+
for (size_t j = 0; j < times.size(); j++) {
5657
std::cout << times[j] << ' ';
5758
}
5859
std::cout << '\n';
5960
#endif
6061
#ifdef ENABLE_STATISTIC_WEIGHTS
6162
std::vector<Tensor> weights = graph.getWEIGHTS();
62-
for (int i = 0; i < weights.size(); i++) {
63+
for (size_t i = 0; i < weights.size(); i++) {
6364
switch (weights[i].get_type()) {
6465
case Type::kInt: {
6566
std::vector<int> ten = *weights[i].as<int>();
66-
for (int j = 0; j < ten.size(); j++) {
67+
for (size_t j = 0; j < ten.size(); j++) {
6768
std::cout << ten[j] << ' ';
6869
}
6970
std::cout << '\n';
7071
break;
7172
}
7273
case Type::kFloat: {
7374
std::vector<float> ten = *weights[i].as<float>();
74-
for (int j = 0; j < ten.size(); j++) {
75+
for (size_t j = 0; j < ten.size(); j++) {
7576
std::cout << ten[j] << ' ';
7677
}
7778
std::cout << '\n';
7879
break;
7980
}
81+
case Type::kUnknown:
82+
default: {
83+
throw std::runtime_error("Unknown tensor type encountered");
84+
break;
85+
}
8086
}
8187
}
8288
#endif
@@ -112,24 +118,29 @@ TEST(bfs, check_end_to_end) {
112118
graph.inference();
113119
#ifdef ENABLE_STATISTIC_WEIGHTS
114120
std::vector<Tensor> weights = graph.getWEIGHTS();
115-
for (int i = 0; i < weights.size(); i++) {
121+
for (size_t i = 0; i < weights.size(); i++) {
116122
switch (weights[i].get_type()) {
117123
case Type::kInt: {
118124
std::vector<int> ten = *weights[i].as<int>();
119-
for (int j = 0; j < ten.size(); j++) {
125+
for (size_t j = 0; j < ten.size(); j++) {
120126
std::cout << ten[j] << ' ';
121127
}
122128
std::cout << '\n';
123129
break;
124130
}
125131
case Type::kFloat: {
126132
std::vector<float> ten = *weights[i].as<float>();
127-
for (int j = 0; j < ten.size(); j++) {
133+
for (size_t j = 0; j < ten.size(); j++) {
128134
std::cout << ten[j] << ' ';
129135
}
130136
std::cout << '\n';
131137
break;
132138
}
139+
case Type::kUnknown:
140+
default: {
141+
throw std::runtime_error("Unknown tensor type encountered");
142+
break;
143+
}
133144
}
134145
}
135146
#endif

0 commit comments

Comments
 (0)