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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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-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 "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(megcoreCreateDeviceHandle(&m_dev_handle, megcorePlatformAtlas, 0));
  27. megcoreActivate(m_dev_handle);
  28. megcoreComputingHandle_t comp_handle;
  29. megcore_check(megcoreCreateComputingHandle(&comp_handle, m_dev_handle));
  30. m_handle_atlas = Handle::make(comp_handle);
  31. megdnn_assert(m_handle_atlas);
  32. }
  33. Handle* ATLAS::handle_naive() {
  34. if (!m_handle_naive)
  35. m_handle_naive = create_cpu_handle(2);
  36. return m_handle_naive.get();
  37. }
  38. void ATLAS::TearDown() {
  39. m_handle_naive.reset();
  40. m_handle_atlas.reset();
  41. MemoryManagerHolder::instance()->clear();
  42. megcoreDeactivate(m_dev_handle);
  43. }
  44. // vim: syntax=cpp.doxygen