Skip to content

Commit b002e57

Browse files
authored
Ownership & move-only Graph (#235)
#225
1 parent e03c095 commit b002e57

13 files changed

Lines changed: 979 additions & 51829 deletions

File tree

app/Accuracy/accuracy_check.cpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ int main() {
3434
}
3535
Shape sh({static_cast<size_t>(count_pic), 227, 227, 3});
3636
Tensor t = make_tensor<float>(res, sh);
37-
Graph graph(6);
37+
Graph graph;
3838
Shape sh1({1, 5, 5, 3});
3939
std::vector<float> vec;
4040
vec.reserve(75);
@@ -43,23 +43,29 @@ int main() {
4343
}
4444
Tensor input = t;
4545
Tensor output = make_tensor(vec, sh1);
46-
auto a1 = std::make_shared<InputLayer>(kNchw, kNchw, 1, 2);
46+
auto a1 = std::make_unique<InputLayer>(kNchw, kNchw, 1, 2);
47+
Layer* a1_ptr = a1.get();
4748
std::vector<float> kernelvec = {1, 1, 1, 1, 1, 1, 1, 1, 1};
4849
Shape sh2({3, 3});
4950
Tensor kernel = make_tensor(kernelvec, sh2);
50-
auto a2 = std::make_shared<ConvolutionalLayer>(1, 0, 0, kernel);
51+
auto a2 = std::make_unique<ConvolutionalLayer>(1, 0, 0, kernel);
52+
Layer* a2_ptr = a2.get();
5153
Shape poolshape = {2, 2};
52-
auto a3 = std::make_shared<EWLayer>("linear", 2.0F, 3.0F);
53-
auto a4 = std::make_shared<PoolingLayer>(poolshape, "average");
54-
auto a5 = std::make_shared<OutputLayer>();
55-
auto a6 = std::make_shared<FCLayer>();
56-
graph.setInput(a1, input);
57-
graph.makeConnection(a1, a2);
58-
graph.makeConnection(a2, a3);
59-
graph.makeConnection(a3, a4);
60-
graph.makeConnection(a4, a5);
61-
graph.makeConnection(a5, a6);
62-
graph.setOutput(a5, output);
54+
auto a3 = std::make_unique<EWLayer>("linear", 2.0F, 3.0F);
55+
Layer* a3_ptr = a3.get();
56+
auto a4 = std::make_unique<PoolingLayer>(poolshape, "average");
57+
Layer* a4_ptr = a4.get();
58+
auto a5 = std::make_unique<OutputLayer>();
59+
Layer* a5_ptr = a5.get();
60+
auto a6 = std::make_unique<FCLayer>();
61+
Layer* a6_ptr = a6.get();
62+
graph.setInput(a1_ptr, input);
63+
graph.makeConnection(a1_ptr, a2_ptr);
64+
graph.makeConnection(a2_ptr, a3_ptr);
65+
graph.makeConnection(a3_ptr, a4_ptr);
66+
graph.makeConnection(a4_ptr, a5_ptr);
67+
graph.makeConnection(a5_ptr, a6_ptr);
68+
graph.setOutput(a5_ptr, output);
6369
graph.inference();
6470
std::vector<float> tmp = *output.as<float>();
6571
std::vector<float> tmp_output = softmax<float>(*output.as<float>());

app/AccuracyImgNet/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)