From b7fe735627c8888223272f84f551c90ef6d38e62 Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Sun, 26 Jan 2025 23:40:52 +0100 Subject: [PATCH 01/15] move to numpy and sycl_usm folders --- .pre-commit-config.yaml | 10 ---------- onedal/datatypes/{ => numpy}/data_conversion.cpp | 8 ++++---- onedal/datatypes/{ => numpy}/data_conversion.hpp | 4 ++-- .../datatypes/{utils => numpy}/numpy_helpers.cpp | 6 +++--- .../datatypes/{utils => numpy}/numpy_helpers.hpp | 4 ++-- .../data_conversion.cpp} | 14 +++++++------- .../data_conversion.hpp} | 6 +++--- .../dtype_conversion.cpp} | 8 ++++---- .../dtype_conversion.hpp} | 4 ++-- .../{utils => sycl_usm}/dtype_dispatcher.hpp | 0 .../sycl_usm_helpers.cpp} | 10 +++++----- .../sycl_usm_helpers.hpp} | 10 +++++----- onedal/datatypes/table.cpp | 12 ++++++------ 13 files changed, 43 insertions(+), 53 deletions(-) rename onedal/datatypes/{ => numpy}/data_conversion.cpp (99%) rename onedal/datatypes/{ => numpy}/data_conversion.hpp (93%) rename onedal/datatypes/{utils => numpy}/numpy_helpers.cpp (92%) rename onedal/datatypes/{utils => numpy}/numpy_helpers.hpp (98%) rename onedal/datatypes/{data_conversion_sua_iface.cpp => sycl_usm/data_conversion.cpp} (96%) rename onedal/datatypes/{data_conversion_sua_iface.hpp => sycl_usm/data_conversion.hpp} (91%) rename onedal/datatypes/{utils/dtype_conversions.cpp => sycl_usm/dtype_conversion.cpp} (95%) rename onedal/datatypes/{utils/dtype_conversions.hpp => sycl_usm/dtype_conversion.hpp} (96%) rename onedal/datatypes/{utils => sycl_usm}/dtype_dispatcher.hpp (100%) rename onedal/datatypes/{utils/sua_iface_helpers.cpp => sycl_usm/sycl_usm_helpers.cpp} (96%) rename onedal/datatypes/{utils/sua_iface_helpers.hpp => sycl_usm/sycl_usm_helpers.hpp} (89%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0df0706894..1c72281f71 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,16 +15,6 @@ #=============================================================================== repos: - - repo: https://github.com/psf/black - rev: 24.1.1 - hooks: - - id: black - language_version: python3.10 - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - language_version: python3.10 - repo: https://github.com/pre-commit/mirrors-clang-format rev: v14.0.6 hooks: diff --git a/onedal/datatypes/data_conversion.cpp b/onedal/datatypes/numpy/data_conversion.cpp similarity index 99% rename from onedal/datatypes/data_conversion.cpp rename to onedal/datatypes/numpy/data_conversion.cpp index 3b60518ad4..69c1f1d3f8 100644 --- a/onedal/datatypes/data_conversion.cpp +++ b/onedal/datatypes/numpy/data_conversion.cpp @@ -22,8 +22,8 @@ #include "oneapi/dal/table/homogen.hpp" #include "oneapi/dal/table/detail/homogen_utils.hpp" -#include "onedal/datatypes/data_conversion.hpp" -#include "onedal/datatypes/utils/numpy_helpers.hpp" +#include "onedal/datatypes/numpy/data_conversion.hpp" +#include "onedal/datatypes/numpy/numpy_helpers.hpp" #include "onedal/version.hpp" #if ONEDAL_VERSION <= 20230100 @@ -32,7 +32,7 @@ #include "oneapi/dal/table/csr.hpp" #endif -namespace oneapi::dal::python { +namespace oneapi::dal::python::numpy { #if ONEDAL_VERSION <= 20230100 typedef oneapi::dal::detail::csr_table csr_table_t; @@ -429,4 +429,4 @@ PyObject *convert_to_pyobject(const dal::table &input) { return res; } -} // namespace oneapi::dal::python +} // namespace oneapi::dal::python::numpy diff --git a/onedal/datatypes/data_conversion.hpp b/onedal/datatypes/numpy/data_conversion.hpp similarity index 93% rename from onedal/datatypes/data_conversion.hpp rename to onedal/datatypes/numpy/data_conversion.hpp index 920e99d013..a8bf2fac05 100644 --- a/onedal/datatypes/data_conversion.hpp +++ b/onedal/datatypes/numpy/data_conversion.hpp @@ -25,11 +25,11 @@ #include "oneapi/dal/table/common.hpp" -namespace oneapi::dal::python { +namespace oneapi::dal::python::numpy { namespace py = pybind11; PyObject *convert_to_pyobject(const dal::table &input); dal::table convert_to_table(py::object inp_obj, py::object queue = py::none()); -} // namespace oneapi::dal::python +} // namespace oneapi::dal::python::numpy diff --git a/onedal/datatypes/utils/numpy_helpers.cpp b/onedal/datatypes/numpy/numpy_helpers.cpp similarity index 92% rename from onedal/datatypes/utils/numpy_helpers.cpp rename to onedal/datatypes/numpy/numpy_helpers.cpp index bce5ee453d..7adacf7a09 100644 --- a/onedal/datatypes/utils/numpy_helpers.cpp +++ b/onedal/datatypes/numpy/numpy_helpers.cpp @@ -14,9 +14,9 @@ * limitations under the License. *******************************************************************************/ -#include "onedal/datatypes/utils/numpy_helpers.hpp" +#include "onedal/datatypes/numpy/numpy_helpers.hpp" -namespace oneapi::dal::python { +namespace oneapi::dal::python::numpy { template auto reverse_map(const std::map& input) { @@ -50,4 +50,4 @@ npy_dtype_t convert_dal_to_npy_type(dal::data_type type) { return get_dal_to_npy_map().at(type); } -} // namespace oneapi::dal::python +} // namespace oneapi::dal::python::numpy diff --git a/onedal/datatypes/utils/numpy_helpers.hpp b/onedal/datatypes/numpy/numpy_helpers.hpp similarity index 98% rename from onedal/datatypes/utils/numpy_helpers.hpp rename to onedal/datatypes/numpy/numpy_helpers.hpp index 461498d1b2..61f8b53aac 100644 --- a/onedal/datatypes/utils/numpy_helpers.hpp +++ b/onedal/datatypes/numpy/numpy_helpers.hpp @@ -140,7 +140,7 @@ #define array_data(a) PyArray_DATA((PyArrayObject *)a) #define array_size(a, i) PyArray_DIM((PyArrayObject *)a, i) -namespace oneapi::dal::python { +namespace oneapi::dal::python::numpy { using npy_dtype_t = decltype(NPY_FLOAT); using npy_to_dal_t = std::map; @@ -152,4 +152,4 @@ const dal_to_npy_t &get_dal_to_npy_map(); dal::data_type convert_npy_to_dal_type(npy_dtype_t); npy_dtype_t convert_dal_to_npy_type(dal::data_type); -} // namespace oneapi::dal::python +} // namespace oneapi::dal::python::numpy diff --git a/onedal/datatypes/data_conversion_sua_iface.cpp b/onedal/datatypes/sycl_usm/data_conversion.cpp similarity index 96% rename from onedal/datatypes/data_conversion_sua_iface.cpp rename to onedal/datatypes/sycl_usm/data_conversion.cpp index 303b9c9629..eb662a9d41 100644 --- a/onedal/datatypes/data_conversion_sua_iface.cpp +++ b/onedal/datatypes/sycl_usm/data_conversion.cpp @@ -27,12 +27,12 @@ #include "oneapi/dal/table/detail/homogen_utils.hpp" #include "onedal/common/sycl_interfaces.hpp" -#include "onedal/datatypes/data_conversion_sua_iface.hpp" -#include "onedal/datatypes/utils/dtype_conversions.hpp" -#include "onedal/datatypes/utils/dtype_dispatcher.hpp" -#include "onedal/datatypes/utils/sua_iface_helpers.hpp" +#include "onedal/datatypes/sycl_usm/data_conversion.hpp" +#include "onedal/datatypes/sycl_usm/dtype_conversion.hpp" +#include "onedal/datatypes/sycl_usm/dtype_dispatcher.hpp" +#include "onedal/datatypes/sycl_usm/sycl_usm_helpers.hpp" -namespace oneapi::dal::python { +namespace oneapi::dal::python::sycl_usm { using namespace pybind11::literals; // Please follow & table_obj) { table_obj.def_property_readonly("__sycl_usm_array_interface__", &construct_sua_iface); } -} // namespace oneapi::dal::python +} // namespace oneapi::dal::python::sycl_usm #endif // ONEDAL_DATA_PARALLEL diff --git a/onedal/datatypes/data_conversion_sua_iface.hpp b/onedal/datatypes/sycl_usm/data_conversion.hpp similarity index 91% rename from onedal/datatypes/data_conversion_sua_iface.hpp rename to onedal/datatypes/sycl_usm/data_conversion.hpp index 4d4b33e4da..d162b6e2ac 100644 --- a/onedal/datatypes/data_conversion_sua_iface.hpp +++ b/onedal/datatypes/sycl_usm/data_conversion.hpp @@ -23,12 +23,12 @@ #include "oneapi/dal/table/common.hpp" -namespace oneapi::dal::python { +namespace oneapi::dal::python::sycl_usm { namespace py = pybind11; // Convert oneDAL table with zero-copy by use of `__sycl_usm_array_interface__` protocol. -dal::table convert_from_sua_iface(py::object obj); +dal::table convert_to_table(py::object obj); // Create a dictionary for `__sycl_usm_array_interface__` protocol from oneDAL table properties. py::dict construct_sua_iface(const dal::table& input); @@ -37,4 +37,4 @@ py::dict construct_sua_iface(const dal::table& input); // USM allocations. void define_sycl_usm_array_property(py::class_& t); -} // namespace oneapi::dal::python +} // namespace oneapi::dal::python::sycl_usm diff --git a/onedal/datatypes/utils/dtype_conversions.cpp b/onedal/datatypes/sycl_usm/dtype_conversion.cpp similarity index 95% rename from onedal/datatypes/utils/dtype_conversions.cpp rename to onedal/datatypes/sycl_usm/dtype_conversion.cpp index c3abb966ee..c49878a74b 100644 --- a/onedal/datatypes/utils/dtype_conversions.cpp +++ b/onedal/datatypes/sycl_usm/dtype_conversion.cpp @@ -21,10 +21,10 @@ #include "oneapi/dal/common.hpp" #include "oneapi/dal/detail/common.hpp" -#include "onedal/datatypes/utils/dtype_conversions.hpp" -#include "onedal/datatypes/utils/dtype_dispatcher.hpp" +#include "onedal/datatypes/sycl_usm/dtype_conversion.hpp" +#include "onedal/datatypes/sycl_usm/dtype_dispatcher.hpp" -namespace oneapi::dal::python { +namespace oneapi::dal::python::sycl_usm { using fwd_map_t = std::unordered_map; using inv_map_t = std::unordered_map; @@ -139,4 +139,4 @@ std::string convert_dal_to_sua_type(dal::data_type dtype) { return get_inv_map().at(dtype); } -} // namespace oneapi::dal::python +} // namespace oneapi::dal::python::sycl_usm diff --git a/onedal/datatypes/utils/dtype_conversions.hpp b/onedal/datatypes/sycl_usm/dtype_conversion.hpp similarity index 96% rename from onedal/datatypes/utils/dtype_conversions.hpp rename to onedal/datatypes/sycl_usm/dtype_conversion.hpp index 8b9dd89db6..ac0e873437 100644 --- a/onedal/datatypes/utils/dtype_conversions.hpp +++ b/onedal/datatypes/sycl_usm/dtype_conversion.hpp @@ -45,9 +45,9 @@ namespace py = pybind11; default: _EXCEPTION; \ }; -namespace oneapi::dal::python { +namespace oneapi::dal::python::sycl_usm { dal::data_type convert_sua_to_dal_type(std::string dtype); std::string convert_dal_to_sua_type(dal::data_type dtype); -} // namespace oneapi::dal::python +} // namespace oneapi::dal::python::sycl_usm diff --git a/onedal/datatypes/utils/dtype_dispatcher.hpp b/onedal/datatypes/sycl_usm/dtype_dispatcher.hpp similarity index 100% rename from onedal/datatypes/utils/dtype_dispatcher.hpp rename to onedal/datatypes/sycl_usm/dtype_dispatcher.hpp diff --git a/onedal/datatypes/utils/sua_iface_helpers.cpp b/onedal/datatypes/sycl_usm/sycl_usm_helpers.cpp similarity index 96% rename from onedal/datatypes/utils/sua_iface_helpers.cpp rename to onedal/datatypes/sycl_usm/sycl_usm_helpers.cpp index d345a35645..d76c98a6ee 100644 --- a/onedal/datatypes/utils/sua_iface_helpers.cpp +++ b/onedal/datatypes/sycl_usm/sycl_usm_helpers.cpp @@ -27,9 +27,9 @@ #include "oneapi/dal/table/detail/homogen_utils.hpp" #include "onedal/common/sycl_interfaces.hpp" -#include "onedal/datatypes/data_conversion_sua_iface.hpp" -#include "onedal/datatypes/utils/dtype_conversions.hpp" -#include "onedal/datatypes/utils/dtype_dispatcher.hpp" +#include "onedal/datatypes/sycl_usm/data_conversion.hpp" +#include "onedal/datatypes/sycl_usm/dtype_conversion.hpp" +#include "onedal/datatypes/sycl_usm/dtype_dispatcher.hpp" /* __sycl_usm_array_interface__ * @@ -53,7 +53,7 @@ * api_reference/dpctl/sycl_usm_array_interface.html#sycl-usm-array-interface-attribute> */ -namespace oneapi::dal::python { +namespace oneapi::dal::python::sycl_usm { // Convert a string encoding elemental data type of the array to oneDAL homogen table data type. dal::data_type get_sua_dtype(const py::dict& sua) { @@ -197,6 +197,6 @@ py::tuple get_npy_strides(const dal::data_layout& data_layout, return strides; } -} // namespace oneapi::dal::python +} // namespace oneapi::dal::python::sycl_usm #endif // ONEDAL_DATA_PARALLEL diff --git a/onedal/datatypes/utils/sua_iface_helpers.hpp b/onedal/datatypes/sycl_usm/sycl_usm_helpers.hpp similarity index 89% rename from onedal/datatypes/utils/sua_iface_helpers.hpp rename to onedal/datatypes/sycl_usm/sycl_usm_helpers.hpp index 050dad036f..eb5ead8a85 100644 --- a/onedal/datatypes/utils/sua_iface_helpers.hpp +++ b/onedal/datatypes/sycl_usm/sycl_usm_helpers.hpp @@ -27,11 +27,11 @@ #include "oneapi/dal/table/detail/homogen_utils.hpp" #include "onedal/common/sycl_interfaces.hpp" -#include "onedal/datatypes/data_conversion_sua_iface.hpp" -#include "onedal/datatypes/utils/dtype_conversions.hpp" -#include "onedal/datatypes/utils/dtype_dispatcher.hpp" +#include "onedal/datatypes/sycl_usm/data_conversion.hpp" +#include "onedal/datatypes/sycl_usm/dtype_conversion.hpp" +#include "onedal/datatypes/sycl_usm/dtype_dispatcher.hpp" -namespace oneapi::dal::python { +namespace oneapi::dal::python::sycl_usm { dal::data_type get_sua_dtype(const py::dict& sua); @@ -62,6 +62,6 @@ py::tuple get_npy_strides(const dal::data_layout& data_layout, npy_intp row_count, npy_intp column_count); -} // namespace oneapi::dal::python +} // namespace oneapi::dal::python::sycl_usm #endif // ONEDAL_DATA_PARALLEL diff --git a/onedal/datatypes/table.cpp b/onedal/datatypes/table.cpp index ed8a931522..4d84f50138 100644 --- a/onedal/datatypes/table.cpp +++ b/onedal/datatypes/table.cpp @@ -18,11 +18,11 @@ #include "oneapi/dal/table/homogen.hpp" #ifdef ONEDAL_DATA_PARALLEL -#include "onedal/datatypes/data_conversion_sua_iface.hpp" +#include "onedal/datatypes/sycl_usm/data_conversion.hpp" #endif // ONEDAL_DATA_PARALLEL -#include "onedal/datatypes/data_conversion.hpp" -#include "onedal/datatypes/utils/numpy_helpers.hpp" +#include "onedal/datatypes/numpy/data_conversion.hpp" +#include "onedal/datatypes/numpy/numpy_helpers.hpp" #include "onedal/common/pybind11_helpers.hpp" #include "onedal/version.hpp" @@ -84,15 +84,15 @@ ONEDAL_PY_INIT_MODULE(table) { m.def("to_table", [](py::object obj, py::object queue) { #ifdef ONEDAL_DATA_PARALLEL if (py::hasattr(obj, "__sycl_usm_array_interface__")) { - return convert_from_sua_iface(obj); + return sycl_usm::convert_to_table(obj); } #endif // ONEDAL_DATA_PARALLEL - return convert_to_table(obj, queue); + return numpy::convert_to_table(obj, queue); }); m.def("from_table", [](const dal::table& t) -> py::handle { - auto* obj_ptr = convert_to_pyobject(t); + auto* obj_ptr = numpy::convert_to_pyobject(t); return obj_ptr; }); } From d1c571c7841e62e1788fe7b2ec8b7790c6cece0b Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Sun, 26 Jan 2025 23:43:57 +0100 Subject: [PATCH 02/15] fix pre-commit --- .pre-commit-config.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1c72281f71..0df0706894 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,16 @@ #=============================================================================== repos: + - repo: https://github.com/psf/black + rev: 24.1.1 + hooks: + - id: black + language_version: python3.10 + - repo: https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort + language_version: python3.10 - repo: https://github.com/pre-commit/mirrors-clang-format rev: v14.0.6 hooks: From dd5ab06c41e9645c542a2feea7233993a3dc4bd8 Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Sun, 26 Jan 2025 23:53:17 +0100 Subject: [PATCH 03/15] fix pickling --- onedal/basic_statistics/basic_statistics.cpp | 24 ++++++++++---------- onedal/covariance/covariance.cpp | 15 ++++++------ onedal/decomposition/pca.cpp | 19 ++++++++-------- onedal/linear_model/linear_model.cpp | 10 ++++---- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/onedal/basic_statistics/basic_statistics.cpp b/onedal/basic_statistics/basic_statistics.cpp index 6d037ef08a..2a2d091cf0 100644 --- a/onedal/basic_statistics/basic_statistics.cpp +++ b/onedal/basic_statistics/basic_statistics.cpp @@ -20,7 +20,7 @@ #include "onedal/version.hpp" #define NO_IMPORT_ARRAY // import_array called in table.cpp -#include "onedal/datatypes/data_conversion.hpp" +#include "onedal/datatypes/numpy/data_conversion.hpp" #include #include @@ -210,11 +210,11 @@ void init_partial_compute_result(py::module_& m) { .def(py::pickle( [](const result_t& res) { return py::make_tuple( - py::cast(convert_to_pyobject(res.get_partial_n_rows())), - py::cast(convert_to_pyobject(res.get_partial_min())), - py::cast(convert_to_pyobject(res.get_partial_max())), - py::cast(convert_to_pyobject(res.get_partial_sum())), - py::cast(convert_to_pyobject(res.get_partial_sum_squares())), + py::cast(numpy::convert_to_pyobject(res.get_partial_n_rows())), + py::cast(numpy::convert_to_pyobject(res.get_partial_min())), + py::cast(numpy::convert_to_pyobject(res.get_partial_max())), + py::cast(numpy::convert_to_pyobject(res.get_partial_sum())), + py::cast(numpy::convert_to_pyobject(res.get_partial_sum_squares())), py::cast( convert_to_pyobject(res.get_partial_sum_squares_centered()))); }, @@ -223,17 +223,17 @@ void init_partial_compute_result(py::module_& m) { throw std::runtime_error("Invalid state!"); result_t res; if (py::cast(t[0].attr("size")) != 0) - res.set_partial_n_rows(convert_to_table(t[0])); + res.set_partial_n_rows(numpy::convert_to_table(t[0])); if (py::cast(t[1].attr("size")) != 0) - res.set_partial_min(convert_to_table(t[1])); + res.set_partial_min(numpy::convert_to_table(t[1])); if (py::cast(t[2].attr("size")) != 0) - res.set_partial_max(convert_to_table(t[2])); + res.set_partial_max(numpy::convert_to_table(t[2])); if (py::cast(t[3].attr("size")) != 0) - res.set_partial_sum(convert_to_table(t[3])); + res.set_partial_sum(numpy::convert_to_table(t[3])); if (py::cast(t[4].attr("size")) != 0) - res.set_partial_sum_squares(convert_to_table(t[4])); + res.set_partial_sum_squares(numpy::convert_to_table(t[4])); if (py::cast(t[5].attr("size")) != 0) - res.set_partial_sum_squares_centered(convert_to_table(t[5])); + res.set_partial_sum_squares_centered(numpy::convert_to_table(t[5])); return res; })); diff --git a/onedal/covariance/covariance.cpp b/onedal/covariance/covariance.cpp index cc9bf83aba..231b1ba3f0 100644 --- a/onedal/covariance/covariance.cpp +++ b/onedal/covariance/covariance.cpp @@ -19,7 +19,7 @@ #include "oneapi/dal/algo/covariance.hpp" #define NO_IMPORT_ARRAY // import_array called in table.cpp -#include "onedal/datatypes/data_conversion.hpp" +#include "onedal/datatypes/numpy/data_conversion.hpp" #include "onedal/common.hpp" #include "onedal/version.hpp" @@ -141,20 +141,21 @@ inline void init_partial_compute_result(pybind11::module_& m) { .def(py::pickle( [](const result_t& res) { return py::make_tuple( - py::cast(convert_to_pyobject(res.get_partial_n_rows())), - py::cast(convert_to_pyobject(res.get_partial_crossproduct())), - py::cast(convert_to_pyobject(res.get_partial_sum()))); + py::cast(numpy::convert_to_pyobject(res.get_partial_n_rows())), + py::cast( + numpy::convert_to_pyobject(res.get_partial_crossproduct())), + py::cast(numpy::convert_to_pyobject(res.get_partial_sum()))); }, [](py::tuple t) { if (t.size() != 3) throw std::runtime_error("Invalid state!"); result_t res; if (py::cast(t[0].attr("size")) != 0) - res.set_partial_n_rows(convert_to_table(t[0])); + res.set_partial_n_rows(numpy::convert_to_table(t[0])); if (py::cast(t[1].attr("size")) != 0) - res.set_partial_crossproduct(convert_to_table(t[1])); + res.set_partial_crossproduct(numpy::convert_to_table(t[1])); if (py::cast(t[2].attr("size")) != 0) - res.set_partial_sum(convert_to_table(t[2])); + res.set_partial_sum(numpy::convert_to_table(t[2])); return res; })); } diff --git a/onedal/decomposition/pca.cpp b/onedal/decomposition/pca.cpp index 929824ce9b..49226f3265 100644 --- a/onedal/decomposition/pca.cpp +++ b/onedal/decomposition/pca.cpp @@ -16,7 +16,7 @@ #include "oneapi/dal/algo/pca.hpp" #include "onedal/common.hpp" #define NO_IMPORT_ARRAY // import_array called in table.cpp -#include "onedal/datatypes/data_conversion.hpp" +#include "onedal/datatypes/numpy/data_conversion.hpp" namespace py = pybind11; @@ -134,12 +134,13 @@ void init_partial_train_result(py::module_& m) { int auxiliary_size = res.get_auxiliary_table_count(); for (int i = 0; i < auxiliary_size; i++) { auto aux_table = res.get_auxiliary_table(i); - auxiliary.append(py::cast(convert_to_pyobject(aux_table))); + auxiliary.append(py::cast(numpy::convert_to_pyobject(aux_table))); } return py::make_tuple( - py::cast(convert_to_pyobject(res.get_partial_n_rows())), - py::cast(convert_to_pyobject(res.get_partial_crossproduct())), - py::cast(convert_to_pyobject(res.get_partial_sum())), + py::cast(numpy::convert_to_pyobject(res.get_partial_n_rows())), + py::cast( + numpy::convert_to_pyobject(res.get_partial_crossproduct())), + py::cast(numpy::convert_to_pyobject(res.get_partial_sum())), auxiliary); }, [](py::tuple t) { @@ -147,14 +148,14 @@ void init_partial_train_result(py::module_& m) { throw std::runtime_error("Invalid state!"); result_t res; if (py::cast(t[0].attr("size")) != 0) - res.set_partial_n_rows(convert_to_table(t[0])); + res.set_partial_n_rows(numpy::convert_to_table(t[0])); if (py::cast(t[1].attr("size")) != 0) - res.set_partial_crossproduct(convert_to_table(t[1])); + res.set_partial_crossproduct(numpy::convert_to_table(t[1])); if (py::cast(t[2].attr("size")) != 0) - res.set_partial_sum(convert_to_table(t[2])); + res.set_partial_sum(numpy::convert_to_table(t[2])); py::list aux_list = t[3].cast(); for (int i = 0; i < aux_list.size(); i++) { - res.set_auxiliary_table(convert_to_table(aux_list[i])); + res.set_auxiliary_table(numpy::convert_to_table(aux_list[i])); } return res; })); diff --git a/onedal/linear_model/linear_model.cpp b/onedal/linear_model/linear_model.cpp index 450ef905ea..ae32a752e0 100644 --- a/onedal/linear_model/linear_model.cpp +++ b/onedal/linear_model/linear_model.cpp @@ -20,7 +20,7 @@ #include "onedal/version.hpp" #define NO_IMPORT_ARRAY // import_array called in table.cpp -#include "onedal/datatypes/data_conversion.hpp" +#include "onedal/datatypes/numpy/data_conversion.hpp" #include @@ -244,17 +244,17 @@ void init_partial_train_result(py::module_& m) { .def(py::pickle( [](const result_t& res) { return py::make_tuple( - py::cast(convert_to_pyobject(res.get_partial_xtx())), - py::cast(convert_to_pyobject(res.get_partial_xty()))); + py::cast(numpy::convert_to_pyobject(res.get_partial_xtx())), + py::cast(numpy::convert_to_pyobject(res.get_partial_xty()))); }, [](py::tuple t) { if (t.size() != 2) throw std::runtime_error("Invalid state!"); result_t res; if (py::cast(t[0].attr("size")) != 0) - res.set_partial_xtx(convert_to_table(t[0])); + res.set_partial_xtx(numpy::convert_to_table(t[0])); if (py::cast(t[1].attr("size")) != 0) - res.set_partial_xty(convert_to_table(t[1])); + res.set_partial_xty(numpy::convert_to_table(t[1])); return res; })); } From c33ed206e94cbb28d6d1c49d0f4ad2299d78320e Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Mon, 27 Jan 2025 00:01:19 +0100 Subject: [PATCH 04/15] forgotten numpy namespace is BS --- onedal/basic_statistics/basic_statistics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onedal/basic_statistics/basic_statistics.cpp b/onedal/basic_statistics/basic_statistics.cpp index 2a2d091cf0..1d8e860ff4 100644 --- a/onedal/basic_statistics/basic_statistics.cpp +++ b/onedal/basic_statistics/basic_statistics.cpp @@ -216,7 +216,7 @@ void init_partial_compute_result(py::module_& m) { py::cast(numpy::convert_to_pyobject(res.get_partial_sum())), py::cast(numpy::convert_to_pyobject(res.get_partial_sum_squares())), py::cast( - convert_to_pyobject(res.get_partial_sum_squares_centered()))); + numpy::convert_to_pyobject(res.get_partial_sum_squares_centered()))); }, [](py::tuple t) { if (t.size() != 6) From 9fdb3ce3aba3e2ecb60915ba6bdf61928d696c4c Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Mon, 27 Jan 2025 00:06:09 +0100 Subject: [PATCH 05/15] missing another numpy --- onedal/datatypes/table.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onedal/datatypes/table.cpp b/onedal/datatypes/table.cpp index 4d84f50138..643326d635 100644 --- a/onedal/datatypes/table.cpp +++ b/onedal/datatypes/table.cpp @@ -74,7 +74,7 @@ ONEDAL_PY_INIT_MODULE(table) { }); table_obj.def_property_readonly("dtype", [](const table& t) { // returns a numpy dtype, even if source was not from numpy - return py::dtype(convert_dal_to_npy_type(t.get_metadata().get_data_type(0))); + return py::dtype(numpy::convert_dal_to_npy_type(t.get_metadata().get_data_type(0))); }); #ifdef ONEDAL_DATA_PARALLEL From b47c12d0eae5baa1e7a8026c05272947c9b7a992 Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Mon, 27 Jan 2025 00:10:24 +0100 Subject: [PATCH 06/15] missing another numpy --- onedal/datatypes/table_metadata.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onedal/datatypes/table_metadata.cpp b/onedal/datatypes/table_metadata.cpp index d83baa7cf3..ddea5ffef6 100644 --- a/onedal/datatypes/table_metadata.cpp +++ b/onedal/datatypes/table_metadata.cpp @@ -16,7 +16,7 @@ #include "oneapi/dal/table/common.hpp" -#include "onedal/datatypes/utils/numpy_helpers.hpp" +#include "onedal/datatypes/numpy/numpy_helpers.hpp" #include "onedal/common/pybind11_helpers.hpp" #include "onedal/version.hpp" @@ -38,7 +38,7 @@ ONEDAL_PY_INIT_MODULE(table_metadata) { table_metadata_obj.def("get_npy_dtype", [](const table_metadata* const ptr, std::int64_t feature) { const auto npy_type = - convert_dal_to_npy_type(ptr->get_data_type(feature)); + numpy::convert_dal_to_npy_type(ptr->get_data_type(feature)); return py::dtype(npy_type); }); From b853e8890db46eff4019808b48566d1df996dcb0 Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Mon, 27 Jan 2025 00:16:56 +0100 Subject: [PATCH 07/15] add missing sycl_usm --- onedal/datatypes/table.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onedal/datatypes/table.cpp b/onedal/datatypes/table.cpp index 643326d635..20e938783b 100644 --- a/onedal/datatypes/table.cpp +++ b/onedal/datatypes/table.cpp @@ -78,7 +78,7 @@ ONEDAL_PY_INIT_MODULE(table) { }); #ifdef ONEDAL_DATA_PARALLEL - define_sycl_usm_array_property(table_obj); + sycl_usm::define_sycl_usm_array_property(table_obj); #endif // ONEDAL_DATA_PARALLEL m.def("to_table", [](py::object obj, py::object queue) { From 3529695c3cc85ac3cd32eaee2cb4e01f81b59c3f Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Mon, 27 Jan 2025 13:15:10 +0100 Subject: [PATCH 08/15] remove table_metadata --- onedal/datatypes/table_metadata.cpp | 50 ----------------------------- 1 file changed, 50 deletions(-) delete mode 100644 onedal/datatypes/table_metadata.cpp diff --git a/onedal/datatypes/table_metadata.cpp b/onedal/datatypes/table_metadata.cpp deleted file mode 100644 index ddea5ffef6..0000000000 --- a/onedal/datatypes/table_metadata.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* -* Copyright 2023 Intel Corporation -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*******************************************************************************/ - -#include "oneapi/dal/table/common.hpp" - -#include "onedal/datatypes/numpy/numpy_helpers.hpp" -#include "onedal/common/pybind11_helpers.hpp" -#include "onedal/version.hpp" - -namespace py = pybind11; - -namespace oneapi::dal::python { - -ONEDAL_PY_INIT_MODULE(table_metadata) { - py::class_ table_metadata_obj(m, "table_metadata"); - table_metadata_obj.def(py::init()); - table_metadata_obj.def_property_readonly("feature_count", // - &table_metadata::get_feature_count); - - table_metadata_obj.def("get_raw_dtype", - [](const table_metadata* const ptr, std::int64_t feature) { - return static_cast(ptr->get_data_type(feature)); - }); - - table_metadata_obj.def("get_npy_dtype", - [](const table_metadata* const ptr, std::int64_t feature) { - const auto npy_type = - numpy::convert_dal_to_npy_type(ptr->get_data_type(feature)); - return py::dtype(npy_type); - }); - - m.def("get_table_metadata", [](const dal::table& t) { - return t.get_metadata(); - }); -} - -} // namespace oneapi::dal::python From e4a0a564e5ddb0487957597b63ae3b632eae42de Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Mon, 27 Jan 2025 13:36:36 +0100 Subject: [PATCH 09/15] remove unneeded includes and move dtype_dispatcher into a central location --- onedal/datatypes/{sycl_usm => }/dtype_dispatcher.hpp | 0 onedal/datatypes/sycl_usm/data_conversion.cpp | 1 - onedal/datatypes/sycl_usm/dtype_conversion.cpp | 2 +- 3 files changed, 1 insertion(+), 2 deletions(-) rename onedal/datatypes/{sycl_usm => }/dtype_dispatcher.hpp (100%) diff --git a/onedal/datatypes/sycl_usm/dtype_dispatcher.hpp b/onedal/datatypes/dtype_dispatcher.hpp similarity index 100% rename from onedal/datatypes/sycl_usm/dtype_dispatcher.hpp rename to onedal/datatypes/dtype_dispatcher.hpp diff --git a/onedal/datatypes/sycl_usm/data_conversion.cpp b/onedal/datatypes/sycl_usm/data_conversion.cpp index eb662a9d41..7876ac6f3e 100644 --- a/onedal/datatypes/sycl_usm/data_conversion.cpp +++ b/onedal/datatypes/sycl_usm/data_conversion.cpp @@ -29,7 +29,6 @@ #include "onedal/common/sycl_interfaces.hpp" #include "onedal/datatypes/sycl_usm/data_conversion.hpp" #include "onedal/datatypes/sycl_usm/dtype_conversion.hpp" -#include "onedal/datatypes/sycl_usm/dtype_dispatcher.hpp" #include "onedal/datatypes/sycl_usm/sycl_usm_helpers.hpp" namespace oneapi::dal::python::sycl_usm { diff --git a/onedal/datatypes/sycl_usm/dtype_conversion.cpp b/onedal/datatypes/sycl_usm/dtype_conversion.cpp index c49878a74b..ab5dba5da9 100644 --- a/onedal/datatypes/sycl_usm/dtype_conversion.cpp +++ b/onedal/datatypes/sycl_usm/dtype_conversion.cpp @@ -22,7 +22,7 @@ #include "oneapi/dal/detail/common.hpp" #include "onedal/datatypes/sycl_usm/dtype_conversion.hpp" -#include "onedal/datatypes/sycl_usm/dtype_dispatcher.hpp" +#include "onedal/datatypes/dtype_dispatcher.hpp" namespace oneapi::dal::python::sycl_usm { From 4ee9026e89470ccf6a5fea39eb9fe873b70216b7 Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Mon, 27 Jan 2025 14:08:23 +0100 Subject: [PATCH 10/15] remove header reference --- onedal/datatypes/sycl_usm/sycl_usm_helpers.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/onedal/datatypes/sycl_usm/sycl_usm_helpers.hpp b/onedal/datatypes/sycl_usm/sycl_usm_helpers.hpp index eb5ead8a85..75834bedef 100644 --- a/onedal/datatypes/sycl_usm/sycl_usm_helpers.hpp +++ b/onedal/datatypes/sycl_usm/sycl_usm_helpers.hpp @@ -29,7 +29,6 @@ #include "onedal/common/sycl_interfaces.hpp" #include "onedal/datatypes/sycl_usm/data_conversion.hpp" #include "onedal/datatypes/sycl_usm/dtype_conversion.hpp" -#include "onedal/datatypes/sycl_usm/dtype_dispatcher.hpp" namespace oneapi::dal::python::sycl_usm { From edb934710ef7a754e87001445effa9e1271eb33c Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Mon, 27 Jan 2025 14:23:20 +0100 Subject: [PATCH 11/15] missed save --- onedal/datatypes/sycl_usm/sycl_usm_helpers.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/onedal/datatypes/sycl_usm/sycl_usm_helpers.cpp b/onedal/datatypes/sycl_usm/sycl_usm_helpers.cpp index d76c98a6ee..cbc7de4bec 100644 --- a/onedal/datatypes/sycl_usm/sycl_usm_helpers.cpp +++ b/onedal/datatypes/sycl_usm/sycl_usm_helpers.cpp @@ -29,7 +29,6 @@ #include "onedal/common/sycl_interfaces.hpp" #include "onedal/datatypes/sycl_usm/data_conversion.hpp" #include "onedal/datatypes/sycl_usm/dtype_conversion.hpp" -#include "onedal/datatypes/sycl_usm/dtype_dispatcher.hpp" /* __sycl_usm_array_interface__ * From bfc66b66b9f326bff2e24430fa24d7d9bcc30196 Mon Sep 17 00:00:00 2001 From: Ian Faust Date: Tue, 28 Jan 2025 07:10:05 +0100 Subject: [PATCH 12/15] Delete onedal/datatypes/dtype_dispatcher.hpp --- onedal/datatypes/dtype_dispatcher.hpp | 101 -------------------------- 1 file changed, 101 deletions(-) delete mode 100644 onedal/datatypes/dtype_dispatcher.hpp diff --git a/onedal/datatypes/dtype_dispatcher.hpp b/onedal/datatypes/dtype_dispatcher.hpp deleted file mode 100644 index d3d2b2e0f3..0000000000 --- a/onedal/datatypes/dtype_dispatcher.hpp +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* -* Copyright 2024 Intel Corporation -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*******************************************************************************/ - -#pragma once - -#include -#include - -#include "onedal/common.hpp" -#include "oneapi/dal/common.hpp" -#include "oneapi/dal/detail/common.hpp" - -// TODO: Using includes should be the primary path -#if defined(ONEDAL_VERSION) && (20240400 < ONEDAL_VERSION) - -#include "oneapi/dal/detail/dtype_dispatcher.hpp" - -#else // Version check - -#include "oneapi/dal/detail/error_messages.hpp" - -namespace oneapi::dal::detail { - -template -inline constexpr auto dispatch_by_data_type(data_type dtype, Op&& op, OnUnknown&& on_unknown) { - switch (dtype) { - case data_type::int8: return op(std::int8_t{}); - case data_type::uint8: return op(std::uint8_t{}); - case data_type::int16: return op(std::int16_t{}); - case data_type::uint16: return op(std::uint16_t{}); - case data_type::int32: return op(std::int32_t{}); - case data_type::uint32: return op(std::uint32_t{}); - case data_type::int64: return op(std::int64_t{}); - case data_type::uint64: return op(std::uint64_t{}); - case data_type::float32: return op(float{}); - case data_type::float64: return op(double{}); - default: return on_unknown(dtype); - } -} - -template > -inline constexpr ResultType dispatch_by_data_type(data_type dtype, Op&& op) { - // Necessary to make the return type conformant with - // other dispatch branches - const auto on_unknown = [](data_type) -> ResultType { - using msg = oneapi::dal::detail::error_messages; - throw unimplemented{ msg::unsupported_conversion_types() }; - }; - - return dispatch_by_data_type(dtype, std::forward(op), on_unknown); -} - -} // namespace oneapi::dal::detail - -#endif // Version check - -// TODO: Using includes should be the primary path -#if defined(ONEDAL_VERSION) && (ONEDAL_VERSION < 20240000) - -namespace oneapi::dal::detail { - -template -constexpr inline void apply(Op&& op) { - ((void)op(Types{}), ...); -} - -template -constexpr inline void apply(Op&& op, Args&&... args) { - ((void)op(std::forward(args)), ...); -} - -} //namespace oneapi::dal::detail - -#endif // Version check - -namespace oneapi::dal::python { - -using supported_types_t = std::tuple; -} // namespace oneapi::dal::python From 8d5e1a34bce080cbd6773a7a1c46e5ace624a36a Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Tue, 28 Jan 2025 07:12:43 +0100 Subject: [PATCH 13/15] Revert "Delete onedal/datatypes/dtype_dispatcher.hpp" This reverts commit bfc66b66b9f326bff2e24430fa24d7d9bcc30196. --- onedal/datatypes/dtype_dispatcher.hpp | 101 ++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 onedal/datatypes/dtype_dispatcher.hpp diff --git a/onedal/datatypes/dtype_dispatcher.hpp b/onedal/datatypes/dtype_dispatcher.hpp new file mode 100644 index 0000000000..d3d2b2e0f3 --- /dev/null +++ b/onedal/datatypes/dtype_dispatcher.hpp @@ -0,0 +1,101 @@ +/******************************************************************************* +* Copyright 2024 Intel Corporation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*******************************************************************************/ + +#pragma once + +#include +#include + +#include "onedal/common.hpp" +#include "oneapi/dal/common.hpp" +#include "oneapi/dal/detail/common.hpp" + +// TODO: Using includes should be the primary path +#if defined(ONEDAL_VERSION) && (20240400 < ONEDAL_VERSION) + +#include "oneapi/dal/detail/dtype_dispatcher.hpp" + +#else // Version check + +#include "oneapi/dal/detail/error_messages.hpp" + +namespace oneapi::dal::detail { + +template +inline constexpr auto dispatch_by_data_type(data_type dtype, Op&& op, OnUnknown&& on_unknown) { + switch (dtype) { + case data_type::int8: return op(std::int8_t{}); + case data_type::uint8: return op(std::uint8_t{}); + case data_type::int16: return op(std::int16_t{}); + case data_type::uint16: return op(std::uint16_t{}); + case data_type::int32: return op(std::int32_t{}); + case data_type::uint32: return op(std::uint32_t{}); + case data_type::int64: return op(std::int64_t{}); + case data_type::uint64: return op(std::uint64_t{}); + case data_type::float32: return op(float{}); + case data_type::float64: return op(double{}); + default: return on_unknown(dtype); + } +} + +template > +inline constexpr ResultType dispatch_by_data_type(data_type dtype, Op&& op) { + // Necessary to make the return type conformant with + // other dispatch branches + const auto on_unknown = [](data_type) -> ResultType { + using msg = oneapi::dal::detail::error_messages; + throw unimplemented{ msg::unsupported_conversion_types() }; + }; + + return dispatch_by_data_type(dtype, std::forward(op), on_unknown); +} + +} // namespace oneapi::dal::detail + +#endif // Version check + +// TODO: Using includes should be the primary path +#if defined(ONEDAL_VERSION) && (ONEDAL_VERSION < 20240000) + +namespace oneapi::dal::detail { + +template +constexpr inline void apply(Op&& op) { + ((void)op(Types{}), ...); +} + +template +constexpr inline void apply(Op&& op, Args&&... args) { + ((void)op(std::forward(args)), ...); +} + +} //namespace oneapi::dal::detail + +#endif // Version check + +namespace oneapi::dal::python { + +using supported_types_t = std::tuple; +} // namespace oneapi::dal::python From 0d5d36a22f961176806a1d77d0c4bc7a4a5f182b Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Tue, 28 Jan 2025 08:14:33 +0100 Subject: [PATCH 14/15] helper -> utils --- onedal/datatypes/numpy/data_conversion.cpp | 2 +- onedal/datatypes/numpy/{numpy_helpers.cpp => numpy_utils.cpp} | 2 +- onedal/datatypes/numpy/{numpy_helpers.hpp => numpy_utils.hpp} | 0 onedal/datatypes/sycl_usm/data_conversion.cpp | 2 +- .../sycl_usm/{sycl_usm_helpers.cpp => sycl_usm_utils.cpp} | 0 .../sycl_usm/{sycl_usm_helpers.hpp => sycl_usm_utils.hpp} | 0 onedal/datatypes/table.cpp | 2 +- 7 files changed, 4 insertions(+), 4 deletions(-) rename onedal/datatypes/numpy/{numpy_helpers.cpp => numpy_utils.cpp} (97%) rename onedal/datatypes/numpy/{numpy_helpers.hpp => numpy_utils.hpp} (100%) rename onedal/datatypes/sycl_usm/{sycl_usm_helpers.cpp => sycl_usm_utils.cpp} (100%) rename onedal/datatypes/sycl_usm/{sycl_usm_helpers.hpp => sycl_usm_utils.hpp} (100%) diff --git a/onedal/datatypes/numpy/data_conversion.cpp b/onedal/datatypes/numpy/data_conversion.cpp index 18a435ec94..9adfe5e3f7 100644 --- a/onedal/datatypes/numpy/data_conversion.cpp +++ b/onedal/datatypes/numpy/data_conversion.cpp @@ -23,7 +23,7 @@ #include "oneapi/dal/table/detail/homogen_utils.hpp" #include "onedal/datatypes/numpy/data_conversion.hpp" -#include "onedal/datatypes/numpy/numpy_helpers.hpp" +#include "onedal/datatypes/numpy/numpy_utils.hpp" #include "onedal/version.hpp" #if ONEDAL_VERSION <= 20230100 diff --git a/onedal/datatypes/numpy/numpy_helpers.cpp b/onedal/datatypes/numpy/numpy_utils.cpp similarity index 97% rename from onedal/datatypes/numpy/numpy_helpers.cpp rename to onedal/datatypes/numpy/numpy_utils.cpp index 7adacf7a09..6c531c9cfb 100644 --- a/onedal/datatypes/numpy/numpy_helpers.cpp +++ b/onedal/datatypes/numpy/numpy_utils.cpp @@ -14,7 +14,7 @@ * limitations under the License. *******************************************************************************/ -#include "onedal/datatypes/numpy/numpy_helpers.hpp" +#include "onedal/datatypes/numpy/numpy_utils.hpp" namespace oneapi::dal::python::numpy { diff --git a/onedal/datatypes/numpy/numpy_helpers.hpp b/onedal/datatypes/numpy/numpy_utils.hpp similarity index 100% rename from onedal/datatypes/numpy/numpy_helpers.hpp rename to onedal/datatypes/numpy/numpy_utils.hpp diff --git a/onedal/datatypes/sycl_usm/data_conversion.cpp b/onedal/datatypes/sycl_usm/data_conversion.cpp index 7876ac6f3e..93f5d0048f 100644 --- a/onedal/datatypes/sycl_usm/data_conversion.cpp +++ b/onedal/datatypes/sycl_usm/data_conversion.cpp @@ -29,7 +29,7 @@ #include "onedal/common/sycl_interfaces.hpp" #include "onedal/datatypes/sycl_usm/data_conversion.hpp" #include "onedal/datatypes/sycl_usm/dtype_conversion.hpp" -#include "onedal/datatypes/sycl_usm/sycl_usm_helpers.hpp" +#include "onedal/datatypes/sycl_usm/sycl_usm_utils.hpp" namespace oneapi::dal::python::sycl_usm { diff --git a/onedal/datatypes/sycl_usm/sycl_usm_helpers.cpp b/onedal/datatypes/sycl_usm/sycl_usm_utils.cpp similarity index 100% rename from onedal/datatypes/sycl_usm/sycl_usm_helpers.cpp rename to onedal/datatypes/sycl_usm/sycl_usm_utils.cpp diff --git a/onedal/datatypes/sycl_usm/sycl_usm_helpers.hpp b/onedal/datatypes/sycl_usm/sycl_usm_utils.hpp similarity index 100% rename from onedal/datatypes/sycl_usm/sycl_usm_helpers.hpp rename to onedal/datatypes/sycl_usm/sycl_usm_utils.hpp diff --git a/onedal/datatypes/table.cpp b/onedal/datatypes/table.cpp index 20e938783b..df0957ea5d 100644 --- a/onedal/datatypes/table.cpp +++ b/onedal/datatypes/table.cpp @@ -22,7 +22,7 @@ #endif // ONEDAL_DATA_PARALLEL #include "onedal/datatypes/numpy/data_conversion.hpp" -#include "onedal/datatypes/numpy/numpy_helpers.hpp" +#include "onedal/datatypes/numpy/numpy_utils.hpp" #include "onedal/common/pybind11_helpers.hpp" #include "onedal/version.hpp" From 91208ab970c2fd4e0f63c5afbc376ee5d10d0b6d Mon Sep 17 00:00:00 2001 From: "Faust, Ian" Date: Tue, 28 Jan 2025 08:43:36 +0100 Subject: [PATCH 15/15] move macro to a central spot --- onedal/datatypes/dtype_dispatcher.hpp | 21 ++++++++++++++++++ .../datatypes/sycl_usm/dtype_conversion.hpp | 22 +------------------ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/onedal/datatypes/dtype_dispatcher.hpp b/onedal/datatypes/dtype_dispatcher.hpp index d3d2b2e0f3..decbe66a66 100644 --- a/onedal/datatypes/dtype_dispatcher.hpp +++ b/onedal/datatypes/dtype_dispatcher.hpp @@ -86,6 +86,27 @@ constexpr inline void apply(Op&& op, Args&&... args) { #endif // Version check +#define SET_CTYPE_FROM_DAL_TYPE(_T, _FUNCT, _EXCEPTION) \ + switch (_T) { \ + case dal::data_type::float32: { \ + _FUNCT(float); \ + break; \ + } \ + case dal::data_type::float64: { \ + _FUNCT(double); \ + break; \ + } \ + case dal::data_type::int32: { \ + _FUNCT(std::int32_t); \ + break; \ + } \ + case dal::data_type::int64: { \ + _FUNCT(std::int64_t); \ + break; \ + } \ + default: _EXCEPTION; \ + }; + namespace oneapi::dal::python { using supported_types_t = std::tuple #include "oneapi/dal/common.hpp" +#include "onedal/datatypes/dtype_dispatcher.hpp" namespace py = pybind11; -#define SET_CTYPE_FROM_DAL_TYPE(_T, _FUNCT, _EXCEPTION) \ - switch (_T) { \ - case dal::data_type::float32: { \ - _FUNCT(float); \ - break; \ - } \ - case dal::data_type::float64: { \ - _FUNCT(double); \ - break; \ - } \ - case dal::data_type::int32: { \ - _FUNCT(std::int32_t); \ - break; \ - } \ - case dal::data_type::int64: { \ - _FUNCT(std::int64_t); \ - break; \ - } \ - default: _EXCEPTION; \ - }; - namespace oneapi::dal::python::sycl_usm { dal::data_type convert_sua_to_dal_type(std::string dtype);