FbcodeMaps.h 982 B

12345678910111213141516171819202122232425262728293031323334
  1. #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
  2. #ifndef C10_UTIL_FBCODEMAPS_H_
  3. #define C10_UTIL_FBCODEMAPS_H_
  4. // Map typedefs so that we can use folly's F14 maps in fbcode without
  5. // taking a folly dependency.
  6. #ifdef FBCODE_CAFFE2
  7. #include <folly/container/F14Map.h>
  8. #include <folly/container/F14Set.h>
  9. #else
  10. #include <unordered_map>
  11. #include <unordered_set>
  12. #endif
  13. namespace c10 {
  14. #ifdef FBCODE_CAFFE2
  15. template <typename Key, typename Value>
  16. using FastMap = folly::F14FastMap<Key, Value>;
  17. template <typename Key>
  18. using FastSet = folly::F14FastSet<Key>;
  19. #else
  20. template <typename Key, typename Value>
  21. using FastMap = std::unordered_map<Key, Value>;
  22. template <typename Key>
  23. using FastSet = std::unordered_set<Key>;
  24. #endif
  25. } // namespace c10
  26. #endif // C10_UTIL_FBCODEMAPS_H_
  27. #else
  28. #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
  29. #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)