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

Add an unsafe mode to TensorTable/TensorColumn (for internal use) #258

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions merlin/table/tensor_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ def __new__(cls, values, *args, offsets=None, **kwargs):
else:
return object.__new__(cls)

def __init__(self, values: Any, offsets: Any = None, dtype=None, _ref=None, _device=None):
self._validate_values_offsets(values, offsets)
def __init__(
self, values: Any, offsets: Any = None, dtype=None, _ref=None, _device=None, _unsafe=False
):
if not _unsafe:
self._validate_values_offsets(values, offsets)

self._values = values
self._offsets = offsets
Expand Down
5 changes: 3 additions & 2 deletions merlin/table/tensor_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ class TensorTable:
def from_df(cls, df):
return tensor_table_from_df(df)

def __init__(self, columns: TensorDict = None):
def __init__(self, columns: TensorDict = None, _unsafe=False):
cols_dict = self._convert_arrays_to_columns(columns)

self._validate_columns(cols_dict)
if not _unsafe:
self._validate_columns(cols_dict)

self._columns = cols_dict

Expand Down