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.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * \file imperative/src/impl/ops/autogen.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 implied.
  10. */
  11. #include "megbrain/imperative/ops/autogen.h"
  12. #include "../op_trait.h"
  13. using namespace megdnn;
  14. // FIXME: remove this when mgb::hash support tuple_hash
  15. namespace mgb {
  16. namespace {
  17. struct HashWrapper {
  18. size_t hash;
  19. constexpr operator size_t() {return hash;}
  20. constexpr HashWrapper operator+(HashWrapper rhs) {
  21. // NOTE: use a + b + c + d, not a + (b + (c + d)) !!!
  22. return {hash * 20141203 + rhs.hash};
  23. }
  24. };
  25. template <typename... Args>
  26. constexpr size_t hash_many(const Args&... args) {
  27. return (... + HashWrapper{mgb::hash(args)});
  28. }
  29. } // anonymous namespace
  30. template<typename T, typename ...Args>
  31. struct HashTrait<std::tuple<T, Args...>> {
  32. static size_t eval(const std::tuple<T, Args...> &t) {
  33. return std::apply(hash_many<T, Args...>, t);
  34. }
  35. };
  36. } // namespace mgb
  37. namespace mgb::imperative {
  38. #include "./opdef.cpp.inl"
  39. } // namespace mgb::imperative

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