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

[mpact][benchmark] check output type #50

Merged
merged 3 commits into from
Jun 27, 2024
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
13 changes: 12 additions & 1 deletion benchmark/python/utils/benchmark_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@ def run_benchmark(
):
"""Run benchmark with specified backends."""
output = []
output_type = None

with torch.no_grad():
for backend in backends:
match backend:
case Backends.TORCH_SPARSE_EAGER:
output.append(torch_net(*sparse_inputs))
sparse_out = torch_net(*sparse_inputs)
output_type = sparse_out.layout
output.append(sparse_out)
runtime_results.append(
timer(
"torch_net(*sparse_inputs)",
Expand Down Expand Up @@ -133,8 +136,16 @@ def run_benchmark(
output.append(
torch.sparse_csr_tensor(*sp_out, size=dense_out.shape)
)
# Check MPACT and torch eager both return sparse csr output
# only when torch sparse eager has been run.
if output_type:
yinying-lisa-li marked this conversation as resolved.
Show resolved Hide resolved
assert output_type == torch.sparse_csr
else:
output.append(torch.from_numpy(sp_out))
# Check MPACT and torch eager both return dense output
# only when torch sparse eager has been run.
if output_type:
assert output_type == torch.strided
invoker, f = mpact_jit_compile(torch_net, *sparse_inputs)
compile_time_results.append(
timer(
Expand Down
Loading