Skip to content

Commit 584f689

Browse files
authored
fix UTs and revert batch norm override (#4987) (#5000)
1 parent 2175cbf commit 584f689

File tree

3 files changed

+2
-102
lines changed

3 files changed

+2
-102
lines changed

csrc/gpu/aten/operators/BatchNorm.cpp

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -5208,90 +5208,6 @@ std::tuple<Tensor, Tensor, Tensor, Tensor> batch_norm_backward_reduce(
52085208
grad_output, input, mean, invstd, weight_opt, input_g, weight_g, bias_g);
52095209
}
52105210

5211-
#ifdef USE_OVERRIDE_OP
5212-
// Rename below functions because they have overload with the same name
5213-
// and can't be registered.
5214-
std::tuple<Tensor, Tensor, Tensor> _native_batch_norm_legit_(
5215-
const Tensor& self,
5216-
const c10::optional<Tensor>& weight_opt,
5217-
const c10::optional<Tensor>& bias_opt,
5218-
Tensor& running_mean,
5219-
Tensor& running_var,
5220-
bool train,
5221-
double momentum,
5222-
double epsilon) {
5223-
return at::AtenIpexTypeXPU::_native_batch_norm_legit(
5224-
self,
5225-
weight_opt,
5226-
bias_opt,
5227-
running_mean,
5228-
running_var,
5229-
train,
5230-
momentum,
5231-
epsilon);
5232-
}
5233-
5234-
std::tuple<Tensor, Tensor, Tensor> _native_batch_norm_legit_no_state(
5235-
const Tensor& self,
5236-
const c10::optional<Tensor>& weight_opt,
5237-
const c10::optional<Tensor>& bias_opt,
5238-
bool train,
5239-
double momentum,
5240-
double epsilon) {
5241-
return at::AtenIpexTypeXPU::_native_batch_norm_legit(
5242-
self, weight_opt, bias_opt, train, momentum, epsilon);
5243-
}
5244-
5245-
std::tuple<Tensor&, Tensor&, Tensor&> _native_batch_norm_legit_out_(
5246-
const Tensor& self,
5247-
const c10::optional<Tensor>& weight_opt,
5248-
const c10::optional<Tensor>& bias_opt,
5249-
Tensor& running_mean,
5250-
Tensor& running_var,
5251-
bool train,
5252-
double momentum,
5253-
double epsilon,
5254-
Tensor& output,
5255-
Tensor& save_mean,
5256-
Tensor& save_invstd) {
5257-
return at::AtenIpexTypeXPU::_native_batch_norm_legit_out(
5258-
self,
5259-
weight_opt,
5260-
bias_opt,
5261-
running_mean,
5262-
running_var,
5263-
train,
5264-
momentum,
5265-
epsilon,
5266-
output,
5267-
save_mean,
5268-
save_invstd);
5269-
}
5270-
5271-
std::tuple<Tensor&, Tensor&, Tensor&> _native_batch_norm_legit_no_state_out(
5272-
const Tensor& self,
5273-
const c10::optional<Tensor>& weight_opt,
5274-
const c10::optional<Tensor>& bias_opt,
5275-
bool train,
5276-
double momentum,
5277-
double epsilon,
5278-
Tensor& output,
5279-
Tensor& save_mean,
5280-
Tensor& save_invstd) {
5281-
return at::AtenIpexTypeXPU::_native_batch_norm_legit_out(
5282-
self,
5283-
weight_opt,
5284-
bias_opt,
5285-
train,
5286-
momentum,
5287-
epsilon,
5288-
output,
5289-
save_mean,
5290-
save_invstd);
5291-
}
5292-
5293-
#endif
5294-
52955211
} // namespace AtenIpexTypeXPU
52965212
} // namespace at
52975213

@@ -5307,18 +5223,6 @@ IPEX_TORCH_LIBRARY_IMPL(aten, XPU, m) {
53075223
m.impl(
53085224
"native_batch_norm_backward",
53095225
TORCH_FN((&at::AtenIpexTypeXPU::native_batch_norm_backward)));
5310-
m.impl(
5311-
"_native_batch_norm_legit",
5312-
TORCH_FN((&at::AtenIpexTypeXPU::_native_batch_norm_legit_)));
5313-
m.impl(
5314-
"_native_batch_norm_legit.out",
5315-
TORCH_FN((&at::AtenIpexTypeXPU::_native_batch_norm_legit_out_)));
5316-
m.impl(
5317-
"_native_batch_norm_legit.no_stats",
5318-
TORCH_FN((&at::AtenIpexTypeXPU::_native_batch_norm_legit_no_state)));
5319-
m.impl(
5320-
"_native_batch_norm_legit.no_stats_out",
5321-
TORCH_FN((&at::AtenIpexTypeXPU::_native_batch_norm_legit_no_state_out)));
53225226
}
53235227

53245228
} // namespace

scripts/tools/torchgen/yaml/xpu_functions.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ supported:
2020
# - im2col.out
2121
# - _embedding_bag
2222
# - _embedding_bag_forward_only
23-
# - _native_batch_norm_legit
24-
# - _native_batch_norm_legit.out
25-
# - _native_batch_norm_legit.no_stats
26-
# - _native_batch_norm_legit.no_stats_out
2723
# - glu_backward
2824
# - glu_backward.grad_input
2925
# - index_select

tests/gpu/examples/test_batch_norm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,8 @@ def test_batch_norm_update_stats_simple(self):
574574
def test_batch_norm_legit_simple(self):
575575
input_cpu = torch.randn(1, 2, 3, 3, dtype=torch.float, device=cpu_device)
576576
n_input = input_cpu.size(1)
577-
weight_cpu = torch.randn(1, 2, 3, 3, dtype=torch.float, device=cpu_device)
578-
bias_cpu = torch.randn(1, 2, 3, 3, dtype=torch.float, device=cpu_device)
577+
weight_cpu = torch.randn(2, dtype=torch.float, device=cpu_device)
578+
bias_cpu = torch.randn(2, dtype=torch.float, device=cpu_device)
579579
train = True
580580
momentum = 0.1
581581
epsilon = 1e-5

0 commit comments

Comments
 (0)