1/*******************************************************************************
2* Copyright 2020-2022 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#ifndef GPU_OCL_SIMPLE_CONCAT_HPP
18#define GPU_OCL_SIMPLE_CONCAT_HPP
19
20#include "common/engine.hpp"
21#include "common/primitive.hpp"
22#include "gpu/gpu_concat_pd.hpp"
23#include "gpu/gpu_primitive.hpp"
24#include "gpu/gpu_resource.hpp"
25#include "gpu/primitive_conf.hpp"
26
27namespace dnnl {
28namespace impl {
29namespace gpu {
30namespace ocl {
31
32struct simple_concat_t : public gpu_primitive_t {
33 using gpu_primitive_t::gpu_primitive_t;
34 struct pd_t : public gpu_concat_pd_t {
35 using gpu_concat_pd_t::gpu_concat_pd_t;
36
37 DECLARE_CONCAT_PD_T("simple:any", simple_concat_t);
38
39 status_t init(engine_t *engine) {
40 bool ok = n_inputs() <= 64 && attr()->has_default_values()
41 && set_default_params() == status::success;
42 if (!ok) return status::unimplemented;
43
44 CHECK(init_conf(engine));
45
46 return status::success;
47 }
48
49 status_t init_conf(engine_t *engine);
50 status_t init_kernel_ctx(compute::kernel_ctx_t &kernel_ctx) const;
51 concat_conf_t conf;
52 };
53
54 status_t init(engine_t *engine) override {
55 compute::kernel_ctx_t kernel_ctx;
56
57 status_t status = pd()->init_kernel_ctx(kernel_ctx);
58 CHECK(status);
59
60 create_kernel(engine, &kernel_, "simple_concat", kernel_ctx);
61 if (!kernel_) return status::runtime_error;
62
63 return status::success;
64 }
65
66 status_t execute(const exec_ctx_t &ctx) const override {
67 return execute_concat(ctx);
68 }
69
70private:
71 status_t execute_concat(const exec_ctx_t &ctx) const;
72 const pd_t *pd() const { return (const pd_t *)primitive_t::pd().get(); }
73
74 compute::kernel_t kernel_;
75};
76
77} // namespace ocl
78} // namespace gpu
79} // namespace impl
80} // namespace dnnl
81
82#endif
83