1 | /******************************************************************************* |
2 | * Copyright 2020-2021 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 CPU_X64_JIT_UNI_SHUFFLE_HPP |
18 | #define CPU_X64_JIT_UNI_SHUFFLE_HPP |
19 | |
20 | #include "common/c_types_map.hpp" |
21 | #include "common/primitive.hpp" |
22 | |
23 | #include "cpu/cpu_shuffle_pd.hpp" |
24 | |
25 | #include "cpu/x64/cpu_isa_traits.hpp" |
26 | #include "cpu/x64/shuffle/jit_uni_shuffle_kernel.hpp" |
27 | |
28 | namespace dnnl { |
29 | namespace impl { |
30 | namespace cpu { |
31 | namespace x64 { |
32 | |
33 | template <cpu_isa_t isa> |
34 | struct jit_uni_shuffle_kernel_t; |
35 | |
36 | template <cpu_isa_t isa> |
37 | struct jit_uni_shuffle_t : public primitive_t { |
38 | struct pd_t : public cpu_shuffle_pd_t { |
39 | using cpu_shuffle_pd_t::cpu_shuffle_pd_t; |
40 | |
41 | DECLARE_COMMON_PD_T( |
42 | JIT_IMPL_NAME_HELPER("jit:" , conf_.isa, "" ), jit_uni_shuffle_t); |
43 | |
44 | status_t init(engine_t *engine); |
45 | |
46 | jit_shuffle_conf_t get_conf() const { return conf_; }; |
47 | |
48 | private: |
49 | jit_shuffle_conf_t conf_; |
50 | }; |
51 | |
52 | jit_uni_shuffle_t(const pd_t *apd); |
53 | |
54 | ~jit_uni_shuffle_t(); |
55 | |
56 | status_t init(engine_t *engine) override; |
57 | |
58 | status_t execute(const exec_ctx_t &ctx) const override; |
59 | |
60 | private: |
61 | const pd_t *pd() const { return (const pd_t *)primitive_t::pd().get(); } |
62 | status_t precompute_offsets(); |
63 | std::unique_ptr<jit_uni_shuffle_kernel_t<isa>> kernel_; |
64 | unsigned *input_off_; |
65 | }; |
66 | |
67 | } // namespace x64 |
68 | } // namespace cpu |
69 | } // namespace impl |
70 | } // namespace dnnl |
71 | |
72 | #endif |
73 | |
74 | // vim: et ts=4 sw=4 cindent cino+=l0,\:4,N-s |
75 | |