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.

kern_helper.h.hip 1.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * \file src/rocm/convolution/chanwise/kern_helper.h.hip
  3. *
  4. * This file is part of MegDNN, a deep neural network run-time library
  5. * developed by Megvii.
  6. *
  7. * \copyright Copyright (c) 2014-2019 Megvii Inc. All rights reserved.
  8. */
  9. #pragma once
  10. #include "megdnn/dtype.h"
  11. #include "src/rocm/utils.h.hip"
  12. #include <stdint.h>
  13. #include <algorithm>
  14. #include "hip_header.h"
  15. namespace megdnn {
  16. namespace rocm {
  17. namespace convolution {
  18. namespace chanwise {
  19. /*!
  20. * \brief return a / b and set mod to a % b
  21. */
  22. __device__ __forceinline__ uint32_t div_mod(uint32_t a, uint32_t b,
  23. uint32_t& mod) {
  24. uint32_t ret = a / b;
  25. mod = a - ret * b;
  26. return ret;
  27. }
  28. /*!
  29. * \brief copy a 2D matrix by all threads in a block
  30. * \param rs row stride
  31. */
  32. template <typename T>
  33. __device__ __forceinline__ void block_memcpy(T* dst, const T* src,
  34. uint32_t size) {
  35. for (uint32_t i = threadIdx.x; i < size; i += blockDim.x) {
  36. dst[i] = src[i];
  37. }
  38. __syncthreads();
  39. }
  40. } // namespace chanwise
  41. } // namespace convolution
  42. } // namespace rocm
  43. } // namespace megdnn
  44. // vim: syntax=cuda.doxygen

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台