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_IR_IR_BUILDER_HPP |
18 | #define GPU_JIT_IR_IR_BUILDER_HPP |
19 | |
20 | #include <array> |
21 | |
22 | #include "gpu/jit/ir/ir.hpp" |
23 | #include "gpu/jit/ir/kernel_info.hpp" |
24 | #include "gpu/jit/ir/tensor.hpp" |
25 | |
26 | namespace dnnl { |
27 | namespace impl { |
28 | namespace gpu { |
29 | namespace jit { |
30 | |
31 | class ir_builder_t { |
32 | public: |
33 | const stmt_t &stmt() const { return stmt_; } |
34 | |
35 | const std::array<expr_t, 3> &local_id() const { return local_id_; } |
36 | |
37 | protected: |
38 | ir_builder_t(const kernel_info_t &kernel_info) |
39 | : kernel_info_(kernel_info) {} |
40 | |
41 | void init_kernel_grid(const grid_info_t &kernel_grid, |
42 | const grid_info_t &tg_grid, int simd_size, constraint_set_t &cset, |
43 | std::vector<stmt_t> &init_stmts); |
44 | |
45 | virtual void build() = 0; |
46 | |
47 | const kernel_info_t &kernel_info_; |
48 | std::array<expr_t, 3> local_id_; // Local IDs (OpenCL) for the 0-th lane. |
49 | |
50 | stmt_t stmt_; |
51 | }; |
52 | |
53 | } // namespace jit |
54 | } // namespace gpu |
55 | } // namespace impl |
56 | } // namespace dnnl |
57 | |
58 | #endif |
59 | |