Skip to content

Commit

Permalink
add string list parse
Browse files Browse the repository at this point in the history
  • Loading branch information
FindHao committed Nov 21, 2024
1 parent 3b88aab commit ba9692d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tritonbench/utils/triton_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,25 @@ def select_metric(backend, m):
)
metric_val = _metrics_dict.get(metric, None)
if isinstance(metric_val, list):
row.append(numpy.median(metric_val))
# Check if all elements are numbers before calculating median
if all(isinstance(x, Number) for x in metric_val):
row.append(numpy.median(metric_val))
else:
# For non-numeric lists, convert to string representation
metric_val_str = str(metric_val)
if ";" in metric_val_str:
logger.warning(
f"Metric value '{metric_val_str}' contains semicolon which may cause CSV parsing issues"
)
row.append(metric_val_str)
elif isinstance(metric_val, bool):
row.append(1.0 if metric_val else 0.0)
elif isinstance(metric_val, str):
if ";" in metric_val:
logger.warning(
f"Metric value '{metric_val}' contains semicolon which may cause CSV parsing issues"
)
row.append(metric_val)
else:
row.append(metric_val)
table.append(row)
Expand Down

0 comments on commit ba9692d

Please sign in to comment.