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.

autogen.cpp 1.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * \file imperative/tablegen/autogen.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 implied.
  10. */
  11. #include "./targets/cpp_class.h"
  12. #include "./targets/pybind11.h"
  13. #include "./targets/python_c_extension.h"
  14. using llvm::raw_ostream;
  15. using llvm::RecordKeeper;
  16. enum ActionType {
  17. None,
  18. CppHeader,
  19. CppBody,
  20. Pybind,
  21. CPython
  22. };
  23. // NOLINTNEXTLINE
  24. llvm::cl::opt<ActionType> action(
  25. llvm::cl::desc("Action to perform:"),
  26. llvm::cl::values(clEnumValN(CppHeader, "gen-cpp-header",
  27. "Generate operator cpp header"),
  28. clEnumValN(CppBody, "gen-cpp-body",
  29. "Generate operator cpp body"),
  30. clEnumValN(Pybind, "gen-python-binding",
  31. "Generate pybind11 python bindings"),
  32. clEnumValN(CPython, "gen-python-c-extension",
  33. "Generate python c extensions")));
  34. using namespace mlir::tblgen;
  35. int main(int argc, char **argv) {
  36. llvm::InitLLVM y(argc, argv);
  37. llvm::cl::ParseCommandLineOptions(argc, argv);
  38. if (action == ActionType::CppHeader) {
  39. return TableGenMain(argv[0], &gen_op_def_c_header);
  40. }
  41. if (action == ActionType::CppBody) {
  42. return TableGenMain(argv[0], &gen_op_def_c_body);
  43. }
  44. if (action == ActionType::Pybind) {
  45. return TableGenMain(argv[0], &gen_op_def_pybind11);
  46. }
  47. if (action == ActionType::CPython) {
  48. return TableGenMain(argv[0], &gen_op_def_python_c_extension);
  49. }
  50. return -1;
  51. }

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