[IE CLDNN] Fixed compilation error for tutorial samples (#430)

Co-authored-by: Kobe Yu <kobe.yu@kneron.us>
Co-authored-by: Alexander Zhogov <alexander.zhogov@intel.com>
This commit is contained in:
kobeyu 2020-10-30 15:07:17 +08:00 committed by GitHub
parent 8ee263e7fb
commit 22e1a30294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 88 additions and 96 deletions

View File

@ -13,12 +13,11 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
*/ */
#include <../api/CPP/cldnn_defs.h> #include <../api/engine.hpp>
#include <../api/CPP/engine.hpp> #include <../api/memory.hpp>
#include <../api/CPP/memory.hpp> #include <../api/tensor.hpp>
#include <../api/CPP/tensor.hpp> #include <../api/input_layout.hpp>
#include <../api/CPP/input_layout.hpp> #include <../api/data.hpp>
#include <../api/CPP/data.hpp>
#include <iostream> #include <iostream>
/*! @page c1 Engine, layout, tensor, memory, data and input /*! @page c1 Engine, layout, tensor, memory, data and input
* @section intro Introduction * @section intro Introduction

View File

@ -14,15 +14,14 @@
// limitations under the License. // limitations under the License.
*/ */
#include <../api/CPP/cldnn_defs.h> #include <../api/engine.hpp>
#include <../api/CPP/engine.hpp> #include <../api/input_layout.hpp>
#include <../api/CPP/input_layout.hpp> #include <../api/activation.hpp>
#include <../api/CPP/activation.hpp> #include <../api/softmax.hpp>
#include <../api/CPP/softmax.hpp> #include <../api/memory.hpp>
#include <../api/CPP/memory.hpp> #include <../api/fully_connected.hpp>
#include <../api/CPP/fully_connected.hpp> #include <../api/data.hpp>
#include <../api/CPP/data.hpp> #include <../api/topology.hpp>
#include <../api/CPP/topology.hpp>
#include <iostream> #include <iostream>
#include "helper_functions.h" #include "helper_functions.h"
@ -45,7 +44,7 @@ topology chapter_2(engine& engine)
activation relu( activation relu(
"relu", // primitive identifier "relu", // primitive identifier
"input", // identifier of input ( output of primitive with provided name is input to current ) "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 is also very easy to create:
softmax softmax( softmax softmax(
@ -66,7 +65,7 @@ topology chapter_2(engine& engine)
data fc_weights("fc_weights", weights_mem); data fc_weights("fc_weights", weights_mem);
// Biases are optional but we can use those in this example. Create 'data' in the same way: // 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: // Use function to fill data:
set_values(bias_mem, { 0.0f, 1.0f, 0.5f }); set_values(bias_mem, { 0.0f, 1.0f, 0.5f });
// Create data primitive. // Create data primitive.

View File

@ -14,13 +14,12 @@
// limitations under the License. // limitations under the License.
*/ */
#include <../api/CPP/cldnn_defs.h> #include <../api/engine.hpp>
#include <../api/CPP/engine.hpp> #include <../api/input_layout.hpp>
#include <../api/CPP/input_layout.hpp> #include <../api/memory.hpp>
#include <../api/CPP/memory.hpp> #include <../api/data.hpp>
#include <../api/CPP/data.hpp> #include <../api/topology.hpp>
#include <../api/CPP/topology.hpp> #include <../api/network.hpp>
#include <../api/CPP/network.hpp>
#include <iostream> #include <iostream>
#include "helper_functions.h" #include "helper_functions.h"

View File

@ -14,13 +14,12 @@
// limitations under the License. // limitations under the License.
*/ */
#include <../api/CPP/cldnn_defs.h> #include <../api/engine.hpp>
#include <../api/CPP/engine.hpp> #include <../api/input_layout.hpp>
#include <../api/CPP/input_layout.hpp> #include <../api/memory.hpp>
#include <../api/CPP/memory.hpp> #include <../api/data.hpp>
#include <../api/CPP/data.hpp> #include <../api/topology.hpp>
#include <../api/CPP/topology.hpp> #include <../api/network.hpp>
#include <../api/CPP/network.hpp>
#include <iostream> #include <iostream>
#include "helper_functions.h" #include "helper_functions.h"

View File

@ -14,13 +14,12 @@
// limitations under the License. // limitations under the License.
*/ */
#include <../api/CPP/cldnn_defs.h> #include <../api/engine.hpp>
#include <../api/CPP/engine.hpp> #include <../api/input_layout.hpp>
#include <../api/CPP/input_layout.hpp> #include <../api/memory.hpp>
#include <../api/CPP/memory.hpp> #include <../api/data.hpp>
#include <../api/CPP/data.hpp> #include <../api/topology.hpp>
#include <../api/CPP/topology.hpp> #include <../api/network.hpp>
#include <../api/CPP/network.hpp>
#include <iostream> #include <iostream>
#include <chrono> #include <chrono>

View File

@ -14,14 +14,13 @@
// limitations under the License. // limitations under the License.
*/ */
#include <../api/CPP/cldnn_defs.h> #include <../api/engine.hpp>
#include <../api/CPP/engine.hpp> #include <../api/input_layout.hpp>
#include <../api/CPP/input_layout.hpp> #include <../api/memory.hpp>
#include <../api/CPP/memory.hpp> #include <../api/data.hpp>
#include <../api/CPP/data.hpp> #include <../api/topology.hpp>
#include <../api/CPP/topology.hpp> #include <../api/network.hpp>
#include <../api/CPP/network.hpp> #include <../api/convolution.hpp>
#include <../api/CPP/convolution.hpp>
#include <iostream> #include <iostream>
#include <chrono> #include <chrono>

View File

@ -14,14 +14,13 @@
// limitations under the License. // limitations under the License.
*/ */
#include <../api/CPP/cldnn_defs.h> #include <../api/engine.hpp>
#include <../api/CPP/engine.hpp> #include <../api/input_layout.hpp>
#include <../api/CPP/input_layout.hpp> #include <../api/memory.hpp>
#include <../api/CPP/memory.hpp> #include <../api/data.hpp>
#include <../api/CPP/data.hpp> #include <../api/topology.hpp>
#include <../api/CPP/topology.hpp> #include <../api/network.hpp>
#include <../api/CPP/network.hpp> #include <../api/custom_gpu_primitive.hpp>
#include <../api/CPP/custom_gpu_primitive.hpp>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <chrono> #include <chrono>
@ -72,7 +71,7 @@ void chapter_7(engine& my_engine)
std::string entry_point = "add_kernel"; std::string entry_point = "add_kernel";
// Parameter binding for the custom primitive // Parameter binding for the custom primitive
std::vector<cldnn_arg> parameters = { { arg_input, 0 }, { arg_input, 1 }, { arg_output, 0 } }; std::vector<custom_gpu_primitive::arg_desc> 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 // Output layout for the custom primitive
layout output_layout = my_layout; layout output_layout = my_layout;

View File

@ -14,16 +14,15 @@
// limitations under the License. // limitations under the License.
*/ */
#include <../api/CPP/cldnn_defs.h> #include <../api/engine.hpp>
#include <../api/CPP/engine.hpp> #include <../api/input_layout.hpp>
#include <../api/CPP/input_layout.hpp> #include <../api/memory.hpp>
#include <../api/CPP/memory.hpp> #include <../api/data.hpp>
#include <../api/CPP/data.hpp> #include <../api/topology.hpp>
#include <../api/CPP/topology.hpp> #include <../api/network.hpp>
#include <../api/CPP/network.hpp> #include <../api/activation.hpp>
#include <../api/CPP/activation.hpp> #include <../api/crop.hpp>
#include <../api/CPP/crop.hpp> #include <../api/resample.hpp>
#include <../api/CPP/resample.hpp>
#include <iostream> #include <iostream>
#include <chrono> #include <chrono>
@ -98,12 +97,12 @@ void chapter_8(engine& engine)
// Create a topology and add primitives // Create a topology and add primitives
topology topology; topology topology;
topology.add(input_layout("input", input_prim.get_layout())); topology.add(input_layout("input", input_prim.get_layout()));
topology.add(resample("resample", "input", 2, 4, resample_type::nearest)); topology.add(resample("resample", "input", tensor(spatial(2)), 4, resample_type::nearest));
topology.add(activation("relu", "resample", activation_relu)); 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("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(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("relu1", "crop1", activation_func::relu));
topology.add(activation("relu2", "crop2", activation_relu)); topology.add(activation("relu2", "crop2", activation_func::relu));
// Build network without optimize data build option // Build network without optimize data build option
network network_1(engine, topology); network network_1(engine, topology);

View File

@ -1,14 +1,14 @@
#include <api/CPP/memory.hpp> #include <api/memory.hpp>
#include <api/CPP/topology.hpp> #include <api/topology.hpp>
#include <api/CPP/reorder.hpp> #include <api/reorder.hpp>
#include <api/CPP/input_layout.hpp> #include <api/input_layout.hpp>
#include <api/CPP/convolution.hpp> #include <api/convolution.hpp>
#include <api/CPP/data.hpp> #include <api/data.hpp>
#include <api/CPP/pooling.hpp> #include <api/pooling.hpp>
#include <api/CPP/fully_connected.hpp> #include <api/fully_connected.hpp>
#include <api/CPP/softmax.hpp> #include <api/softmax.hpp>
#include <api/CPP/engine.hpp> #include <api/engine.hpp>
#include <api/CPP/network.hpp> #include <api/network.hpp>
#include <iostream> #include <iostream>
@ -72,8 +72,8 @@ topology create_topology(const layout& in_layout, const memory& conv1_weights_me
pooling("pool1", pooling("pool1",
"conv1", // Input: "conv1" "conv1", // Input: "conv1"
pooling_mode::max, // Pooling mode: MAX pooling_mode::max, // Pooling mode: MAX
spatial(2,2), // stride: 2 tensor(spatial(2,2)), // stride: 2
spatial(2,2) // kernel_size: 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 for conv2 weights. Data will passed by network::set_input_data()
input_layout("conv2_weights", conv2_weights_layout), input_layout("conv2_weights", conv2_weights_layout),
// Input layout for conv2 bias. // 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" // Second convolution id: "conv2"
convolution("conv2", convolution("conv2",
"pool1", // Input: "pool1" "pool1", // Input: "pool1"
@ -96,15 +96,14 @@ topology create_topology(const layout& in_layout, const memory& conv1_weights_me
pooling("pool2", pooling("pool2",
"conv2", // Input: "conv2" "conv2", // Input: "conv2"
pooling_mode::max, // Pooling mode: MAX pooling_mode::max, // Pooling mode: MAX
spatial(2, 2), // stride: 2 tensor(spatial(2, 2)), // stride: 2
spatial(2, 2) // kernel_size: 2 tensor(spatial(2, 2)) // kernel_size: 2
), ),
// Fully connected (inner product) primitive id "fc1" // Fully connected (inner product) primitive id "fc1"
fully_connected("fc1", fully_connected("fc1",
"pool2", // Input: "pool2" "pool2", // Input: "pool2"
"fc1_weights", // "fc1_weights" will be added to the topology later "fc1_weights", // "fc1_weights" will be added to the topology later
"fc1_bias", // will be defined later "fc1_bias" // will be defined later
true // Use built-in Relu. Slope is set to 0 by default.
), ),
// Second FC/IP primitive id: "fc2", input: "fc1". // Second FC/IP primitive id: "fc2", input: "fc1".
// Weights ("fc2_weights") and biases ("fc2_bias") will be defined later. // Weights ("fc2_weights") and biases ("fc2_bias") will be defined later.
@ -183,7 +182,7 @@ int main_func()
cldnn::engine engine; cldnn::engine engine;
// Create memory for conv1 bias // 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 // Memory allocation requires engine
auto conv1_bias_mem = memory::allocate(engine, conv1_bias_layout); 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. // 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. // Build the network. Allow implicit data optimizations.
// The "softmax" primitive is not used as an input for other primitives, // 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() // 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. // Set network data which was not known at topology creation.
network.set_input_data("conv2_weights", load_mem(engine, "conv2_weights.data")); network.set_input_data("conv2_weights", load_mem(engine, "conv2_weights.data"));

View File

@ -15,8 +15,7 @@
*/ */
#include <initializer_list> #include <initializer_list>
#include <../api/CPP/cldnn_defs.h> #include <../api/memory.hpp>
#include <../api/CPP/memory.hpp>

View File

@ -29,8 +29,8 @@
* @subpage c8 <br> * @subpage c8 <br>
* *
*/ */
#include <../api/CPP/engine.hpp> #include <../api/engine.hpp>
#include <../api/CPP/topology.hpp> #include <../api/topology.hpp>
cldnn::engine chapter_1(); // Engine, layout, tensor, memory, data and input cldnn::engine chapter_1(); // Engine, layout, tensor, memory, data and input