Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / tests / module_tests / events_pool_test.cpp
1 /*
2 // Copyright (c) 2016 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17
18
19 #include <gtest/gtest.h>
20 #include "api/CPP/engine.hpp"
21 #include "test_utils/test_utils.h"
22 #include "api/CPP/input_layout.hpp"
23 #include "api/CPP/network.hpp"
24
25 using namespace tests;
26 using namespace cldnn;
27
28 TEST(events_pool, DISABLED_basic_test)
29 {
30     /*
31     This tests if the events pool works and there's no memory leak.
32     */
33     auto batch_num = 1;
34     auto feature_num = 4;
35     auto x_size = 1;
36     auto y_size = 1;
37
38     topology topology;
39     topology.add(input_layout("input", { data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num))}}));
40     topology.add(activation("relu", "input", activation_relu));
41     topology.add(activation("relu1", "relu", activation_relu));
42     topology.add(activation("relu2", "relu1", activation_relu));
43     topology.add(activation("relu3", "relu2", activation_relu));
44     topology.add(activation("relu4", "relu3", activation_relu));
45     topology.add(activation("relu5", "relu4", activation_relu));
46
47     build_options bo;
48     bo.set_option(build_option::optimize_data(true));
49
50     for (int i = 0; i < 20; i++)
51     {
52         engine eng;// here we build new engine i times
53         auto input = memory::allocate(eng, { data_types::f32, format::bfyx,{ tensor(spatial(x_size, y_size), feature(feature_num), batch(batch_num)) } });
54         std::vector<float> input_vec = { -1.f, 2.f, -3.f, 4.f };
55         for (int j = 0; j < 20; j++) //then we build network j times
56         {
57             network network(eng, topology, bo);
58             network.set_input_data("input", input);
59             for(int k = 0; k < 20; k++) //and execute that network k times
60                 network.execute();  
61         }
62         EXPECT_EQ(eng.get_max_used_device_memory_size(), (uint64_t)80);
63         eng.~engine();
64     }
65 }