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.

opr_header_prologue.h 1.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * \file dnn/include/megdnn/internal/opr_header_prologue.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. // intentional no header guard here
  12. #include "megdnn/handle.h"
  13. #include "megdnn/opr_param_defs.h"
  14. #include "megdnn/opr_result_defs.h"
  15. #include "megdnn/oprs/base.h"
  16. #include "./visibility_prologue.h"
  17. #include <array>
  18. #include <limits>
  19. #ifndef _megdnn_in
  20. #define _megdnn_in
  21. #endif
  22. #ifndef _megdnn_out
  23. #define _megdnn_out
  24. #endif
  25. #ifndef _megdnn_tensor_in
  26. #define _megdnn_tensor_in const TensorND&
  27. #endif
  28. #ifndef _megdnn_tensor_out
  29. #define _megdnn_tensor_out const TensorND&
  30. #endif
  31. #ifndef _megdnn_tensor_inout
  32. #define _megdnn_tensor_inout const TensorND&
  33. #endif
  34. #ifndef _megdnn_workspace
  35. #define _megdnn_workspace const Workspace&
  36. #endif
  37. #define DEF_OPR_IMPL_CTOR(_opr_name, _base_name) \
  38. public: \
  39. _opr_name(Handle* handle) : _base_name(handle) {}
  40. #define DEF_OPR_IMPL(_opr_name, _base_name, _nr_inputs, _nr_outputs) \
  41. DEF_OPR_IMPL_CTOR(_opr_name, _base_name) \
  42. static MEGDNN_CONSTEXPR int NR_INPUTS = _nr_inputs; \
  43. static MEGDNN_CONSTEXPR int NR_OUTPUTS = _nr_outputs;
  44. #define DEF_OPR_PARAM(_pname) \
  45. public: \
  46. using Param = param::_pname; \
  47. Param& param() { return m_param; } \
  48. const Param& param() const { return m_param; } \
  49. \
  50. protected: \
  51. Param m_param
  52. // vim: syntax=cpp.doxygen

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