Skip to content

Commit 8689650

Browse files
committed
Fix response convertion
1 parent 70227be commit 8689650

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

dpbench/infrastructure/benchmark.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,25 @@ def warmup(impl_fn, inputs):
169169
# Special case: if the benchmark implementation returns anything, then
170170
# add that to the results dict
171171
if retval is not None:
172-
results_dict["return-value"] = retval
172+
results_dict["return-value"] = convert_to_numpy(retval, fmwrk)
173173

174174
results_dict["error_state"] = ErrorCodes.SUCCESS
175175
results_dict["error_msg"] = ""
176176

177177

178+
def convert_to_numpy(value: any, fmwrk: Framework) -> any:
179+
"""Calls copy_from_func on all array values."""
180+
if isinstance(value, tuple):
181+
retval_list = list(value)
182+
for i, _ in enumerate(retval_list):
183+
retval_list[i] = fmwrk.copy_from_func()(retval_list[i])
184+
value = tuple(retval_list)
185+
else:
186+
value = fmwrk.copy_from_func()(value)
187+
188+
return value
189+
190+
178191
class BenchmarkResults:
179192
"""A helper class to store the results and timing from running a
180193
benchmark.

0 commit comments

Comments
 (0)