1 | /******************************************************************************* |
2 | * Copyright 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_MATMUL_BRGEMM_MATMUL_COPY_UTILS_HPP |
18 | #define CPU_X64_MATMUL_BRGEMM_MATMUL_COPY_UTILS_HPP |
19 | |
20 | #include "cpu/x64/matmul/brgemm_matmul_utils.hpp" |
21 | |
22 | namespace dnnl { |
23 | namespace impl { |
24 | namespace cpu { |
25 | namespace x64 { |
26 | namespace matmul { |
27 | |
28 | struct jit_brgemm_matmul_copy_b_t { |
29 | struct ctx_t { |
30 | const void *src; |
31 | const void *tr_src; |
32 | const void *compensation_ptr; |
33 | const void *zp_a_compensation_ptr; |
34 | const void *zp_a_neg_value_ptr; |
35 | |
36 | dim_t current_K_start; |
37 | dim_t current_K_iters; |
38 | dim_t current_N_blk; |
39 | }; |
40 | |
41 | virtual void operator()(ctx_t *ctx) = 0; |
42 | virtual status_t create_kernel() = 0; |
43 | |
44 | jit_brgemm_matmul_copy_b_t(const brgemm_matmul_conf_t *conf) |
45 | : conf_(conf) {} |
46 | virtual ~jit_brgemm_matmul_copy_b_t() {} |
47 | |
48 | const brgemm_matmul_conf_t *conf_; |
49 | }; |
50 | |
51 | struct jit_brgemm_matmul_copy_a_t { |
52 | struct ctx_t { |
53 | const void *src; |
54 | const void *tr_src; |
55 | const void *zp_b_compensation_buffer_ptr; |
56 | const void *zp_a_compensation_result_ptr; |
57 | const void *zp_b_neg_value_ptr; |
58 | const void *zp_ab_comp_ptr; |
59 | |
60 | dim_t current_K_start; |
61 | dim_t current_K_blk; |
62 | dim_t current_M_blk; |
63 | }; |
64 | |
65 | virtual void operator()(ctx_t *ctx) = 0; |
66 | virtual status_t create_kernel() = 0; |
67 | |
68 | jit_brgemm_matmul_copy_a_t(const brgemm_matmul_conf_t *conf) |
69 | : conf_(conf) {} |
70 | virtual ~jit_brgemm_matmul_copy_a_t() {} |
71 | |
72 | const brgemm_matmul_conf_t *conf_; |
73 | }; |
74 | |
75 | status_t create_brgemm_matmul_copy_b( |
76 | std::unique_ptr<jit_brgemm_matmul_copy_b_t> ©_ker, |
77 | const brgemm_matmul_conf_t *conf); |
78 | |
79 | status_t create_brgemm_matmul_copy_a( |
80 | std::unique_ptr<jit_brgemm_matmul_copy_a_t> ©_ker, |
81 | const brgemm_matmul_conf_t *conf); |
82 | |
83 | } // namespace matmul |
84 | } // namespace x64 |
85 | } // namespace cpu |
86 | } // namespace impl |
87 | } // namespace dnnl |
88 | |
89 | #endif |
90 | |