1 | /******************************************************************************* |
2 | * Copyright 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_JIT_REORDER_CONFIG_HPP |
18 | #define GPU_JIT_REORDER_CONFIG_HPP |
19 | |
20 | #include <iostream> |
21 | #include <sstream> |
22 | |
23 | #include "common/memory_desc_wrapper.hpp" |
24 | #include "common/reorder_pd.hpp" |
25 | #include "gpu/jit/ir/hw_config.hpp" |
26 | #include "gpu/jit/ir/tensor.hpp" |
27 | |
28 | namespace dnnl { |
29 | namespace impl { |
30 | namespace gpu { |
31 | namespace jit { |
32 | |
33 | // Parameters for kernel generation. |
34 | struct reorder_config_t { |
35 | std::string str() const { |
36 | std::ostringstream ss; |
37 | ss << src_layout.str() << " -> " << dst_layout.str(); |
38 | return ss.str(); |
39 | } |
40 | |
41 | layout_t src_layout; |
42 | layout_t dst_layout; |
43 | |
44 | exec_config_t exec_cfg; |
45 | |
46 | reorder_config_t(engine_t *engine, const memory_desc_t *src_md, |
47 | const memory_desc_t *dst_md) |
48 | : src_layout(memory_desc_wrapper(src_md), /*do_normalize=*/false) |
49 | , dst_layout(memory_desc_wrapper(dst_md), /*do_normalize=*/false) |
50 | , exec_cfg(engine) {} |
51 | }; |
52 | |
53 | inline std::ostream &operator<<( |
54 | std::ostream &out, const reorder_config_t &cfg) { |
55 | out << cfg.str(); |
56 | return out; |
57 | } |
58 | |
59 | } // namespace jit |
60 | } // namespace gpu |
61 | } // namespace impl |
62 | } // namespace dnnl |
63 | |
64 | #endif |
65 | |