1 | /******************************************************************************* |
2 | * Copyright 2019-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 | #include "cpu/cpu_engine.hpp" |
18 | |
19 | #include "cpu/ref_resampling.hpp" |
20 | #include "cpu/simple_resampling.hpp" |
21 | |
22 | #if DNNL_X64 |
23 | #include "cpu/x64/jit_avx512_core_resampling.hpp" |
24 | #include "cpu/x64/jit_uni_resampling.hpp" |
25 | using namespace dnnl::impl::cpu::x64; |
26 | #endif |
27 | |
28 | namespace dnnl { |
29 | namespace impl { |
30 | namespace cpu { |
31 | |
32 | namespace { |
33 | using namespace dnnl::impl::data_type; |
34 | using namespace dnnl::impl::prop_kind; |
35 | |
36 | const std::map<pk_impl_key_t, std::vector<impl_list_item_t>> &impl_list_map() { |
37 | // clang-format off |
38 | static std::map<pk_impl_key_t, std::vector<impl_list_item_t>> the_map = REG_RESAMPLING_P({ |
39 | {{forward}, { |
40 | CPU_INSTANCE_X64(jit_uni_resampling_fwd_t) |
41 | CPU_INSTANCE(simple_resampling_fwd_t) |
42 | CPU_INSTANCE(ref_resampling_fwd_t) |
43 | nullptr, |
44 | }}, |
45 | {{backward}, REG_BWD_PK({ |
46 | CPU_INSTANCE_X64(jit_avx512_core_resampling_bwd_t) |
47 | CPU_INSTANCE(simple_resampling_bwd_t) |
48 | CPU_INSTANCE(ref_resampling_bwd_t) |
49 | nullptr, |
50 | })}, |
51 | }); |
52 | // clang-format on |
53 | return the_map; |
54 | } |
55 | } // namespace |
56 | |
57 | const impl_list_item_t *get_resampling_impl_list( |
58 | const resampling_desc_t *desc) { |
59 | static const impl_list_item_t empty_list[] = {nullptr}; |
60 | |
61 | const bool is_fwd = utils::one_of( |
62 | desc->prop_kind, forward_training, forward_inference); |
63 | prop_kind_t prop_kind = is_fwd ? forward : backward; |
64 | |
65 | pk_impl_key_t key {prop_kind}; |
66 | |
67 | const auto impl_list_it = impl_list_map().find(key); |
68 | return impl_list_it != impl_list_map().cend() ? impl_list_it->second.data() |
69 | : empty_list; |
70 | } |
71 | |
72 | } // namespace cpu |
73 | } // namespace impl |
74 | } // namespace dnnl |
75 | |