@@ -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;
37+ Graph graph ( 6 ) ;
3838 Shape sh1 ({1 , 5 , 5 , 3 });
3939 std::vector<float > vec;
4040 vec.reserve (75 );
@@ -43,29 +43,23 @@ int main() {
4343 }
4444 Tensor input = t;
4545 Tensor output = make_tensor (vec, sh1);
46- auto a1 = std::make_unique<InputLayer>(kNchw , kNchw , 1 , 2 );
47- Layer* a1_ptr = a1.get ();
46+ auto a1 = std::make_shared<InputLayer>(kNchw , kNchw , 1 , 2 );
4847 std::vector<float > kernelvec = {1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 };
4948 Shape sh2 ({3 , 3 });
5049 Tensor kernel = make_tensor (kernelvec, sh2);
51- auto a2 = std::make_unique<ConvolutionalLayer>(1 , 0 , 0 , kernel);
52- Layer* a2_ptr = a2.get ();
50+ auto a2 = std::make_shared<ConvolutionalLayer>(1 , 0 , 0 , kernel);
5351 Shape poolshape = {2 , 2 };
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);
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);
6963 graph.inference ();
7064 std::vector<float > tmp = *output.as <float >();
7165 std::vector<float > tmp_output = softmax<float >(*output.as <float >());
0 commit comments