[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:
parent
8ee263e7fb
commit
22e1a30294
@ -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 <iostream>
|
||||
/*! @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;
|
||||
}
|
||||
}
|
||||
|
@ -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 <iostream>
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
@ -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 <iostream>
|
||||
|
||||
#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).
|
||||
}
|
||||
}
|
||||
|
@ -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 <iostream>
|
||||
|
||||
#include "helper_functions.h"
|
||||
|
@ -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 <iostream>
|
||||
#include <chrono>
|
||||
|
||||
|
@ -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 <iostream>
|
||||
#include <chrono>
|
||||
|
||||
|
@ -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 <iostream>
|
||||
#include <iomanip>
|
||||
#include <chrono>
|
||||
@ -72,7 +71,7 @@ void chapter_7(engine& my_engine)
|
||||
std::string entry_point = "add_kernel";
|
||||
|
||||
// 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
|
||||
layout output_layout = my_layout;
|
||||
|
@ -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 <iostream>
|
||||
#include <chrono>
|
||||
|
||||
@ -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);
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include <api/CPP/memory.hpp>
|
||||
#include <api/CPP/topology.hpp>
|
||||
#include <api/CPP/reorder.hpp>
|
||||
#include <api/CPP/input_layout.hpp>
|
||||
#include <api/CPP/convolution.hpp>
|
||||
#include <api/CPP/data.hpp>
|
||||
#include <api/CPP/pooling.hpp>
|
||||
#include <api/CPP/fully_connected.hpp>
|
||||
#include <api/CPP/softmax.hpp>
|
||||
#include <api/CPP/engine.hpp>
|
||||
#include <api/CPP/network.hpp>
|
||||
#include <api/memory.hpp>
|
||||
#include <api/topology.hpp>
|
||||
#include <api/reorder.hpp>
|
||||
#include <api/input_layout.hpp>
|
||||
#include <api/convolution.hpp>
|
||||
#include <api/data.hpp>
|
||||
#include <api/pooling.hpp>
|
||||
#include <api/fully_connected.hpp>
|
||||
#include <api/softmax.hpp>
|
||||
#include <api/engine.hpp>
|
||||
#include <api/network.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -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"));
|
||||
|
@ -15,8 +15,7 @@
|
||||
*/
|
||||
#include <initializer_list>
|
||||
|
||||
#include <../api/CPP/cldnn_defs.h>
|
||||
#include <../api/CPP/memory.hpp>
|
||||
#include <../api/memory.hpp>
|
||||
|
||||
|
||||
|
||||
|
@ -29,8 +29,8 @@
|
||||
* @subpage c8 <br>
|
||||
*
|
||||
*/
|
||||
#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
|
||||
|
Loading…
Reference in New Issue
Block a user