Skip to content

Commit 09de29b

Browse files
Merge pull request #874 from ndgrigorian/pybind11-update
Updated pybind11 from 2.9.2 to 2.10.0
2 parents e4fb398 + 79872a0 commit 09de29b

File tree

5 files changed

+18
-101
lines changed

5 files changed

+18
-101
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ include(FetchContent)
3131

3232
FetchContent_Declare(
3333
pybind11
34-
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.9.2.tar.gz
35-
URL_HASH SHA256=6bd528c4dbe2276635dc787b6b1f2e5316cf6b49ee3e150264e455a0d68d19c1
34+
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.10.0.tar.gz
35+
URL_HASH SHA256=eacf582fa8f696227988d08cfc46121770823839fe9e301a20fbce67e7cd70ec
3636
)
3737
FetchContent_MakeAvailable(pybind11)
3838

dpctl/apis/include/dpctl4pybind11.hpp

Lines changed: 10 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -305,55 +305,13 @@ namespace memory
305305
class usm_memory : public py::object
306306
{
307307
public:
308-
// Use macro once Pybind11 2.9.3 is released instead of code bewteen
309-
// START_TOKEN and END_TOKEN
310-
/*
311-
PYBIND11_OBJECT_CVT(
312-
usm_memory,
313-
py::object,
314-
[](PyObject *o) -> bool{ return PyObject_TypeCheck(o, &Py_MemoryType)
315-
!= 0;},
316-
[](PyObject *o) -> PyObject* { return as_usm_memory(o); }
317-
)
318-
*/
319-
// START_TOKEN
320-
321-
// these constructors do not validate, but since borrowed_t and stolen_t are
322-
// protected struct members of the object, they can only be called
323-
// internally.
324-
usm_memory(py::handle h, borrowed_t) : py::object(h, borrowed_t{}) {}
325-
usm_memory(py::handle h, stolen_t) : py::object(h, stolen_t{}) {}
326-
327-
static bool check_(py::handle h)
328-
{
329-
return h.ptr() != nullptr &&
330-
PyObject_TypeCheck(h.ptr(), &Py_MemoryType);
331-
}
332-
333-
template <typename Policy_>
334-
/* NOLINTNEXTLINE(google-explicit-constructor) */
335-
usm_memory(const py::detail::accessor<Policy_> &a)
336-
: usm_memory(py::object(a))
337-
{
338-
}
339-
340-
usm_memory(const py::object &o)
341-
: py::object(check_(o) ? o.inc_ref().ptr() : as_usm_memory(o.ptr()),
342-
stolen_t{})
343-
{
344-
if (!m_ptr)
345-
throw py::error_already_set();
346-
}
347-
348-
/* NOLINTNEXTLINE(google-explicit-constructor) */
349-
usm_memory(py::object &&o)
350-
: py::object(check_(o) ? o.release().ptr() : as_usm_memory(o.ptr()),
351-
stolen_t{})
352-
{
353-
if (!m_ptr)
354-
throw py::error_already_set();
355-
}
356-
// END_TOKEN
308+
PYBIND11_OBJECT_CVT(
309+
usm_memory,
310+
py::object,
311+
[](PyObject *o) -> bool {
312+
return PyObject_TypeCheck(o, &Py_MemoryType) != 0;
313+
},
314+
[](PyObject *o) -> PyObject * { return as_usm_memory(o); })
357315

358316
usm_memory()
359317
: py::object(::dpctl::detail::dpctl_api::get().default_usm_memory_(),
@@ -412,50 +370,9 @@ namespace tensor
412370
class usm_ndarray : public py::object
413371
{
414372
public:
415-
// In Pybind11 2.9.3 replace code between START_TOKEN and END_TOKEN with
416-
// macro
417-
/*
418-
PYBIND11_OBJECT(
419-
usm_ndarray,
420-
py::object,
421-
[](PyObject *o) -> bool {return PyObject_TypeCheck(o, &PyUSMArrayType)
422-
!= 0;}
423-
)
424-
*/
425-
426-
// START_TOKEN
427-
static bool check_(py::handle h)
428-
{
429-
return h.ptr() != nullptr &&
430-
PyObject_TypeCheck(h.ptr(), &PyUSMArrayType);
431-
}
432-
433-
// these constructors do not validate, but since borrowed_t and stolen_t are
434-
// protected struct members of the object, they can only be called
435-
// internally.
436-
usm_ndarray(py::handle h, borrowed_t) : py::object(h, borrowed_t{}) {}
437-
usm_ndarray(py::handle h, stolen_t) : py::object(h, stolen_t{}) {}
438-
439-
template <typename Policy_>
440-
/* NOLINTNEXTLINE(google-explicit-constructor) */
441-
usm_ndarray(const py::detail::accessor<Policy_> &a)
442-
: usm_ndarray(py::object(a))
443-
{
444-
}
445-
446-
usm_ndarray(const py::object &o) : py::object(o)
447-
{
448-
if (m_ptr && !check_(m_ptr))
449-
throw PYBIND11_OBJECT_CHECK_FAILED(usm_ndarray, m_ptr);
450-
}
451-
452-
/* NOLINTNEXTLINE(google-explicit-constructor) */
453-
usm_ndarray(py::object &&o) : py::object(std::move(o))
454-
{
455-
if (m_ptr && !check_(m_ptr))
456-
throw PYBIND11_OBJECT_CHECK_FAILED(usm_ndarray, m_ptr);
457-
}
458-
// END_TOKEN
373+
PYBIND11_OBJECT(usm_ndarray, py::object, [](PyObject *o) -> bool {
374+
return PyObject_TypeCheck(o, &PyUSMArrayType) != 0;
375+
})
459376

460377
usm_ndarray()
461378
: py::object(::dpctl::detail::dpctl_api::get().default_usm_ndarray_(),

examples/pybind11/external_usm_allocation/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
1313
include(FetchContent)
1414
FetchContent_Declare(
1515
pybind11
16-
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.9.2.tar.gz
17-
URL_HASH SHA256=6bd528c4dbe2276635dc787b6b1f2e5316cf6b49ee3e150264e455a0d68d19c1
16+
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.10.0.tar.gz
17+
URL_HASH SHA256=eacf582fa8f696227988d08cfc46121770823839fe9e301a20fbce67e7cd70ec
1818
)
1919
FetchContent_MakeAvailable(pybind11)
2020

examples/pybind11/onemkl_gemv/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ include(GNUInstallDirs)
1717
include(FetchContent)
1818
FetchContent_Declare(
1919
pybind11
20-
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.9.2.tar.gz
21-
URL_HASH SHA256=6bd528c4dbe2276635dc787b6b1f2e5316cf6b49ee3e150264e455a0d68d19c1
20+
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.10.0.tar.gz
21+
URL_HASH SHA256=eacf582fa8f696227988d08cfc46121770823839fe9e301a20fbce67e7cd70ec
2222
)
2323
FetchContent_MakeAvailable(pybind11)
2424

examples/pybind11/use_dpctl_syclqueue/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
1313
include(FetchContent)
1414
FetchContent_Declare(
1515
pybind11
16-
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.9.2.tar.gz
17-
URL_HASH SHA256=6bd528c4dbe2276635dc787b6b1f2e5316cf6b49ee3e150264e455a0d68d19c1
16+
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.10.0.tar.gz
17+
URL_HASH SHA256=eacf582fa8f696227988d08cfc46121770823839fe9e301a20fbce67e7cd70ec
1818
)
1919
FetchContent_MakeAvailable(pybind11)
2020

0 commit comments

Comments
 (0)