handle.cpp 6.4 KB
Newer Older
1 2 3 4
#include "src/naive/handle.h"

#include "src/common/handle_impl.h"

5
#include "src/naive/adaptive_pooling/opr_impl.h"
6 7 8 9 10 11
#include "src/naive/add_update/opr_impl.h"
#include "src/naive/argmxx/opr_impl.h"
#include "src/naive/argsort/opr_impl.h"
#include "src/naive/batch_conv_bias/opr_impl.h"
#include "src/naive/batch_normalization/opr_impl.h"
#include "src/naive/batched_matrix_mul/opr_impl.h"
12
#include "src/naive/check_non_finite/opr_impl.h"
13 14 15 16 17 18 19
#include "src/naive/checksum/opr_impl.h"
#include "src/naive/concat/opr_impl.h"
#include "src/naive/cond_take/opr_impl.h"
#include "src/naive/conv_bias/opr_impl.h"
#include "src/naive/convolution/opr_impl.h"
#include "src/naive/convolution3d/opr_impl.h"
#include "src/naive/convpooling/opr_impl.h"
20
#include "src/naive/correlation/opr_impl.h"
21
#include "src/naive/cross/opr_impl.h"
22 23
#include "src/naive/cumsum/opr_impl.h"
#include "src/naive/cvt_color/opr_impl.h"
24
#include "src/naive/dct/opr_impl.h"
25 26
#include "src/naive/deformable_conv/opr_impl.h"
#include "src/naive/deformable_ps_roi_pooling/opr_impl.h"
27
#include "src/naive/diag/opr_impl.h"
28
#include "src/naive/dot/opr_impl.h"
29
#include "src/naive/dropout/opr_impl.h"
30 31 32
#include "src/naive/elemwise/opr_impl.h"
#include "src/naive/elemwise_multi_type/opr_impl.h"
#include "src/naive/eye/opr_impl.h"
33
#include "src/naive/fake_quant/opr_impl.h"
M
Megvii Engine Team 已提交
34
#include "src/naive/fill/opr_impl.h"
35 36
#include "src/naive/flip/opr_impl.h"
#include "src/naive/gaussian_blur/opr_impl.h"
37
#include "src/naive/general_norm/opr_impl.h"
38
#include "src/naive/group_local/opr_impl.h"
39
#include "src/naive/group_norm/opr_impl.h"
40 41 42
#include "src/naive/images2neibs/opr_impl.h"
#include "src/naive/indexing_multi_axis_vec/opr_impl.h"
#include "src/naive/indexing_one_hot/opr_impl.h"
43
#include "src/naive/lamb/opr_impl.h"
44
#include "src/naive/layer_norm/opr_impl.h"
45 46 47 48
#include "src/naive/linspace/opr_impl.h"
#include "src/naive/local/opr_impl.h"
#include "src/naive/local_share/opr_impl.h"
#include "src/naive/lrn/opr_impl.h"
M
Megvii Engine Team 已提交
49
#include "src/naive/lsq/opr_impl.h"
50 51
#include "src/naive/lstm/opr_impl.h"
#include "src/naive/lstm_cell/opr_impl.h"
52
#include "src/naive/mask_conv/opr_impl.h"
M
Megvii Engine Team 已提交
53
#include "src/naive/masked_fill/opr_impl.h"
54 55 56 57
#include "src/naive/matrix_inverse/opr_impl.h"
#include "src/naive/matrix_mul/opr_impl.h"
#include "src/naive/max_tensor_diff/opr_impl.h"
#include "src/naive/mesh_indexing/opr_impl.h"
58
#include "src/naive/multi_head_attn/opr_impl.h"
59
#include "src/naive/non_zero/opr_impl.h"
60
#include "src/naive/norm/opr_impl.h"
M
Megvii Engine Team 已提交
61
#include "src/naive/padding/opr_impl.h"
62 63 64 65
#include "src/naive/param_pack/opr_impl.h"
#include "src/naive/pooling/opr_impl.h"
#include "src/naive/powc/opr_impl.h"
#include "src/naive/reduce/opr_impl.h"
66
#include "src/naive/region_restricted_convolution/opr_impl.h"
67 68
#include "src/naive/relayout/opr_impl.h"
#include "src/naive/relayout_format/opr_impl.h"
69
#include "src/naive/remap/opr_impl.h"
70 71 72
#include "src/naive/repeat/opr_impl.h"
#include "src/naive/resize/opr_impl.h"
#include "src/naive/rng/opr_impl.h"
73 74
#include "src/naive/rnn/opr_impl.h"
#include "src/naive/rnn_cell/opr_impl.h"
75 76 77 78 79 80 81
#include "src/naive/roi_align/opr_impl.h"
#include "src/naive/roi_copy/opr_impl.h"
#include "src/naive/roi_pooling/opr_impl.h"
#include "src/naive/rotate/opr_impl.h"
#include "src/naive/separable_conv/opr_impl.h"
#include "src/naive/separable_filter/opr_impl.h"
#include "src/naive/sleep/opr_impl.h"
82
#include "src/naive/sliding_window_transpose/opr_impl.h"
83
#include "src/naive/softmax/opr_impl.h"
84 85 86 87 88
#include "src/naive/split/opr_impl.h"
#include "src/naive/svd/opr_impl.h"
#include "src/naive/tensor_remap/opr_impl.h"
#include "src/naive/tile/opr_impl.h"
#include "src/naive/topk/opr_impl.h"
89
#include "src/naive/tqt/opr_impl.h"
90 91 92 93
#include "src/naive/transpose/opr_impl.h"
#include "src/naive/type_cvt/opr_impl.h"
#include "src/naive/warp_affine/opr_impl.h"
#include "src/naive/warp_perspective/opr_impl.h"
94
#include "src/naive/where/opr_impl.h"
95 96 97

