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

Why is the performance of the mkl_conv in the torch test worse than that of the benchdnn test? #2672

Open
Serenagirl opened this issue Feb 12, 2025 · 1 comment
Assignees
Labels

Comments

@Serenagirl
Copy link

Serenagirl commented Feb 12, 2025

I tested aten::mkldnn_convolutioin in pytorch:

import torch
import torch.nn.functional as F
from torch.profiler import profile, record_function, ProfilerActivity

input_tensor = torch.randn(1, 64, 170, 256)  # [batch_size, in_channels, height, width]
weight_tensor = torch.randn(64, 64, 3, 3)    # [out_channels, in_channels, kernel_height, kernel_width]
bias_tensor = torch.randn(64)               # [out_channels]

stride = (1, 1)
padding = (1, 1)
dilation = (1, 1)
groups = 1

with profile(activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA], record_shapes=True) as prof:
    with record_function("aten::mkldnn_convolution"):
        output = F.conv2d(input_tensor, weight_tensor, bias_tensor, stride, padding, dilation, groups)
print(prof.key_averages().table(sort_by="self_cpu_time_total"))

and got time total:144ms,but I tested the same convolution in benchdnn:
OMP_NUM_THREADS=1 taskset -c 0 ./benchdnn --conv --mode=P --dt=f32 --dir=FWD_B --mb=1 ic64ih170iw256oc64oh168ow254kh3kw3sh1sw1dh1dw1ph1pw1

total perf: min(ms):349.276 avg(ms):349.385
total: 3.54s; fill: 0.05s (1%);

why the difference

@rupakroyintel
Copy link

rupakroyintel commented Feb 12, 2025

@Serenagirl Thanks for reaching out.
Can you share the following information:

  • oneDNN Verbose log for the PyTorch code execution?
  • Platform information
    Also, is there any particular reason for setting OMP_NUM_THREADS=1 for the benchdnn test?

Here are some best practices for Configuring oneDNN for Benchmarking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants