From 50d4ab5591fe003bc93452d3eddca5541d908c83 Mon Sep 17 00:00:00 2001 From: Gregor Thalhammer Date: Tue, 6 Nov 2018 09:52:37 +0100 Subject: [PATCH 1/2] change default arguments for host/buffer_pitches of rectangular buffer transfers to empty tuple instead of None --- src/wrap_cl_part_1.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wrap_cl_part_1.cpp b/src/wrap_cl_part_1.cpp index a87158f9..01a62ab3 100644 --- a/src/wrap_cl_part_1.cpp +++ b/src/wrap_cl_part_1.cpp @@ -309,8 +309,8 @@ void pyopencl_expose_part_1(py::module &m) py::arg("buffer_origin"), py::arg("host_origin"), py::arg("region"), - py::arg("buffer_pitches")=py::none(), - py::arg("host_pitches")=py::none(), + py::arg("buffer_pitches")=py::tuple(), + py::arg("host_pitches")=py::tuple(), py::arg("wait_for")=py::none(), py::arg("is_blocking")=true ); @@ -321,8 +321,8 @@ void pyopencl_expose_part_1(py::module &m) py::arg("buffer_origin"), py::arg("host_origin"), py::arg("region"), - py::arg("buffer_pitches")=py::none(), - py::arg("host_pitches")=py::none(), + py::arg("buffer_pitches")=py::tuple(), + py::arg("host_pitches")=py::tuple(), py::arg("wait_for")=py::none(), py::arg("is_blocking")=true ); @@ -333,8 +333,8 @@ void pyopencl_expose_part_1(py::module &m) py::arg("src_origin"), py::arg("dst_origin"), py::arg("region"), - py::arg("src_pitches")=py::none(), - py::arg("dst_pitches")=py::none(), + py::arg("src_pitches")=py::tuple(), + py::arg("dst_pitches")=py::tuple(), py::arg("wait_for")=py::none() ); #endif -- GitLab From e8f06ff7f9c4b55dc27b6eb995a2fb58d87cd02c Mon Sep 17 00:00:00 2001 From: Gregor Thalhammer Date: Tue, 6 Nov 2018 10:09:56 +0100 Subject: [PATCH 2/2] set and accept None as default argument for buffer/host_pitches, cast to sequence if not None --- src/wrap_cl.hpp | 4 ++-- src/wrap_cl_part_1.cpp | 12 ++++++------ src/wrap_helpers.hpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/wrap_cl.hpp b/src/wrap_cl.hpp index f76aba6b..d1948cc8 100644 --- a/src/wrap_cl.hpp +++ b/src/wrap_cl.hpp @@ -2348,8 +2348,8 @@ namespace pyopencl py::object py_buffer_origin, py::object py_host_origin, py::object py_region, - py::sequence py_buffer_pitches, - py::sequence py_host_pitches, + py::object py_buffer_pitches, + py::object py_host_pitches, py::object py_wait_for, bool is_blocking ) diff --git a/src/wrap_cl_part_1.cpp b/src/wrap_cl_part_1.cpp index 01a62ab3..a87158f9 100644 --- a/src/wrap_cl_part_1.cpp +++ b/src/wrap_cl_part_1.cpp @@ -309,8 +309,8 @@ void pyopencl_expose_part_1(py::module &m) py::arg("buffer_origin"), py::arg("host_origin"), py::arg("region"), - py::arg("buffer_pitches")=py::tuple(), - py::arg("host_pitches")=py::tuple(), + py::arg("buffer_pitches")=py::none(), + py::arg("host_pitches")=py::none(), py::arg("wait_for")=py::none(), py::arg("is_blocking")=true ); @@ -321,8 +321,8 @@ void pyopencl_expose_part_1(py::module &m) py::arg("buffer_origin"), py::arg("host_origin"), py::arg("region"), - py::arg("buffer_pitches")=py::tuple(), - py::arg("host_pitches")=py::tuple(), + py::arg("buffer_pitches")=py::none(), + py::arg("host_pitches")=py::none(), py::arg("wait_for")=py::none(), py::arg("is_blocking")=true ); @@ -333,8 +333,8 @@ void pyopencl_expose_part_1(py::module &m) py::arg("src_origin"), py::arg("dst_origin"), py::arg("region"), - py::arg("src_pitches")=py::tuple(), - py::arg("dst_pitches")=py::tuple(), + py::arg("src_pitches")=py::none(), + py::arg("dst_pitches")=py::none(), py::arg("wait_for")=py::none() ); #endif diff --git a/src/wrap_helpers.hpp b/src/wrap_helpers.hpp index 651274e0..bf6853ea 100644 --- a/src/wrap_helpers.hpp +++ b/src/wrap_helpers.hpp @@ -86,7 +86,7 @@ namespace py = pybind11; size_t NAME[2] = {0, 0}; \ if (py_##NAME.ptr() != Py_None) \ { \ - py::tuple py_tup_##NAME = py_##NAME; \ + py::tuple py_tup_##NAME = py::cast(py_##NAME); \ size_t my_len = len(py_tup_##NAME); \ if (my_len > 2) \ throw error("transfer", CL_INVALID_VALUE, #NAME "has too many components"); \ -- GitLab