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.

fixture.cpp 1.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * \file dnn/test/atlas/fixture.cpp
  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
  10. * implied.
  11. */
  12. #include "test/atlas/fixture.h"
  13. #include "src/atlas/handle.h"
  14. #include "src/atlas/megcore/device_context.hpp"
  15. #include "src/atlas/utils.h"
  16. #include "test/common/memory_manager.h"
  17. #include "test/common/random_state.h"
  18. #include "test/common/utils.h"
  19. #include "acl/acl.h"
  20. #include <cstdlib>
  21. using namespace megdnn;
  22. using namespace test;
  23. void ATLAS::SetUp() {
  24. RandomState::reset();
  25. // use card 0
  26. megcore_check(
  27. megcoreCreateDeviceHandle(&m_dev_handle, megcorePlatformAtlas, 0));
  28. megcoreActivate(m_dev_handle);
  29. megcoreComputingHandle_t comp_handle;
  30. megcore_check(megcoreCreateComputingHandle(&comp_handle, m_dev_handle));
  31. m_handle_atlas = Handle::make(comp_handle);
  32. megdnn_assert(m_handle_atlas);
  33. }
  34. Handle* ATLAS::handle_naive() {
  35. if (!m_handle_naive)
  36. m_handle_naive = create_cpu_handle(2);
  37. return m_handle_naive.get();
  38. }
  39. void ATLAS::TearDown() {
  40. m_handle_naive.reset();
  41. m_handle_atlas.reset();
  42. MemoryManagerHolder::instance()->clear();
  43. megcoreDeactivate(m_dev_handle);
  44. }
  45. // vim: syntax=cpp.doxygen

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