Skip to content

Commit 118b660

Browse files
committed
Sync pybind11 patch bundled in torch
1 parent f1d9d47 commit 118b660

File tree

1 file changed

+7
-81
lines changed

1 file changed

+7
-81
lines changed

graalpython/lib-graalpython/patches/torch/torch-2.2.1.patch

Lines changed: 7 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -174,81 +174,22 @@ index 6e358034..0edf7770 100644
174174
class TestWrapperSubclassAliasing(TestCase):
175175

176176
diff --git a/third_party/pybind11/include/pybind11/detail/common.h b/third_party/pybind11/include/pybind11/detail/common.h
177-
index 31a54c77..a2d2a519 100644
177+
index 31a54c77..aafeb9c8 100644
178178
--- a/third_party/pybind11/include/pybind11/detail/common.h
179179
+++ b/third_party/pybind11/include/pybind11/detail/common.h
180-
@@ -291,6 +291,9 @@ PYBIND11_WARNING_DISABLE_MSVC(4505)
181-
#if defined(PYPY_VERSION) && !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
182-
# define PYBIND11_SIMPLE_GIL_MANAGEMENT
180+
@@ -288,7 +288,7 @@ PYBIND11_WARNING_DISABLE_MSVC(4505)
181+
# undef copysign
183182
#endif
184-
+#ifdef GRAALVM_PYTHON
185-
+# define PYBIND11_SIMPLE_GIL_MANAGEMENT
186-
+#endif
187183

188-
#if defined(_MSC_VER)
189-
# if defined(PYBIND11_DEBUG_MARKER)
190-
diff --git a/third_party/pybind11/include/pybind11/detail/internals.h b/third_party/pybind11/include/pybind11/detail/internals.h
191-
index aaa7f868..855fbaf1 100644
192-
--- a/third_party/pybind11/include/pybind11/detail/internals.h
193-
+++ b/third_party/pybind11/include/pybind11/detail/internals.h
194-
@@ -186,7 +186,7 @@ struct internals {
195-
PyTypeObject *static_property_type;
196-
PyTypeObject *default_metaclass;
197-
PyObject *instance_base;
198-
-#if defined(WITH_THREAD)
199-
+#if defined(WITH_THREAD) && !defined(GRAALVM_PYTHON)
200-
// Unused if PYBIND11_SIMPLE_GIL_MANAGEMENT is defined:
201-
PYBIND11_TLS_KEY_INIT(tstate)
202-
# if PYBIND11_INTERNALS_VERSION > 4
203-
@@ -300,7 +300,7 @@ struct type_info {
184+
-#if defined(PYPY_VERSION) && !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
185+
+#if (defined(PYPY_VERSION) || defined(GRAALVM_PYTHON)) && !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
186+
# define PYBIND11_SIMPLE_GIL_MANAGEMENT
204187
#endif
205188

206-
#ifndef PYBIND11_INTERNALS_KIND
207-
-# if defined(WITH_THREAD)
208-
+# if defined(WITH_THREAD) && !defined(GRAALVM_PYTHON)
209-
# define PYBIND11_INTERNALS_KIND ""
210-
# else
211-
# define PYBIND11_INTERNALS_KIND "_without_thread"
212-
@@ -508,7 +508,7 @@ PYBIND11_NOINLINE internals &get_internals() {
213-
}
214-
auto *&internals_ptr = *internals_pp;
215-
internals_ptr = new internals();
216-
-#if defined(WITH_THREAD)
217-
+#if defined(WITH_THREAD) && !defined(GRAALVM_PYTHON)
218-
219-
PyThreadState *tstate = PyThreadState_Get();
220-
// NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
221-
@@ -544,7 +544,7 @@ PYBIND11_NOINLINE internals &get_internals() {
222-
struct local_internals {
223-
type_map<type_info *> registered_types_cpp;
224-
std::forward_list<ExceptionTranslator> registered_exception_translators;
225-
-#if defined(WITH_THREAD) && PYBIND11_INTERNALS_VERSION == 4
226-
+#if defined(WITH_THREAD) && !defined(GRAALVM_PYTHON) && PYBIND11_INTERNALS_VERSION == 4
227-
228-
// For ABI compatibility, we can't store the loader_life_support TLS key in
229-
// the `internals` struct directly. Instead, we store it in `shared_data` and
230189
diff --git a/third_party/pybind11/include/pybind11/detail/type_caster_base.h b/third_party/pybind11/include/pybind11/detail/type_caster_base.h
231-
index 16387506..2ea0fb76 100644
190+
index 16387506..53e20b48 100644
232191
--- a/third_party/pybind11/include/pybind11/detail/type_caster_base.h
233192
+++ b/third_party/pybind11/include/pybind11/detail/type_caster_base.h
234-
@@ -36,7 +36,7 @@ private:
235-
loader_life_support *parent = nullptr;
236-
std::unordered_set<PyObject *> keep_alive;
237-
238-
-#if defined(WITH_THREAD)
239-
+#if defined(WITH_THREAD) && !defined(GRAALVM_PYTHON)
240-
// Store stack pointer in thread-local storage.
241-
static PYBIND11_TLS_KEY_REF get_stack_tls_key() {
242-
# if PYBIND11_INTERNALS_VERSION == 4
243-
@@ -55,7 +55,7 @@ private:
244-
// Use single global variable for stack.
245-
static loader_life_support **get_stack_pp() {
246-
static loader_life_support *global_stack = nullptr;
247-
- return global_stack;
248-
+ return &global_stack;
249-
}
250-
static loader_life_support *get_stack_top() { return *get_stack_pp(); }
251-
static void set_stack_top(loader_life_support *value) { *get_stack_pp() = value; }
252193
@@ -484,7 +484,7 @@ PYBIND11_NOINLINE handle get_object_handle(const void *ptr, const detail::type_i
253194
}
254195

@@ -271,21 +212,6 @@ index bd5f981f..c25f036b 100644
271212
template <eval_mode mode = eval_statements>
272213
object eval_file(str, object, object) {
273214
pybind11_fail("eval_file not supported in PyPy3. Use eval");
274-
diff --git a/third_party/pybind11/include/pybind11/gil.h b/third_party/pybind11/include/pybind11/gil.h
275-
index 570a5581..feb1f95c 100644
276-
--- a/third_party/pybind11/include/pybind11/gil.h
277-
+++ b/third_party/pybind11/include/pybind11/gil.h
278-
@@ -173,8 +173,8 @@ public:
279-
if (disassoc) {
280-
// Python >= 3.7 can remove this, it's an int before 3.7
281-
// NOLINTNEXTLINE(readability-qualified-auto)
282-
- auto key = detail::get_internals().tstate;
283-
- PYBIND11_TLS_REPLACE_VALUE(key, tstate);
284-
+ // auto key = detail::get_internals().tstate;
285-
+ // PYBIND11_TLS_REPLACE_VALUE(key, tstate);
286-
}
287-
}
288-
289215
diff --git a/third_party/pybind11/include/pybind11/pybind11.h b/third_party/pybind11/include/pybind11/pybind11.h
290216
index 818115cc..b4b3bf93 100644
291217
--- a/third_party/pybind11/include/pybind11/pybind11.h

0 commit comments

Comments
 (0)