opr_impl.h 1.9 KB
Newer Older
1 2 3 4
/**
 * \file dnn/src/x86/matrix_mul/opr_impl.h
 * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
 *
5
 * Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
6 7 8
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
9 10
 * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
11 12
 */
#pragma once
13

14 15
#include "src/common/utils.h"
#include "src/fallback/matrix_mul/opr_impl.h"
16 17 18 19 20 21 22 23 24 25 26 27 28
#include "src/x86/utils.h"

#if MEGDNN_X86_WITH_MKL
#include <mkl.h>
#include <mkl_cblas.h>
#elif MEGDNN_X86_WITH_OPENBLAS
#include <cblas.h>
#else
#endif

#if MEGDNN_X86_WITH_MKL_DNN
#include <mkldnn.h>
#endif
29 30 31 32 33 34 35

namespace megdnn {
namespace x86 {

class MatrixMulImpl : public fallback::MatrixMulImpl {
public:
    using fallback::MatrixMulImpl::MatrixMulImpl;
36 37 38 39 40 41
    class AlgoBase : public fallback::MatrixMulImpl::AlgoBase {
    public:
        AlgoBase() : fallback::MatrixMulImpl::AlgoBase() {
            m_handle_type = Handle::HandleType::X86;
        }
    };
42 43 44

    bool is_thread_safe() const override { return true; }

45 46
    SmallVector<fallback::MatrixMulImpl::AlgoBase*> get_all_packed_algo()
            override;
47

48 49 50 51
    static fallback::MatrixMulImpl::AlgoBase* get_algo_from_desc(
            const AlgorithmDesc& desc);

private:
52
    class AlgoF32Blas;
53
#if MEGDNN_X86_WITH_MKL && SUPPORT_MKL_PACKED_GEMM
54 55 56 57 58 59
    class AlgoF32MKLPackA;
#endif
#if MEGDNN_X86_WITH_VNNI
    class AlgoInt8x8x32Vnni;
#endif

60
#if MEGDNN_X86_WITH_MKL_DNN
61 62 63 64 65 66
    class AlgoInt8x8x32Mkldnn;
#endif

    class AlgoInt8x8x32AVX2M2N4K16;
    class AlgoInt8x8x32AVX2M4N16K2;
    class AlgoInt8x8x32SSEM4N8K2;
67
    class AlgoInt8x8x16AVX2;
68
    class AlgoInt8x8x16SSE;
69 70
    class AlgoPack;
    class AlgoF32MK8_8x8;
71
    class AlgoFloatAVX2M6N16;
72 73
public:
    static const AlgoPack& algo_pack();
74 75 76 77 78 79
};

}  // namespace x86
}  // namespace megdnn

// vim: syntax=cpp.doxygen