Skip to content

Commit 18b82b0

Browse files
committed
Fix build
1 parent d2c21c9 commit 18b82b0

File tree

7 files changed

+37
-15
lines changed

7 files changed

+37
-15
lines changed

include/pybind11/detail/class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ inline void add_patient(PyObject *nurse, PyObject *patient) {
414414

415415
inline void clear_patients(PyObject *self) {
416416
auto *instance = reinterpret_cast<detail::instance *>(self);
417-
std::vector<PyObject *> patients;
417+
luisa::vector<PyObject *> patients;
418418

419419
with_internals([&](internals &internals) {
420420
auto pos = internals.patients.find(self);

include/pybind11/detail/internals.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct type_equal_to {
116116
#endif
117117

118118
template <typename value_type>
119-
using type_map = std::unordered_map<std::type_index, value_type, type_hash, type_equal_to>;
119+
using type_map = pybind::unordered_map<std::type_index, value_type, type_hash, type_equal_to>;
120120

121121
struct override_hash {
122122
inline size_t operator()(const std::pair<const PyObject *, const char *> &v) const {
@@ -126,7 +126,7 @@ struct override_hash {
126126
}
127127
};
128128

129-
using instance_map = std::unordered_multimap<const void *, instance *>;
129+
using instance_map = pybind::unordered_multimap<const void *, instance *>;
130130

131131
#ifdef Py_GIL_DISABLED
132132
// Wrapper around PyMutex to provide BasicLockable semantics
@@ -162,19 +162,19 @@ struct internals {
162162
// std::type_index -> pybind11's type information
163163
type_map<type_info *> registered_types_cpp;
164164
// PyTypeObject* -> base type_info(s)
165-
std::unordered_map<PyTypeObject *, luisa::vector<type_info *>> registered_types_py;
165+
pybind::unordered_map<PyTypeObject *, luisa::vector<type_info *>> registered_types_py;
166166
#ifdef Py_GIL_DISABLED
167167
std::unique_ptr<instance_map_shard[]> instance_shards; // void * -> instance*
168168
size_t instance_shards_mask;
169169
#else
170170
instance_map registered_instances; // void * -> instance*
171171
#endif
172-
std::unordered_set<std::pair<const PyObject *, const char *>, override_hash>
172+
pybind::unordered_set<std::pair<const PyObject *, const char *>, override_hash>
173173
inactive_override_cache;
174174
type_map<luisa::vector<bool (*)(PyObject *, void *&)>> direct_conversions;
175-
std::unordered_map<const PyObject *, luisa::vector<PyObject *>> patients;
175+
pybind::unordered_map<const PyObject *, luisa::vector<PyObject *>> patients;
176176
std::forward_list<ExceptionTranslator> registered_exception_translators;
177-
std::unordered_map<std::string, void *> shared_data; // Custom data to be shared across
177+
pybind::unordered_map<std::string, void *> shared_data; // Custom data to be shared across
178178
// extensions
179179
std::forward_list<std::string> static_strings; // Stores the std::strings backing
180180
// detail::c_str()

include/pybind11/detail/type_caster_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ PYBIND11_NAMESPACE_BEGIN(detail)
4343
class loader_life_support {
4444
private:
4545
loader_life_support *parent = nullptr;
46-
std::unordered_set<PyObject *> keep_alive;
46+
pybind::unordered_set<PyObject *> keep_alive;
4747

4848
// Store stack pointer in thread-local storage.
4949
static PYBIND11_TLS_KEY_REF get_stack_tls_key() {

include/pybind11/numpy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct numpy_type_info {
136136
};
137137

138138
struct numpy_internals {
139-
std::unordered_map<std::type_index, numpy_type_info> registered_dtypes;
139+
pybind::unordered_map<std::type_index, numpy_type_info> registered_dtypes;
140140

141141
numpy_type_info *get_type_info(const std::type_info &tinfo, bool throw_if_missing = true) {
142142
auto it = registered_dtypes.find(std::type_index(tinfo));

include/pybind11/pybind11.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@
1212
#include <luisa/core/stl/vector.h>
1313
#include <luisa/core/stl/functional.h>
1414
#include <luisa/core/stl/variant.h>
15+
#include <unordered_map>
16+
#include <unordered_set>
17+
namespace pybind {
18+
template<typename K, typename V,
19+
typename Hash = std::hash<K>,
20+
typename Eq = std::equal_to<>,
21+
typename Alloc = luisa::allocator<std::pair<const K, V>>>
22+
using unordered_map = std::unordered_map<K, V, Hash, Eq, Alloc>;
23+
template<typename K, typename V,
24+
typename Hash = std::hash<K>,
25+
typename Eq = std::equal_to<>,
26+
typename Alloc = luisa::allocator<std::pair<const K, V>>>
27+
using unordered_multimap = std::unordered_multimap<K, V, Hash, Eq, Alloc>;
28+
29+
template<typename K,
30+
typename Hash = std::hash<K>,
31+
typename Eq = std::equal_to<>,
32+
typename Alloc = luisa::allocator<K>>
33+
using unordered_set = std::unordered_set<K, Hash, Eq, Alloc>;
34+
}
35+
36+
1537
#include "detail/class.h"
1638
#include "detail/dynamic_raw_ptr_cast_if_possible.h"
1739
#include "detail/exception_translation.h"

include/pybind11/stl.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ struct array_caster {
420420
// Deliberate choice: no template specializations, for simplicity, and
421421
// because the compile time overhead for the specializations is deemed
422422
// more significant than the runtime overhead for the `temp` storage.
423-
std::vector<Value> temp;
423+
luisa::vector<Value> temp;
424424
temp.reserve(l.size());
425425
for (auto it : l) {
426426
value_conv conv;
@@ -513,16 +513,16 @@ struct type_caster<std::set<Key, Compare, Alloc>>
513513
: set_caster<std::set<Key, Compare, Alloc>, Key> {};
514514

515515
template <typename Key, typename Hash, typename Equal, typename Alloc>
516-
struct type_caster<std::unordered_set<Key, Hash, Equal, Alloc>>
517-
: set_caster<std::unordered_set<Key, Hash, Equal, Alloc>, Key> {};
516+
struct type_caster<pybind::unordered_set<Key, Hash, Equal, Alloc>>
517+
: set_caster<pybind::unordered_set<Key, Hash, Equal, Alloc>, Key> {};
518518

519519
template <typename Key, typename Value, typename Compare, typename Alloc>
520520
struct type_caster<std::map<Key, Value, Compare, Alloc>>
521521
: map_caster<std::map<Key, Value, Compare, Alloc>, Key, Value> {};
522522

523523
template <typename Key, typename Value, typename Hash, typename Equal, typename Alloc>
524-
struct type_caster<std::unordered_map<Key, Value, Hash, Equal, Alloc>>
525-
: map_caster<std::unordered_map<Key, Value, Hash, Equal, Alloc>, Key, Value> {};
524+
struct type_caster<pybind::unordered_map<Key, Value, Hash, Equal, Alloc>>
525+
: map_caster<pybind::unordered_map<Key, Value, Hash, Equal, Alloc>, Key, Value> {};
526526

527527
// This type caster is intended to be used for std::optional and std::experimental::optional
528528
template <typename Type, typename Value = typename Type::value_type>

include/pybind11/stl_bind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ class_<Vector, holder_type> bind_vector(handle scope, std::string const &name, A
566566
}
567567

568568
//
569-
// std::map, std::unordered_map
569+
// std::map, pybind::unordered_map
570570
//
571571

572572
PYBIND11_NAMESPACE_BEGIN(detail)

0 commit comments

Comments
 (0)