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.

static_mem_record.cpp 1.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * \file src/plugin/impl/static_mem_record.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 "megbrain/plugin/static_mem_record.h"
  13. #include "megbrain/utils/visable_data_set.h"
  14. #ifndef __IN_TEE_ENV__
  15. #if MGB_ENABLE_JSON
  16. #include <fstream>
  17. #include <iostream>
  18. using namespace mgb;
  19. using namespace cg;
  20. void StaticMemRecorder::dump_to_json() {
  21. VisableDataSet writer(m_log_dir);
  22. for (auto&& i : m_memory_chunk_recorder) {
  23. // static mem chunk
  24. if (i.id < m_weight_chunk_id) {
  25. std::string overwrite_dest_id =
  26. i.is_overwrite ? std::to_string(i.overwrite_dest_id) : "-1";
  27. Chunk c(std::to_string(i.id), Chunk::static_mem,
  28. std::to_string(i.time_begin), std::to_string(i.time_end),
  29. std::to_string(i.addr_begin), std::to_string(i.addr_end),
  30. overwrite_dest_id);
  31. writer.dump_info(c);
  32. } else {
  33. // weight mem chunk
  34. Chunk c(std::to_string(i.id), Chunk::weight_mem,
  35. std::to_string(i.time_begin), std::to_string(i.time_end),
  36. std::to_string(i.addr_begin), std::to_string(i.addr_end),
  37. "-1");
  38. writer.dump_info(c);
  39. }
  40. }
  41. for (auto&& i : m_opr_seq_recorder) {
  42. OprSeq o(std::to_string(i.id), i.name);
  43. writer.dump_info(o);
  44. }
  45. writer.write_to_file();
  46. }
  47. #endif
  48. #endif

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