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.

handle.cpp 1.7 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * \file dnn/src/atlas/handle.cpp
  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
  10. * implied.
  11. */
  12. #include "megcore_atlas.h"
  13. #include "src/common/handle_impl.h"
  14. #include "src/atlas/handle.h"
  15. #include "src/atlas/checksum/opr_impl.h"
  16. #include <acl/acl.h>
  17. namespace megdnn {
  18. namespace atlas {
  19. HandleImpl::HandleImpl(megcoreComputingHandle_t comp_handle)
  20. : HandleImplHelper(comp_handle, HandleType::ATLAS) {
  21. // Get megcore device handle
  22. megcoreDeviceHandle_t dev_handle;
  23. megcoreGetDeviceHandle(comp_handle, &dev_handle);
  24. int dev_id;
  25. megcoreGetDeviceID(dev_handle, &dev_id);
  26. m_device_id = dev_id;
  27. megcore::getAtlasContext(comp_handle, &m_megcore_context);
  28. }
  29. HandleImpl::~HandleImpl() noexcept = default;
  30. template <typename Opr>
  31. std::unique_ptr<Opr> HandleImpl::create_operator() {
  32. megdnn_throw("unsupported atlas opr");
  33. return nullptr;
  34. }
  35. size_t HandleImpl::alignment_requirement() const {
  36. //! because memcpyasync api requires that the memory is 128bytes alignment
  37. return 64;
  38. }
  39. MEGDNN_SPECIALIZE_CREATE_OPERATOR(ChecksumForward);
  40. #pragma GCC diagnostic push
  41. #pragma GCC diagnostic ignored "-Wpragmas"
  42. #pragma GCC diagnostic ignored "-Winstantiation-after-specialization"
  43. MEGDNN_FOREACH_OPR_CLASS(MEGDNN_INST_CREATE_OPERATOR)
  44. #pragma GCC diagnostic pop
  45. } // namespace atlas
  46. } // namespace megdnn
  47. // vim: syntax=cpp.doxygen

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