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 2.2 kB

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

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