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

Incorporate supported_formats property into NVT ops #1799

Merged
merged 4 commits into from
May 23, 2023
Merged
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
5 changes: 5 additions & 0 deletions cpp/nvtabular/inference/categorify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ namespace nvtabular
{
py::object supports = py::module_::import("nvtabular").attr("graph").attr("base_operator").attr("Supports");
return supports.attr("CPU_DICT_ARRAY");
})
.def_property_readonly("supported_formats", [](py::object self)
{
py::object supported = py::module_::import("nvtabular").attr("graph").attr("base_operator").attr("DataFormats");
return supported.attr("NUMPY_DICT_ARRAY");
});
}
} // namespace inference
Expand Down
5 changes: 5 additions & 0 deletions cpp/nvtabular/inference/fill.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ namespace nvtabular
py::object supports = py::module_::import("nvtabular").attr("graph").attr("base_operator").attr("Supports");
return supports.attr("CPU_DICT_ARRAY");
})
.def_property_readonly("supported_formats", [](py::object self)
{
py::object supported = py::module_::import("nvtabular").attr("graph").attr("base_operator").attr("DataFormats");
return supported.attr("NUMPY_DICT_ARRAY");
})
.def("transform", &FillTransform::transform);
}
} // namespace inference
Expand Down
20 changes: 19 additions & 1 deletion nvtabular/ops/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
flatten_list_column_values,
is_list_dtype,
)
from merlin.dag import Supports
from merlin.dag import DataFormats, Supports
from merlin.schema import Tags
from nvtabular.ops.moments import _custom_moments
from nvtabular.ops.operator import ColumnSelector, Operator
Expand Down Expand Up @@ -98,6 +98,15 @@ def supports(self):
| Supports.GPU_DATAFRAME
)

@property
def supported_formats(self):
return (
DataFormats.PANDAS_DATAFRAME
| DataFormats.CUDF_DATAFRAME
| DataFormats.NUMPY_DICT_ARRAY
| DataFormats.CUPY_DICT_ARRAY
)

def clear(self):
self.means = {}
self.stds = {}
Expand Down Expand Up @@ -181,6 +190,15 @@ def supports(self):
| Supports.GPU_DATAFRAME
)

@property
def supported_formats(self):
return (
DataFormats.PANDAS_DATAFRAME
| DataFormats.CUDF_DATAFRAME
| DataFormats.NUMPY_DICT_ARRAY
| DataFormats.CUPY_DICT_ARRAY
)

@property
def output_tags(self):
return [Tags.CONTINUOUS]
Expand Down
6 changes: 5 additions & 1 deletion nvtabular/ops/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import nvtabular as nvt
from merlin.core.dispatch import DataFrameType
from merlin.dag import BaseOperator, ColumnSelector
from merlin.dag import BaseOperator, ColumnSelector, DataFormats


class Operator(BaseOperator):
Expand Down Expand Up @@ -53,3 +53,7 @@ def inference_initialize(

def create_node(self, selector):
return nvt.workflow.node.WorkflowNode(selector)

@property
def supported_formats(self) -> DataFormats:
return DataFormats.PANDAS_DATAFRAME | DataFormats.CUDF_DATAFRAME