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.

megcore_cdefs.h 1.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * \file dnn/include/megcore_cdefs.h
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2020 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 <stdint.h>
  13. /**
  14. * \brief MegCore platform types
  15. */
  16. typedef enum {
  17. megcorePlatformCPU = 1,
  18. megcorePlatformCUDA = 4,
  19. megcorePlatformCambricon = 7,
  20. megcorePlatformAtlas = 8,
  21. } megcorePlatform_t;
  22. /**
  23. * \brief MegCore return codes
  24. *
  25. * Note: since MegCore has been merged into MegDNN and uses C++ API with
  26. * exception, this return status only serves for backward compatibility and all
  27. * API would return megcoreSuccess
  28. */
  29. typedef enum {
  30. megcoreSuccess = 0,
  31. megcoreErrorMemoryAllocation = 1,
  32. megcoreErrorInvalidArgument = 2,
  33. megcoreErrorInvalidDeviceHandle = 3,
  34. megcoreErrorInvalidComputingHandle = 4,
  35. megcoreErrorInternalError = 5,
  36. } megcoreStatus_t;
  37. /**
  38. * \brief Memcpy kind
  39. */
  40. typedef enum {
  41. megcoreMemcpyHostToDevice = 1,
  42. megcoreMemcpyDeviceToHost = 2,
  43. megcoreMemcpyDeviceToDevice = 3,
  44. } megcoreMemcpyKind_t;
  45. namespace megcore {
  46. /*!
  47. * \brief error reporting from asynchronous execution devices
  48. *
  49. * This is currently used by CUDA kernels. It is used to report errors that
  50. * depend on input data.
  51. */
  52. struct AsyncErrorInfo {
  53. //! number of errors occurred; only detailed information of the first error
  54. //! would be recorded
  55. uint32_t nr_error;
  56. //! tracker set by set_error_tracker()
  57. void* tracker_ptr;
  58. //! human readable message; it can contain %d which would be replaced by
  59. //! msg_args
  60. char msg[228];
  61. int msg_args[4];
  62. };
  63. } // namespace megcore
  64. // vim: syntax=cpp.doxygen

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