From 22e1a30294f1afb5c74bf00a88e247af62e236b8 Mon Sep 17 00:00:00 2001 From: kobeyu <46064838+kobeyu@users.noreply.github.com> Date: Fri, 30 Oct 2020 15:07:17 +0800 Subject: [PATCH] [IE CLDNN] Fixed compilation error for tutorial samples (#430) Co-authored-by: Kobe Yu Co-authored-by: Alexander Zhogov --- .../thirdparty/clDNN/tutorial/chapter_1.cpp | 13 +++--- .../thirdparty/clDNN/tutorial/chapter_2.cpp | 23 +++++------ .../thirdparty/clDNN/tutorial/chapter_3.cpp | 15 ++++--- .../thirdparty/clDNN/tutorial/chapter_4.cpp | 13 +++--- .../thirdparty/clDNN/tutorial/chapter_5.cpp | 13 +++--- .../thirdparty/clDNN/tutorial/chapter_6.cpp | 15 ++++--- .../thirdparty/clDNN/tutorial/chapter_7.cpp | 17 ++++---- .../thirdparty/clDNN/tutorial/chapter_8.cpp | 27 ++++++------ .../clDNN/tutorial/example_cldnn.cpp | 41 ++++++++++--------- .../clDNN/tutorial/helper_functions.h | 3 +- .../thirdparty/clDNN/tutorial/main.cpp | 4 +- 11 files changed, 88 insertions(+), 96 deletions(-) diff --git a/inference-engine/thirdparty/clDNN/tutorial/chapter_1.cpp b/inference-engine/thirdparty/clDNN/tutorial/chapter_1.cpp index 511961a8acb..4a47f33a6e8 100644 --- a/inference-engine/thirdparty/clDNN/tutorial/chapter_1.cpp +++ b/inference-engine/thirdparty/clDNN/tutorial/chapter_1.cpp @@ -13,12 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. */ -#include <../api/CPP/cldnn_defs.h> -#include <../api/CPP/engine.hpp> -#include <../api/CPP/memory.hpp> -#include <../api/CPP/tensor.hpp> -#include <../api/CPP/input_layout.hpp> -#include <../api/CPP/data.hpp> +#include <../api/engine.hpp> +#include <../api/memory.hpp> +#include <../api/tensor.hpp> +#include <../api/input_layout.hpp> +#include <../api/data.hpp> #include /*! @page c1 Engine, layout, tensor, memory, data and input * @section intro Introduction @@ -74,4 +73,4 @@ engine chapter_1() data data("named_memory", memory1); return engine; -} \ No newline at end of file +} diff --git a/inference-engine/thirdparty/clDNN/tutorial/chapter_2.cpp b/inference-engine/thirdparty/clDNN/tutorial/chapter_2.cpp index baed733357a..3b729d0f08c 100644 --- a/inference-engine/thirdparty/clDNN/tutorial/chapter_2.cpp +++ b/inference-engine/thirdparty/clDNN/tutorial/chapter_2.cpp @@ -14,15 +14,14 @@ // limitations under the License. */ -#include <../api/CPP/cldnn_defs.h> -#include <../api/CPP/engine.hpp> -#include <../api/CPP/input_layout.hpp> -#include <../api/CPP/activation.hpp> -#include <../api/CPP/softmax.hpp> -#include <../api/CPP/memory.hpp> -#include <../api/CPP/fully_connected.hpp> -#include <../api/CPP/data.hpp> -#include <../api/CPP/topology.hpp> +#include <../api/engine.hpp> +#include <../api/input_layout.hpp> +#include <../api/activation.hpp> +#include <../api/softmax.hpp> +#include <../api/memory.hpp> +#include <../api/fully_connected.hpp> +#include <../api/data.hpp> +#include <../api/topology.hpp> #include #include "helper_functions.h" @@ -45,7 +44,7 @@ topology chapter_2(engine& engine) activation relu( "relu", // primitive identifier "input", // identifier of input ( output of primitive with provided name is input to current ) - activation_relu); + activation_func::relu); // Softmax is also very easy to create: softmax softmax( @@ -66,7 +65,7 @@ topology chapter_2(engine& engine) data fc_weights("fc_weights", weights_mem); // Biases are optional but we can use those in this example. Create 'data' in the same way: - auto bias_mem = memory::allocate(engine, { data_types::f32,format::bfyx,{ spatial(3) } }); // y, b and f will be set to ones by default + auto bias_mem = memory::allocate(engine, { data_types::f32,format::bfyx, tensor(spatial(3)) }); // y, b and f will be set to ones by default // Use function to fill data: set_values(bias_mem, { 0.0f, 1.0f, 0.5f }); // Create data primitive. @@ -101,4 +100,4 @@ topology chapter_2(engine& engine) std::cout << it << std::endl; } return topology; -} \ No newline at end of file +} diff --git a/inference-engine/thirdparty/clDNN/tutorial/chapter_3.cpp b/inference-engine/thirdparty/clDNN/tutorial/chapter_3.cpp index bfd6caf2191..b2228f24444 100644 --- a/inference-engine/thirdparty/clDNN/tutorial/chapter_3.cpp +++ b/inference-engine/thirdparty/clDNN/tutorial/chapter_3.cpp @@ -14,13 +14,12 @@ // limitations under the License. */ -#include <../api/CPP/cldnn_defs.h> -#include <../api/CPP/engine.hpp> -#include <../api/CPP/input_layout.hpp> -#include <../api/CPP/memory.hpp> -#include <../api/CPP/data.hpp> -#include <../api/CPP/topology.hpp> -#include <../api/CPP/network.hpp> +#include <../api/engine.hpp> +#include <../api/input_layout.hpp> +#include <../api/memory.hpp> +#include <../api/data.hpp> +#include <../api/topology.hpp> +#include <../api/network.hpp> #include #include "helper_functions.h" @@ -76,4 +75,4 @@ void chapter_3(engine& engine, topology& topology) } // What if someone may want to look into intermediate results (hidden layers). This will be described in next chapter (4). -} \ No newline at end of file +} diff --git a/inference-engine/thirdparty/clDNN/tutorial/chapter_4.cpp b/inference-engine/thirdparty/clDNN/tutorial/chapter_4.cpp index 1fe069b9822..accea67b5cc 100644 --- a/inference-engine/thirdparty/clDNN/tutorial/chapter_4.cpp +++ b/inference-engine/thirdparty/clDNN/tutorial/chapter_4.cpp @@ -14,13 +14,12 @@ // limitations under the License. */ -#include <../api/CPP/cldnn_defs.h> -#include <../api/CPP/engine.hpp> -#include <../api/CPP/input_layout.hpp> -#include <../api/CPP/memory.hpp> -#include <../api/CPP/data.hpp> -#include <../api/CPP/topology.hpp> -#include <../api/CPP/network.hpp> +#include <../api/engine.hpp> +#include <../api/input_layout.hpp> +#include <../api/memory.hpp> +#include <../api/data.hpp> +#include <../api/topology.hpp> +#include <../api/network.hpp> #include #include "helper_functions.h" diff --git a/inference-engine/thirdparty/clDNN/tutorial/chapter_5.cpp b/inference-engine/thirdparty/clDNN/tutorial/chapter_5.cpp index f6ccee97dfb..655c17c0278 100644 --- a/inference-engine/thirdparty/clDNN/tutorial/chapter_5.cpp +++ b/inference-engine/thirdparty/clDNN/tutorial/chapter_5.cpp @@ -14,13 +14,12 @@ // limitations under the License. */ -#include <../api/CPP/cldnn_defs.h> -#include <../api/CPP/engine.hpp> -#include <../api/CPP/input_layout.hpp> -#include <../api/CPP/memory.hpp> -#include <../api/CPP/data.hpp> -#include <../api/CPP/topology.hpp> -#include <../api/CPP/network.hpp> +#include <../api/engine.hpp> +#include <../api/input_layout.hpp> +#include <../api/memory.hpp> +#include <../api/data.hpp> +#include <../api/topology.hpp> +#include <../api/network.hpp> #include #include diff --git a/inference-engine/thirdparty/clDNN/tutorial/chapter_6.cpp b/inference-engine/thirdparty/clDNN/tutorial/chapter_6.cpp index 58da3ebdd48..fb972d88baf 100644 --- a/inference-engine/thirdparty/clDNN/tutorial/chapter_6.cpp +++ b/inference-engine/thirdparty/clDNN/tutorial/chapter_6.cpp @@ -14,14 +14,13 @@ // limitations under the License. */ -#include <../api/CPP/cldnn_defs.h> -#include <../api/CPP/engine.hpp> -#include <../api/CPP/input_layout.hpp> -#include <../api/CPP/memory.hpp> -#include <../api/CPP/data.hpp> -#include <../api/CPP/topology.hpp> -#include <../api/CPP/network.hpp> -#include <../api/CPP/convolution.hpp> +#include <../api/engine.hpp> +#include <../api/input_layout.hpp> +#include <../api/memory.hpp> +#include <../api/data.hpp> +#include <../api/topology.hpp> +#include <../api/network.hpp> +#include <../api/convolution.hpp> #include #include diff --git a/inference-engine/thirdparty/clDNN/tutorial/chapter_7.cpp b/inference-engine/thirdparty/clDNN/tutorial/chapter_7.cpp index c4d5e4f14fc..c2f683464e4 100644 --- a/inference-engine/thirdparty/clDNN/tutorial/chapter_7.cpp +++ b/inference-engine/thirdparty/clDNN/tutorial/chapter_7.cpp @@ -14,14 +14,13 @@ // limitations under the License. */ -#include <../api/CPP/cldnn_defs.h> -#include <../api/CPP/engine.hpp> -#include <../api/CPP/input_layout.hpp> -#include <../api/CPP/memory.hpp> -#include <../api/CPP/data.hpp> -#include <../api/CPP/topology.hpp> -#include <../api/CPP/network.hpp> -#include <../api/CPP/custom_gpu_primitive.hpp> +#include <../api/engine.hpp> +#include <../api/input_layout.hpp> +#include <../api/memory.hpp> +#include <../api/data.hpp> +#include <../api/topology.hpp> +#include <../api/network.hpp> +#include <../api/custom_gpu_primitive.hpp> #include #include #include @@ -72,7 +71,7 @@ void chapter_7(engine& my_engine) std::string entry_point = "add_kernel"; // Parameter binding for the custom primitive - std::vector parameters = { { arg_input, 0 }, { arg_input, 1 }, { arg_output, 0 } }; + std::vector parameters = { { custom_gpu_primitive::arg_input, 0 }, { custom_gpu_primitive::arg_input, 1 }, { custom_gpu_primitive::arg_output, 0 } }; // Output layout for the custom primitive layout output_layout = my_layout; diff --git a/inference-engine/thirdparty/clDNN/tutorial/chapter_8.cpp b/inference-engine/thirdparty/clDNN/tutorial/chapter_8.cpp index a555ad7ef43..a5e782e2bb2 100644 --- a/inference-engine/thirdparty/clDNN/tutorial/chapter_8.cpp +++ b/inference-engine/thirdparty/clDNN/tutorial/chapter_8.cpp @@ -14,16 +14,15 @@ // limitations under the License. */ -#include <../api/CPP/cldnn_defs.h> -#include <../api/CPP/engine.hpp> -#include <../api/CPP/input_layout.hpp> -#include <../api/CPP/memory.hpp> -#include <../api/CPP/data.hpp> -#include <../api/CPP/topology.hpp> -#include <../api/CPP/network.hpp> -#include <../api/CPP/activation.hpp> -#include <../api/CPP/crop.hpp> -#include <../api/CPP/resample.hpp> +#include <../api/engine.hpp> +#include <../api/input_layout.hpp> +#include <../api/memory.hpp> +#include <../api/data.hpp> +#include <../api/topology.hpp> +#include <../api/network.hpp> +#include <../api/activation.hpp> +#include <../api/crop.hpp> +#include <../api/resample.hpp> #include #include @@ -98,12 +97,12 @@ void chapter_8(engine& engine) // Create a topology and add primitives topology topology; topology.add(input_layout("input", input_prim.get_layout())); - topology.add(resample("resample", "input", 2, 4, resample_type::nearest)); - topology.add(activation("relu", "resample", activation_relu)); + topology.add(resample("resample", "input", tensor(spatial(2)), 4, resample_type::nearest)); + topology.add(activation("relu", "resample", activation_func::relu)); topology.add(crop("crop1", "relu", tensor(batch(1), spatial(2, 2), feature(3)), { tensor(feature(0), spatial(0,0),batch(0)) })); topology.add(crop("crop2", "relu", tensor(batch(1), spatial(2, 2), feature(1)), { tensor(feature(3), spatial(0,0),batch(0)) })); - topology.add(activation("relu1", "crop1", activation_relu)); - topology.add(activation("relu2", "crop2", activation_relu)); + topology.add(activation("relu1", "crop1", activation_func::relu)); + topology.add(activation("relu2", "crop2", activation_func::relu)); // Build network without optimize data build option network network_1(engine, topology); diff --git a/inference-engine/thirdparty/clDNN/tutorial/example_cldnn.cpp b/inference-engine/thirdparty/clDNN/tutorial/example_cldnn.cpp index 50021f9747d..4ed03b4191d 100644 --- a/inference-engine/thirdparty/clDNN/tutorial/example_cldnn.cpp +++ b/inference-engine/thirdparty/clDNN/tutorial/example_cldnn.cpp @@ -1,14 +1,14 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -72,8 +72,8 @@ topology create_topology(const layout& in_layout, const memory& conv1_weights_me pooling("pool1", "conv1", // Input: "conv1" pooling_mode::max, // Pooling mode: MAX - spatial(2,2), // stride: 2 - spatial(2,2) // kernel_size: 2 + tensor(spatial(2,2)), // stride: 2 + tensor(spatial(2,2)) // kernel_size: 2 ) ); @@ -85,7 +85,7 @@ topology create_topology(const layout& in_layout, const memory& conv1_weights_me // Input layout for conv2 weights. Data will passed by network::set_input_data() input_layout("conv2_weights", conv2_weights_layout), // Input layout for conv2 bias. - input_layout("conv2_bias", { data_type, format::bfyx, spatial(conv2_out_channels) }), + input_layout("conv2_bias", { data_type, format::bfyx, tensor(spatial(conv2_out_channels)) }), // Second convolution id: "conv2" convolution("conv2", "pool1", // Input: "pool1" @@ -96,15 +96,14 @@ topology create_topology(const layout& in_layout, const memory& conv1_weights_me pooling("pool2", "conv2", // Input: "conv2" pooling_mode::max, // Pooling mode: MAX - spatial(2, 2), // stride: 2 - spatial(2, 2) // kernel_size: 2 + tensor(spatial(2, 2)), // stride: 2 + tensor(spatial(2, 2)) // kernel_size: 2 ), // Fully connected (inner product) primitive id "fc1" fully_connected("fc1", "pool2", // Input: "pool2" "fc1_weights", // "fc1_weights" will be added to the topology later - "fc1_bias", // will be defined later - true // Use built-in Relu. Slope is set to 0 by default. + "fc1_bias" // will be defined later ), // Second FC/IP primitive id: "fc2", input: "fc1". // Weights ("fc2_weights") and biases ("fc2_bias") will be defined later. @@ -183,7 +182,7 @@ int main_func() cldnn::engine engine; // Create memory for conv1 bias - layout conv1_bias_layout(data_type, format::bfyx, spatial(20)); + layout conv1_bias_layout(data_type, format::bfyx, tensor(spatial(20))); // Memory allocation requires engine auto conv1_bias_mem = memory::allocate(engine, conv1_bias_layout); // The memory is allocated by library, so we do not need to care about buffer lifetime. @@ -203,7 +202,9 @@ int main_func() // Build the network. Allow implicit data optimizations. // The "softmax" primitive is not used as an input for other primitives, // so we do not need to explicitly select it in build_options::outputs() - cldnn::network network(engine, topology, { build_option::optimize_data(true) }); + cldnn::build_options options; + options.set_option(cldnn::build_option::optimize_data(true)); + cldnn::network network(engine, topology, options); // Set network data which was not known at topology creation. network.set_input_data("conv2_weights", load_mem(engine, "conv2_weights.data")); diff --git a/inference-engine/thirdparty/clDNN/tutorial/helper_functions.h b/inference-engine/thirdparty/clDNN/tutorial/helper_functions.h index 5ec6b1959ef..2244b92da37 100644 --- a/inference-engine/thirdparty/clDNN/tutorial/helper_functions.h +++ b/inference-engine/thirdparty/clDNN/tutorial/helper_functions.h @@ -15,8 +15,7 @@ */ #include -#include <../api/CPP/cldnn_defs.h> -#include <../api/CPP/memory.hpp> +#include <../api/memory.hpp> diff --git a/inference-engine/thirdparty/clDNN/tutorial/main.cpp b/inference-engine/thirdparty/clDNN/tutorial/main.cpp index f02bbbd3366..10b5b7f8e86 100644 --- a/inference-engine/thirdparty/clDNN/tutorial/main.cpp +++ b/inference-engine/thirdparty/clDNN/tutorial/main.cpp @@ -29,8 +29,8 @@ * @subpage c8
* */ -#include <../api/CPP/engine.hpp> -#include <../api/CPP/topology.hpp> +#include <../api/engine.hpp> +#include <../api/topology.hpp> cldnn::engine chapter_1(); // Engine, layout, tensor, memory, data and input