Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / src / gpu / wait_for_events_gpu.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 #include "primitive_inst.h"
18 #include "data_inst.h"
19 #include "prior_box_inst.h"
20 #include "input_layout_inst.h"
21 #include "implementation_map.h"
22
23 #include "network_impl.h"
24 #include "events_waiter.h"
25
26 namespace cldnn { namespace gpu {
27
28 class wait_for_events_gpu : public primitive_impl
29 {
30 public:
31     wait_for_events_gpu(const program_node& /*node*/) {}
32
33     event_impl::ptr execute(const std::vector<event_impl::ptr>& events, primitive_inst& instance) override
34     {
35         events_waiter events_waiter(instance.get_network().get_engine().get_context());
36         return events_waiter.run(events);
37     }
38
39     bool validate(const primitive_inst&) const override
40     {
41         return true;
42     }
43
44     static primitive_impl* create_data(const data_node& data)
45     {
46         return new wait_for_events_gpu(data);
47     }
48
49     static primitive_impl* create_input_layout(const input_layout_node& input)
50     {
51         return new wait_for_events_gpu(input);
52     }
53
54     static primitive_impl* create_prior_box(const prior_box_node& prior_box)
55     {
56         // This primitive is being executed on CPU during network compilation.
57         return new wait_for_events_gpu(prior_box);
58     }
59 };
60
61 namespace {
62     struct attach {
63         attach() {
64             implementation_map<data>::add({
65                 { engine_types::ocl, wait_for_events_gpu::create_data }
66             });
67
68             implementation_map<input_layout>::add({
69                 { engine_types::ocl, wait_for_events_gpu::create_input_layout }
70             });
71
72             implementation_map<prior_box>::add({
73                 { engine_types::ocl, wait_for_events_gpu::create_prior_box }
74             });
75         }
76         ~attach() {}
77     };
78     attach attach_impl;
79 }
80
81 }}