// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #include #include "core/common/inlined_containers_fwd.h" #ifndef DISABLE_ABSEIL #ifdef _MSC_VER #pragma warning(push) // C4127: conditional expression is constant #pragma warning(disable : 4127) // C4324: structure was padded due to alignment specifier // Usage of alignas causes some internal padding in places. #pragma warning(disable : 4324) // C4702: unreachable code #pragma warning(disable : 4702) #endif // _MSC_VER #include #include #include #include #ifdef _MSC_VER #pragma warning(pop) #endif // _MSC_VER #else // DISABLE_ABSEIL #include #include #include #include #endif // DISABLE_ABSEIL namespace onnxruntime { #ifndef DISABLE_ABSEIL // InlinedHashSet and InlinedHashMap are preferred // hash based containers. They store their values in the // buckets array that is allocated in one shot. It eliminates // per-node new/delete calls. Always call reserve() on any hash set/map // when the number of items is known in advance. // This does not allocate a dummy 'end' node on default construction. template class InlinedHashSet : public absl::flat_hash_set, absl::container_internal::hash_default_eq, Allocator> { using Base = absl::flat_hash_set, absl::container_internal::hash_default_eq, Allocator>; public: using Base::Base; }; template class InlinedHashMap : public absl::flat_hash_map, absl::container_internal::hash_default_eq, Allocator> { using Base = absl::flat_hash_map, absl::container_internal::hash_default_eq, Allocator>; public: using Base::Base; }; // Use this hash set/map where pointer stability is required, otherwise use // InlinedHashSet and InlinedHashMap // This does not allocate a dummy 'end' node on default construction. // Use reserve() when the number of elements is known. template class NodeHashSet : public absl::node_hash_set, absl::container_internal::hash_default_eq, Allocator> { using Base = absl::node_hash_set, absl::container_internal::hash_default_eq, Allocator>; public: using Base::Base; }; template class NodeHashMap : public absl::node_hash_map, absl::container_internal::hash_default_eq, Allocator> { using Base = absl::node_hash_map, absl::container_internal::hash_default_eq, Allocator>; public: using Base::Base; }; #else // DISABLE_ABSEIL template class InlinedHashSet : public std::unordered_set, std::equal_to, Allocator> { using Base = std::unordered_set, std::equal_to, Allocator>; public: using Base::Base; }; template class InlinedHashMap : public std::unordered_map, std::equal_to, Allocator> { using Base = std::unordered_map, std::equal_to, Allocator>; public: using Base::Base; }; // Use this hash set/map where pointer stability is required, otherwise use // InlinedHashSet and InlinedHashMap // This does not allocate a dummy 'end' node on default construction. // Use reserve() when the number of elements is known. template class NodeHashSet : public std::unordered_set, std::equal_to, Allocator> { using Base = std::unordered_set, std::equal_to, Allocator>; public: using Base::Base; }; template class NodeHashMap : public std::unordered_map, std::equal_to, Allocator> { using Base = std::unordered_map, std::equal_to, Allocator>; public: using Base::Base; }; #endif // DISABLE_ABSEIL } // namespace onnxruntime