8000 [Intel GPU] Enable mkdnn._linear_pointwise at XPU backend by ZhiweiYan-96 · Pull Request #140365 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[Intel GPU] Enable mkdnn._linear_pointwise at XPU backend #140365

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

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update
[ghstack-poisoned]
  • Loading branch information
ZhiweiYan-96 committed Nov 25, 2024
commit 8b87482bd90a798418e71a00500b23a03347ea9b
17 changes: 1 addition & 16 deletions aten/src/ATen/native/mkldnn/xpu/Linear.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@ struct LinearConverter {
is_fused_ = false;
}

// linear with post-ops
template <typename Func>
Tensor& call(
Tensor& result,
const Tensor& input,
const Tensor& weight,
const c10::optional<Tensor>& bias,
Func func) {
onednn::Attr attr = func();
Tensor _bias = bias.has_value() ? bias.value() : at::Tensor();
Tensor _input = input.dim() <= 2 ? input : input.contiguous();
return impl::matmul_fusion_variants(
result, _input, weight, false, attr, is_fused_, _bias);
}

Tensor& call(
Tensor& result,
const Tensor& input,
Expand All @@ -32,7 +17,7 @@ struct LinearConverter {
Tensor _bias = bias.has_value() ? bias.value() : at::Tensor();
Tensor _input = input.dim() <= 2 ? input : input.contiguous();
return impl::matmul_fusion_variants(
result, _input, weight, /*trans*/ true, attr, is_fused_, _bias);
result, _input, weight, /*trans*/ false, attr, is_fused_, _bias);
}

bool is_fused() {
Expand Down
4 changes: 2 additions & 2 deletions test/xpu/test_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def forward(self, x):
algorithm = pointwise_info.algorithm
fused = torch.ops.mkldnn._linear_pointwise(
v,
mod.linear.weight.transpose(1, 0),
mod.linear.weight,
mod.linear.bias,
attr,
scalars,
Expand Down Expand Up @@ -116,7 +116,7 @@ def forward(self, x, other):
fused = torch.ops.mkldnn._linear_pointwise(
input,
other,
model.linear.weight.transpose(1, 0),
model.linear.weight,
model.linear.bias,
attr,
)
Expand Down
Loading
0