@@ -19,8 +19,11 @@ void alexnet_inf_careless(Graph& graph, const RuntimeOptions& options,
1919 auto * o = new Tensor (output);
2020 auto * i = new Tensor (input);
2121 graph.inference (options);
22- graph.setOutput (*o);
23- graph.setInput (*i);
22+ if (graph.getLayersCount () == 0 ) {
23+ throw std::runtime_error (" No layers" );
24+ }
25+ graph.setOutput (graph.getLayerFromID (graph.getLayersCount () - 1 ), *o);
26+ graph.setInput (graph.getLayerFromID (0 ), *i);
2427}
2528
2629void alexnet_comparison () {
@@ -45,7 +48,7 @@ void alexnet_comparison() {
4548 RuntimeOptions options;
4649 Graph graph;
4750 Graph graph2;
48- build_graph_linear (graph, input, output, options, true );
51+ build_graph_linear (graph, input, output, options, true , false );
4952 Graph subgraph;
5053 std::shared_ptr<Layer> layer_0 = std::make_shared<ConvolutionalLayer>();
5154 std::shared_ptr<Layer> layer_1 = std::make_shared<EWLayer>(" relu" );
@@ -57,9 +60,11 @@ void alexnet_comparison() {
5760 Tensor input_c = input;
5861 Tensor output_c = output;
5962 auto time1 = elapsed_time_avg<double , std::milli>(
60- 2 , alexnet_inf_careless, graph, options, input_c, output_c);
63+ 4 , alexnet_inf_careless, graph, options, input_c, output_c);
64+ print_time_stats (graph);
6165 auto time2 = elapsed_time_avg<double , std::milli>(
62- 2 , alexnet_inf_careless, graph2, options, input_c, output_c);
66+ 4 , alexnet_inf_careless, graph2, options, input_c, output_c);
67+ print_time_stats (graph2);
6368 std::cout << time1 << " for unchanged graph\n " ;
6469 std::cout << time2 << " for convrelu graph\n " ;
6570}
0 commit comments