Skip to content
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
34 changes: 18 additions & 16 deletions graph_net_bench/torch/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,29 +308,31 @@ def print_and_store_cmp(key, cmp_func, args, expected_out, compiled_out, **kwarg


def compare_correctness(expected_out, compiled_out, args):
eager_dtypes = [
(
str(x.dtype).replace("torch.", "")
if isinstance(x, torch.Tensor)
else type(x).__name__
)
for x in expected_out
]
compiled_dtypes = [
(
str(x.dtype).replace("torch.", "")
if isinstance(x, torch.Tensor)
else type(x).__name__
)
for x in compiled_out
]
def _get_output_dtypes(outs):
return [
(
str(x.dtype).replace("torch.", "")
if isinstance(x, torch.Tensor)
else type(x).__name__
)
for x in outs
]

def _align_output_device(outs, device):
return [x.to(device) if x.device != device else x for x in outs]

eager_dtypes = _get_output_dtypes(expected_out)
compiled_dtypes = _get_output_dtypes(compiled_out)

# datatype check
type_match = test_compiler_util.check_output_datatype(
args, eager_dtypes, compiled_dtypes
)

if type_match:
expected_out = _align_output_device(expected_out, args.device)
compiled_out = _align_output_device(compiled_out, args.device)

test_compiler_util.check_equal(
args,
expected_out,
Expand Down
Loading