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.

common.h 1.0 kB

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include "megbrain_build_config.h"
  3. #include "megdnn/oprs/base.h"
  4. #if MGB_ENABLE_GETENV
  5. #define MGB_GETENV ::std::getenv
  6. #else
  7. #define MGB_GETENV(_name) static_cast<char*>(nullptr)
  8. #endif
  9. #ifdef WIN32
  10. #define unsetenv(_name) _putenv_s(_name, "");
  11. #define setenv(name, value, overwrite) _putenv_s(name, value)
  12. #endif
  13. namespace megdnn {
  14. /*!
  15. * \brief whether there is an algorithm from algo_pack() that is available for
  16. * current size
  17. */
  18. template <class Opr, typename... Args>
  19. bool has_available_algo(Opr* opr, Args&&... args) {
  20. auto&& all_algos = opr->get_all_algorithms_info(std::forward<Args>(args)...);
  21. return !all_algos.empty();
  22. }
  23. template <class Opr, typename... Args>
  24. bool has_no_naive_heuristic_algo(Opr* opr, Args&&... args) {
  25. auto&& algo = opr->get_algorithm_info_heuristic(std::forward<Args>(args)...);
  26. return !static_cast<bool>(algo.attribute & detail::Algorithm::Attribute::NAIVE);
  27. }
  28. } // namespace megdnn
  29. // vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}