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_JIT_BRDGMM_DW_CONV_HPP
18#define CPU_X64_JIT_BRDGMM_DW_CONV_HPP
19
20#include "common/primitive.hpp"
21
22#include "cpu/cpu_convolution_pd.hpp"
23#include "cpu/platform.hpp"
24
25#include "cpu/x64/brgemm/brgemm.hpp"
26#include "cpu/x64/jit_primitive_conf.hpp"
27
28namespace dnnl {
29namespace impl {
30namespace cpu {
31namespace x64 {
32
33struct brdgmm_dw_convolution_fwd_t : public primitive_t {
34 struct pd_t : public cpu_convolution_fwd_pd_t {
35 pd_t(const convolution_desc_t *adesc, const primitive_attr_t *attr,
36 const typename pd_t::base_class *hint_fwd_pd)
37 : cpu_convolution_fwd_pd_t(adesc, attr, hint_fwd_pd), jcp_() {}
38
39 DECLARE_COMMON_PD_T(JIT_IMPL_NAME_HELPER("brdgmm_dw:", jcp_.isa, ""),
40 brdgmm_dw_convolution_fwd_t);
41
42 status_t init(engine_t *engine);
43 jit_brdgmm_conv_conf_t jcp_;
44 std::vector<brgemm_t> bcps_;
45 size_t buffer_size_ = 0;
46
47 private:
48 status_t init_brdgmm_conf();
49 status_t init_scratchpad();
50 };
51
52 brdgmm_dw_convolution_fwd_t(const pd_t *apd) : primitive_t(apd) {}
53
54 status_t init(engine_t *engine) override;
55 status_t execute(const exec_ctx_t &ctx) const override;
56
57private:
58 std::vector<std::unique_ptr<brgemm_kernel_t>> brdgmm_kernels_;
59 const pd_t *pd() const { return (const pd_t *)primitive_t::pd().get(); }
60};
61} // namespace x64
62} // namespace cpu
63} // namespace impl
64} // namespace dnnl
65#endif
66