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

Fix the code that aligns returned data with the output schema #335

Merged
merged 1 commit into from
Apr 25, 2023
Merged
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
24 changes: 15 additions & 9 deletions merlin/systems/triton/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,23 @@ def match_representations(schema: Schema, dict_array: Dict[str, Any]) -> Dict[st
Dict[str, Any]
A dictionary of NumPy or CuPy ndarrays with representations adjusted
"""
schema_names = tensor_names(schema)

aligned = {}
for tensor_name in dict_array.keys():
if tensor_name in schema_names:
aligned[tensor_name] = dict_array[tensor_name]
for col_name, col_schema in schema.column_schemas.items():
if col_schema.is_ragged:
vals_name = f"{col_name}__values"
offs_name = f"{col_name}__offsets"

try:
# Look for values and offsets that already exist
aligned[vals_name] = dict_array[vals_name]
aligned[offs_name] = dict_array[offs_name]
except KeyError:
# If you don't find them, create the offsets
values, offsets = _to_values_offsets(dict_array[col_name])
aligned[vals_name] = values
aligned[offs_name] = offsets
else:
# Ragged columns with fixed shape values
values, offsets = _to_values_offsets(dict_array[tensor_name])
aligned[f"{tensor_name}__values"] = values
aligned[f"{tensor_name}__offsets"] = offsets
aligned[col_name] = dict_array[col_name]

return aligned

Expand Down