You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

multi_thread_common.h 2.9 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * \file dnn/src/fallback/conv_bias/direct/multi_thread_common.h
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
  6. *
  7. * Unless required by applicable law or agreed to in writing,
  8. * software distributed under the License is distributed on an
  9. * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. */
  11. #pragma once
  12. #include "megbrain_build_config.h"
  13. #include "src/fallback/conv_bias/opr_impl.h"
  14. #include "src/fallback/matrix_mul/opr_impl.h"
  15. #if MEGDNN_X86
  16. #include "src/x86/conv_bias/postprocess_helper.h"
  17. #elif (MEGDNN_ARMV7 || MEGDNN_AARCH64)
  18. #include "src/arm_common/conv_bias/postprocess_helper.h"
  19. #else
  20. //! TODO: optimize common postprocess_helper with general intrinsic
  21. #include "src/common/postprocess_helper.h"
  22. #endif
  23. namespace megdnn {
  24. namespace fallback {
  25. template <class io_ctype, class compute_ctype>
  26. class MultithreadDirectConvCommon {
  27. public:
  28. using NCBKernSizeParam = fallback::ConvBiasImpl::NCBKernSizeParam;
  29. using NCBKernParam = fallback::ConvBiasImpl::NCBKernParam;
  30. using NCBKernIndex = fallback::ConvBiasImpl::NCBKernIndex;
  31. using kern_direct_conv_f32 = std::function<void(
  32. const compute_ctype* src, const compute_ctype* filter, compute_ctype* dst,
  33. size_t, size_t, size_t, size_t, size_t, size_t)>;
  34. using kern_direct_conv_f32_stride = std::function<void(
  35. const compute_ctype* src, const compute_ctype* filter, compute_ctype* dst,
  36. size_t, size_t, size_t, size_t, size_t)>;
  37. static WorkspaceBundle get_bundle(
  38. const NCBKernSizeParam& param, bool m_large_group);
  39. static WorkspaceBundle get_bundle_stride(
  40. const NCBKernSizeParam& param, bool m_large_group);
  41. static void weight_flip_kern(
  42. const WorkspaceBundle& bundle, const NCBKernParam& kern_param,
  43. const NCBKernIndex& ncb_index, const CpuNDRange& workspace_ids);
  44. static void copy_padding_kern(
  45. const WorkspaceBundle& bundle, const NCBKernParam& kern_param,
  46. const NCBKernIndex& ncb_index, const CpuNDRange& workspace_ids);
  47. static void copy_padding_kern_stride(
  48. const WorkspaceBundle& bundle, const NCBKernParam& kern_param,
  49. const NCBKernIndex& ncb_index, const CpuNDRange& workspace_ids);
  50. static void do_conv_kern(
  51. const WorkspaceBundle& bundle, const NCBKernParam& kern_param,
  52. const NCBKernIndex& ncb_index, const kern_direct_conv_f32& fun,
  53. const CpuNDRange& workspace_ids);
  54. static void do_conv_kern_stride(
  55. const WorkspaceBundle& bundle, const NCBKernParam& kern_param,
  56. const NCBKernIndex& ncb_index, const kern_direct_conv_f32_stride& fun,
  57. const CpuNDRange& workspace_ids);
  58. };
  59. } // namespace fallback
  60. } // namespace megdnn
  61. // vim: syntax=cpp.doxygen