MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / DISPATCH_FUNC

Function DISPATCH_FUNC

dnn/src/arm_common/pooling/algo.cpp:308–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306 DISPATCH_FUNC(int8_t, int8, 1);
307 } else if (param.src_type.enumv() == DTypeEnum::Quantized8Asymm) {
308 DISPATCH_FUNC(uint8_t, uint8, 2);
309#if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
310 } else if (param.src_type == dtype::Float16{}) {
311 DISPATCH_FUNC(__fp16, float16, 3);
312#endif
313 }
314#undef DISPATCH_FUNC
315}
316bool PoolingImpl::AlgoFilter3AverageStride2::usable(
317 const PoolingKernSizeParam& param) const {
318 bool avaible = (param.src_type.category() == DTypeCategory::FLOAT) &&
319 param.format == Param::Format::NCHW && param.mode == Mode::AVERAGE &&
320 param.filter[0] == 3 && param.filter[1] == 3 &&
321 param.stride[0] == 2 && param.stride[1] == 2 && param.isz[0] >= 2 &&
322 param.isz[1] >= 2;
323 return avaible;
324}
325
326void PoolingImpl::AlgoFilter3AverageStride2::exec(const PoolingKernParam& param) const {
327 auto IH = param.isz[0], IW = param.isz[1];
328 auto OH = param.osz[0], OW = param.osz[1];
329 auto N = param.n, C = param.ic;
330 auto PH = param.padding[0];
331 auto PW = param.padding[1];
332
333 auto src_ptr = param.src_ptr;
334 auto dst_ptr = param.dst_ptr;
335
336#define DISPATCH_FUNC(type, MEGDNN_SIMD_WIDTH, midout_type_id) \
337 MIDOUT_BEGIN(megdnn_arm_common_pooling, midout_iv(3), midout_iv(midout_type_id)) { \
338 WorkspaceBundle wbundle = get_bundle(param); \
339 auto run = [C, IH, IW, OH, OW, PH, PW, src_ptr, dst_ptr, wbundle = wbundle, \
340 workspace_ptr = param.workspace<dt_byte>()]( \
341 size_t index, size_t thread_id) { \
342 auto ws = wbundle; \
343 ws.set(workspace_ptr + ws.total_size_in_bytes() * thread_id); \
344 size_t n = index / C; \
345 size_t c = index % C; \
346 do_average_pooling_3x3_s2x2_NEON( \
347 static_cast<const type*>(src_ptr.get_ptr()) + n * C * IH * IW + \
348 c * IH * IW, \
349 static_cast<type*>(dst_ptr.get_ptr()) + n * C * OH * OW + \
350 c * OH * OW, \
351 IH, IW, OH, OW, PH, PW, ws, MEGDNN_SIMD_WIDTH); \
352 }; \
353 MEGDNN_DISPATCH_MULTI_THREAD_CPU_KERN( \
354 static_cast<::megdnn::naive::HandleImpl*>(param.handle), N* C, run); \
355 } \
356 MIDOUT_END();
357 if (param.src_type == dtype::Float32{}) {
358 DISPATCH_FUNC(dt_float32, 4, 0);
359#if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
360 } else if (param.src_type == dtype::Float16{}) {
361 DISPATCH_FUNC(__fp16, 8, 1);
362#endif
363 }

Callers 1

algo.cppFile · 0.70

Calls 9

pooling_max_w2x2_s2x2Function · 0.85
categoryMethod · 0.80
total_size_in_bytesMethod · 0.80
get_ptrMethod · 0.80
get_bundleFunction · 0.70
execFunction · 0.50
MIDOUT_BEGINFunction · 0.50
setMethod · 0.45

Tested by

no test coverage detected