Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Data management update to support SUA ifaces for Homogen OneDAL tables #2045

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions onedal/datatypes/_data_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
from daal4py.sklearn._utils import make2d
from onedal import _backend, _is_dpc_backend

from .._device_offload import dpctl_available, dpnp_available
from ..utils import _is_csr

try:
import dpctl
if dpctl_available:
import dpctl.tensor as dpt

dpctl_available = dpctl.__version__ >= "0.14"
except ImportError:
dpctl_available = False
if dpnp_available:
import dpnp


def _apply_and_pass(func, *args):
Expand All @@ -38,20 +37,39 @@ def _apply_and_pass(func, *args):
return tuple(map(func, args))


def from_table(*args):
return _apply_and_pass(_backend.from_table, *args)


def convert_one_to_table(arg):
if dpctl_available:
if isinstance(arg, dpt.usm_ndarray):
return _backend.dpctl_to_table(arg)
# TODO:
# add warnings if no dpc backend.
# TODO:
# sparse for sua data.
# TODO:
# update it for each of the datafrmae format.
# TODO:
# update func use with args and kwargs with _apply_and_pass.
def convert_one_from_table(table, sua_iface=None, xp=None):
# Currently only `__sycl_usm_array_interface__` protocol used to
# convert into dpnp/dpctl tensors.
if sua_iface:
return xp.asarray(table)
return _backend.from_table(table)


# TODO:
# add warnings if no dpc backend.
# TODO:
# sparse for sua data.
def convert_one_to_table(arg, sua_iface=None):
if sua_iface and _is_dpc_backend:
return _backend.sua_iface_to_table(arg)

if not _is_csr(arg):
arg = make2d(arg)
return _backend.to_table(arg)


def from_table(*args):
return _apply_and_pass(convert_one_from_table, *args)


def to_table(*args):
return _apply_and_pass(convert_one_to_table, *args)

Expand Down
2 changes: 1 addition & 1 deletion onedal/datatypes/data_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "oneapi/dal/table/detail/homogen_utils.hpp"

#include "onedal/datatypes/data_conversion.hpp"
#include "onedal/datatypes/numpy_helpers.hpp"
#include "onedal/datatypes/utils/numpy_helpers.hpp"
#include "onedal/version.hpp"

#if ONEDAL_VERSION <= 20230100
Expand Down
225 changes: 0 additions & 225 deletions onedal/datatypes/data_conversion_dpctl.cpp

This file was deleted.

Loading
Loading