17 #include <../api/CPP/cldnn_defs.h> 18 #include <../api/CPP/engine.hpp> 19 #include <../api/CPP/input_layout.hpp> 20 #include <../api/CPP/memory.hpp> 21 #include <../api/CPP/data.hpp> 22 #include <../api/CPP/topology.hpp> 23 #include <../api/CPP/network.hpp> 24 #include <../api/CPP/activation.hpp> 25 #include <../api/CPP/crop.hpp> 26 #include <../api/CPP/upsampling.hpp> 30 #include "helper_functions.h" 51 using namespace cldnn;
54 void print_info(std::map<primitive_id, primitive_id>& all_primitives, std::map<primitive_id, event>& executed_primitives)
56 std::cout << std::endl <<
"Org_primitive_id, Primitive_id_after_optimization" << std::endl;
57 for (
auto& p : all_primitives)
59 std::cout << p.first <<
", " << p.second << std::endl;
63 std::vector<cldnn::instrumentation::profiling_info> profiling_table;
64 for (
auto& p : executed_primitives)
66 profiling_table.push_back({ p.first, p.second.get_profiling_info() });
70 for (
auto& p : profiling_table)
72 std::cout << p.name <<
":" << std::endl;
73 for (
auto& q : p.intervals)
75 std::cout <<
"\t" << q.name <<
": " << std::chrono::duration_cast<std::chrono::duration<double, std::chrono::milliseconds::period>>(q.value->value()).count()
76 <<
" milliseconds" << std::endl;
83 std::cout << std::endl <<
"-- Chapter 8 --" << std::endl;
96 set_values(input_prim, get_simple_data<float>(input_prim));
112 network_1.set_input_data(
"input", input_prim);
114 auto outputs_1 = network_1.execute();
119 auto executed_primitives_1 = network_1.get_executed_primitives();
124 auto all_primitives_1 = network_1.get_all_primitives();
127 std::cout << std::endl <<
"Primitives list and profiling info for network without optimize data build option." << std::endl;
128 print_info(all_primitives_1, executed_primitives_1);
134 network_2.set_input_data(
"input", input_prim);
135 auto outputs = network_2.execute();
140 auto executed_primitives_2 = network_2.get_executed_primitives();
148 auto all_primitives_2 = network_2.get_all_primitives();
162 std::cout << std::endl <<
"Primitives list and profiling info for network with optimize data build option." << std::endl;
163 print_info(all_primitives_2, executed_primitives_2);
Represents program build options list.
Activation using rectified linear unit or parameterized rectified linear unit.
N-dimensional vector. Mostly used to represent memory size.
void set_option(std::shared_ptr< const build_option > opt)
Adds or replace option to the options list.
Performs crop operation on input.
upsampling nearest neighbor.
User selected list of program outputs.
Network topology to be defined by user.
void add(PType const &desc)
Adds a primitive to topology.
static memory allocate(const engine &engine, const layout &layout)
Allocate memory on engine using specified layout.
Performs nearest neighbor/bilinear upsampling Also supports built-in Relu activation available by set...
Executable network allocated from program.
const layout & get_layout() const
Associated layout.
Represents clDNN engine object.
Represents buffer with particular layout.
static std::shared_ptr< const build_option > optimize_data(bool enable=false)
Enable implicit reordering for user inputs (default: false).