namespace megdnn {
namespace naive {
98 99 100 101
//! always for ci
static size_t g_image2d_pitch_alignment = 1;
static HandleImpl::HandleVendorType g_image2d_pitch_vendor =
        HandleImpl::HandleVendorType::NOT_SPEC;
102 103

DefaultConvolutionForwardAlgorithm HandleImpl::m_default_conv_fwd_algo;
M
Megvii Engine Team 已提交
104 105
DefaultConvolutionBackwardDataAlgorithm HandleImpl::m_default_conv_bwd_data_algo;
DefaultConvolutionBackwardFilterAlgorithm HandleImpl::m_default_conv_bwd_filter_algo;
106 107
DefaultConvBiasForwardAlgorithm HandleImpl::m_default_conv_bias_fwd_algo;
DefaultConvolution3DForwardAlgorithm HandleImpl::m_default_conv3d_fwd_algo;
M
Megvii Engine Team 已提交
108
DefaultConvolution3DBackwardDataAlgorithm HandleImpl::m_default_conv3d_bwd_data_algo;
109 110
DefaultConvolution3DBackwardFilterAlgorithm
        HandleImpl::m_default_conv3d_bwd_filter_algo;
M
Megvii Engine Team 已提交
111
DefaultBatchConvBiasForwardAlgorithm HandleImpl::m_default_batch_conv_bias_fwd_algo;
112
DefaultLocalShareForwardAlgorithm HandleImpl::m_default_local_share_fwd_algo;
M
Megvii Engine Team 已提交
113
DefaultLocalShareBackwardDataAlgorithm HandleImpl::m_default_local_share_bwd_data_algo;
114 115
DefaultLocalShareBackwardFilterAlgorithm
        HandleImpl::m_default_local_share_bwd_filter_algo;
116

117 118 119
DefaultMatrixMulAlgorithm HandleImpl::m_default_matmul_fwd_algo;
DefaultBatchedMatrixMulAlgorithm HandleImpl::m_default_batched_matmul_fwd_algo;

120 121
DefaultPoolingForwardAlgorithm HandleImpl::m_default_pooling_fwd_algo;
DefaultPoolingBackwardAlgorithm HandleImpl::m_default_pooling_bwd_algo;
122 123 124 125
DeformableConvForwardAlgorithm HandleImpl::m_default_deformable_conv_fwd_algo;
DeformableConvBackwardDataAlgorithm HandleImpl::m_default_deformable_conv_bwd_data_algo;
DeformableConvBackwardFilterAlgorithm
        HandleImpl::m_default_deformable_conv_bwd_filter_algo;
126

M
Megvii Engine Team 已提交
127
HandleImpl::HandleImpl(megcoreComputingHandle_t computing_handle, HandleType type)
128 129 130 131
        : HandleImplHelper(computing_handle, type),
          m_dispatcher{megcoreGetCPUDispatcher(computing_handle)} {}

size_t HandleImpl::image2d_pitch_alignment() const {
132
    return g_image2d_pitch_alignment;
133 134
}

135
HandleImpl::HandleVendorType HandleImpl::vendor_type() const {
136
    return g_image2d_pitch_vendor;
137 138
}

139 140 141 142 143 144
size_t HandleImpl::exchange_image2d_pitch_alignment(size_t alignment) {
    auto ret = g_image2d_pitch_alignment;
    g_image2d_pitch_alignment = alignment;
    return ret;
}

145 146 147 148 149 150 151
HandleImpl::HandleVendorType HandleImpl::exchange_image2d_vendor(
        HandleImpl::HandleVendorType vendor) {
    auto ret = g_image2d_pitch_vendor;
    g_image2d_pitch_vendor = vendor;
    return ret;
}

152 153 154 155
MEGDNN_FOREACH_OPR_CLASS(MEGDNN_SPECIALIZE_CREATE_OPERATOR)

}  // namespace naive
}  // namespace megdnn
156

157
// vim: syntax=cpp.doxygen