algos.h 3.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/**
 * \file dnn/src/arm_common/conv_bias/int8x8x16/algos.h
 * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
 *
 * Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 */

#pragma once

#include "../opr_impl.h"

namespace megdnn {
namespace arm_common {
class ConvBiasImpl::AlgoI8x8x16Direct final : public AlgoBase {
    SmallVector<NCBKern> get_kimpls(const NCBKernSizeParam& param) const;
    WorkspaceBundle get_bundle(const NCBKernSizeParam& param) const;
21
    static void copy_padding_kern(const WorkspaceBundle& bundle,
22 23 24
                                  const NCBKernParam& kern_param,
                                  const NCBKernIndex& ncb_index,
                                  const CpuNDRange& workspace_ids);
25
    static void do_conv_kern(const WorkspaceBundle& bundle,
26 27 28 29 30 31 32 33 34 35 36 37
                             const NCBKernParam& kern_param,
                             const NCBKernIndex& ncb_index,
                             const CpuNDRange& workspace_ids);
    bool m_large_group;

public:
    AlgoI8x8x16Direct(bool large_group) : m_large_group(large_group) {}
    bool is_reproducible() const override { return true; }
    const char* name() const override {
        return m_large_group ? "I8816DIRECT_LARGE_GROUP"
                             : "I8816DIRECT_SMALL_GROUP";
    }
38
    bool usable(const NCBKernSizeParam& param,
39
                AlgoSelectionStrategy algo_selection_strategy) const override;
40
    size_t get_workspace(const NCBKernSizeParam& param) const override;
41 42 43 44 45 46 47
    virtual SmallVector<NCBKern> dispatch_kerns(
            const NCBKernSizeParam& param) const override;
};

class ConvBiasImpl::AlgoI8x8x16Stride2 final : public AlgoBase {
    SmallVector<NCBKern> get_kimpls(const NCBKernSizeParam& param) const;
    WorkspaceBundle get_bundle(const NCBKernSizeParam& param) const;
48
    static void copy_padding_kern(const WorkspaceBundle& bundle,
49 50 51
                                  const NCBKernParam& kern_param,
                                  const NCBKernIndex& ncb_index,
                                  const CpuNDRange& workspace_ids);
52
    static void do_conv_kern(const WorkspaceBundle& bundle,
53 54 55 56 57 58 59 60 61 62 63 64
                             const NCBKernParam& kern_param,
                             const NCBKernIndex& ncb_index,
                             const CpuNDRange& workspace_ids);
    bool m_large_group;

public:
    AlgoI8x8x16Stride2(bool large_group) : m_large_group(large_group) {}
    bool is_reproducible() const override { return true; }
    const char* name() const override {
        return m_large_group ? "I8816STRD2_LARGE_GROUP"
                             : "I8816STRD2_SMALL_GROUP";
    }
65
    bool usable(const NCBKernSizeParam& param,
66 67
                AlgoSelectionStrategy algo_selection_strategy) const override;

68
    size_t get_workspace(const NCBKernSizeParam& param) const override;
69 70 71 72 73 74 75 76 77
    virtual SmallVector<NCBKern> dispatch_kerns(
            const NCBKernSizeParam& param) const override;
};

class ConvBiasImpl::AlgoI8x8x16Stride2Filter2 final : public AlgoBase {
public:
    bool is_reproducible() const override { return true; }
    const char* name() const override { return "I8816STRD2F2"; }

78
    bool usable(const NCBKernSizeParam& param,
79 80
                AlgoSelectionStrategy algo_selection_strategy) const override;

81
    size_t get_workspace(const NCBKernSizeParam& param) const override;
82 83 84 85 86 87 88 89
    virtual SmallVector<NCBKern> dispatch_kerns(
            const NCBKernSizeParam& param) const override;
};

}  // namespace arm_common
}  // namespace megdnn

// vim: syntax=cpp.doxygen