Skip to content

Commit c74bf64

Browse files
committed
Rebase torch patches on autopatch changes
1 parent aec220e commit c74bf64

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ index e2e1f694..870ef417 100644
1212
option(BUILD_DOCS "Build Caffe2 documentation" OFF)
1313
option(BUILD_CUSTOM_PROTOBUF "Build and use Caffe2's own protobuf under third_party" ON)
1414
diff --git a/functorch/csrc/dim/dim.cpp b/functorch/csrc/dim/dim.cpp
15-
index abdebc24..4f235d66 100644
15+
index 9bab33b6..4f235d66 100644
1616
--- a/functorch/csrc/dim/dim.cpp
1717
+++ b/functorch/csrc/dim/dim.cpp
1818
@@ -6,7 +6,7 @@
@@ -24,15 +24,6 @@ index abdebc24..4f235d66 100644
2424
#include <utility>
2525
#include <new>
2626
#include <iostream>
27-
@@ -1304,7 +1304,7 @@ static py::object __torch_function__(Arena &A, py::handle orig, py::vector_args
28-
}
29-
30-
py::vector_args as_vector_args(Arena& A, py::handle args, py::handle kwargs) {
31-
- auto pos_args = (py::handle*) &PyTuple_GET_ITEM(args.ptr(), 0);
32-
+ auto pos_args = (py::handle*) PySequence_Fast_ITEMS(args.ptr());
33-
auto pos_n = PyTuple_GET_SIZE(args.ptr());
34-
if (!kwargs.ptr()) {
35-
return py::vector_args(pos_args, pos_n, nullptr);
3627
@@ -1421,6 +1421,7 @@ PyTypeObject Tensor::Type = {
3728

3829
// dim() --------------------
@@ -307,10 +298,10 @@ index b847129d..3219d1e1 100644
307298
def clone(self):
308299
return self.__class__(self.mode)
309300
diff --git a/torch/csrc/Module.cpp b/torch/csrc/Module.cpp
310-
index 8e1ca3b1..b150ac3f 100644
301+
index 3af2e723..df857f31 100644
311302
--- a/torch/csrc/Module.cpp
312303
+++ b/torch/csrc/Module.cpp
313-
@@ -257,50 +257,14 @@ PyObject* THPModule_addDocStr(PyObject* _unused, PyObject* args) {
304+
@@ -257,50 +257,16 @@ PyObject* THPModule_addDocStr(PyObject* _unused, PyObject* args) {
314305
doc_str = all_docs.back().c_str();
315306
}
316307

@@ -320,7 +311,7 @@ index 8e1ca3b1..b150ac3f 100644
320311
- return PyErr_Format(
321312
- PyExc_RuntimeError,
322313
- "function '%s' already has a docstring",
323-
- f->m_ml->ml_name);
314+
- _PyCFunction_GetMethodDef((PyObject*)(f))->ml_name);
324315
- }
325316
- PyObject_SetDoc((PyObject*)(f), doc_str);
326317
- } else if (strcmp(Py_TYPE(obj)->tp_name, "method_descriptor") == 0) {
@@ -354,6 +345,7 @@ index 8e1ca3b1..b150ac3f 100644
354345
- }
355346
- t->tp_doc = doc_str;
356347
- } else {
348+
+ // GraalPy change
357349
+ if (PyObject_GetDoc(obj)) {
358350
return PyErr_Format(
359351
- PyExc_TypeError,
@@ -363,6 +355,7 @@ index 8e1ca3b1..b150ac3f 100644
363355
+ "object '%100R' already has a docstring",
364356
+ obj);
365357
+ }
358+
+ // GraalPy change
366359
+ if (PyObject_SetDoc(obj, doc_str) < 0) {
367360
+ return NULL;
368361
}

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/functorch/csrc/dim/dim.cpp b/functorch/csrc/dim/dim.cpp
2-
index 4cc02750..ab2497c5 100644
2+
index 21f0a166..ab2497c5 100644
33
--- a/functorch/csrc/dim/dim.cpp
44
+++ b/functorch/csrc/dim/dim.cpp
55
@@ -22,7 +22,10 @@ PyObject* Dim_init() {
@@ -27,15 +27,6 @@ index 4cc02750..ab2497c5 100644
2727

2828
// C++ API functions for objects to
2929
// * construct the object, returning a ref-counted handle
30-
@@ -1350,7 +1355,7 @@ mpy::object __torch_function__(Arena &A, mpy::handle orig, mpy::vector_args args
31-
}
32-
33-
mpy::vector_args as_vector_args(Arena& A, mpy::handle args, mpy::handle kwargs) {
34-
- auto pos_args = (mpy::handle*) &PyTuple_GET_ITEM(args.ptr(), 0);
35-
+ auto pos_args = (mpy::handle*) PySequence_Fast_ITEMS(args.ptr());
36-
auto pos_n = PyTuple_GET_SIZE(args.ptr());
37-
if (!kwargs.ptr()) {
38-
return mpy::vector_args(pos_args, pos_n, nullptr);
3930
@@ -1468,6 +1473,7 @@ PyTypeObject Tensor::Type = {
4031

4132
// dim() --------------------
@@ -356,7 +347,7 @@ index 1293a0fd..dfb4385a 100644
356347
+ torch._C._DisableFuncTorch():
357348
return _str_intern(self, tensor_contents=tensor_contents)
358349
diff --git a/torch/csrc/Module.cpp b/torch/csrc/Module.cpp
359-
index a8bf9903..0168b101 100644
350+
index b85e94d2..0168b101 100644
360351
--- a/torch/csrc/Module.cpp
361352
+++ b/torch/csrc/Module.cpp
362353
@@ -341,46 +341,16 @@ PyObject* THPModule_addDocStr(PyObject* _unused, PyObject* args) {
@@ -369,7 +360,7 @@ index a8bf9903..0168b101 100644
369360
- return PyErr_Format(
370361
- PyExc_RuntimeError,
371362
- "function '%s' already has a docstring",
372-
- f->m_ml->ml_name);
363+
- _PyCFunction_GetMethodDef((PyObject*)(f))->ml_name);
373364
- }
374365
- PyObject_SetDoc((PyObject*)(f), doc_str);
375366
- } else if (strcmp(Py_TYPE(obj)->tp_name, "method_descriptor") == 0) {

0 commit comments

Comments
 (0)