Skip to content

Commit

Permalink
[inductor][cpu]disable pointwise_cat on CPU (pytorch#116313)
Browse files Browse the repository at this point in the history
We observed negative performance impact of pointwise_cat optimization on CPU so disabled it. We will revisit this later after enabling vectorization on index_expr.

This PR fix the following three regression issues:
pytorch#115827
pytorch#112139
pytorch#114495

and cause performance regression of pytorch_unet again. Related issue: pytorch#115343

Pull Request resolved: pytorch#116313
Approved by: https://github.com/jgong5, https://github.com/leslie-fang-intel, https://github.com/eellison
  • Loading branch information
jiayisunx authored and pytorchmergebot committed Jan 11, 2024
1 parent e3d4f4d commit 9f57cf5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/inductor/test_cpu_repro.py
Original file line number Diff line number Diff line change
Expand Up @@ -2708,7 +2708,7 @@ def fn(x, y):
y = torch.randn(32, 120)
metrics.reset()
self.common(fn, (x, y))
assert metrics.generated_cpp_vec_kernel_count == 1
assert metrics.generated_cpp_vec_kernel_count == 3

def test_expr_vec_non_contiguous(self):
def fn(x):
Expand Down
7 changes: 6 additions & 1 deletion torch/_inductor/lowering.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,12 @@ def should_lower_cat_input(x) -> bool:

return False

if len(inputs) <= config.max_pointwise_cat_inputs:
# TODO: We observed negative performance impact of pointwise_cat optimization on CPU so disabled it.
# We will revisit this later after enabling vectorization on index_expr.
if (
len(inputs) <= config.max_pointwise_cat_inputs
and inputs[0].get_device().type != "cpu"
):
pointwise_uses = all(is_pointwise_use(use) for use in V.current_node.users)
all_pointwise_inputs = all(should_lower_cat_input(inp) for inp in inputs)
any_pointwise_inputs = any(should_lower_cat_input(inp) for inp in inputs)
Expand Down

0 comments on commit 9f57cf5

Please sign in to comment.