已合并
[fix]modify ut and hf_Bert model bug #37829
zzll创建于 6月8日
[fix]modify ut and hf_Bert model bug #37829
已合并
共 17 个文件变更+36-36
| @@ -27,8 +27,8 @@ class TestCastStandardPass(TestUtils): | |||
| 27 | std_result = self.op_calc(first_element) | 27 | std_result = self.op_calc(first_element) |
| 28 | with torch.no_grad(): | 28 | with torch.no_grad(): |
| 29 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 29 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 30 | - inductor_result = compiled_op_calc(first_element) | 30 | + inductor_result = compiled_op_calc(first_element) |
| 31 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 31 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | 34 | ||
| @@ -62,8 +62,8 @@ class TestCatSliceCatPass(TestUtils): | |||
| 62 | std_result = self.op_calc(first_element) | 62 | std_result = self.op_calc(first_element) |
| 63 | with torch.no_grad(): | 63 | with torch.no_grad(): |
| 64 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 64 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 65 | - inductor_result = compiled_op_calc(first_element) | 65 | + inductor_result = compiled_op_calc(first_element) |
| 66 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 66 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | 69 | ||
| @@ -29,8 +29,8 @@ class TestFoldAddPass(TestUtils): | |||
| 29 | std_result = self.op_calc(first_element) | 29 | std_result = self.op_calc(first_element) |
| 30 | with torch.no_grad(): | 30 | with torch.no_grad(): |
| 31 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 31 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 32 | - inductor_result = compiled_op_calc(first_element) | 32 | + inductor_result = compiled_op_calc(first_element) |
| 33 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 33 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | 36 | ||
| @@ -37,8 +37,8 @@ class TestFoldCatPass(TestUtils): | |||
| 37 | std_result = self.op_calc(t1, t2, t3, t4, t5) | 37 | std_result = self.op_calc(t1, t2, t3, t4, t5) |
| 38 | with torch.no_grad(): | 38 | with torch.no_grad(): |
| 39 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 39 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 40 | - inductor_result = compiled_op_calc(t1, t2, t3, t4, t5) | 40 | + inductor_result = compiled_op_calc(t1, t2, t3, t4, t5) |
| 41 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 41 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | 44 | ||
| @@ -29,8 +29,8 @@ class TestFoldClonePass(TestUtils): | |||
| 29 | std_result = self.op_calc(t1) | 29 | std_result = self.op_calc(t1) |
| 30 | with torch.no_grad(): | 30 | with torch.no_grad(): |
| 31 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 31 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 32 | - inductor_result = compiled_op_calc(t1) | 32 | + inductor_result = compiled_op_calc(t1) |
| 33 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 33 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | 36 | ||
| @@ -30,8 +30,8 @@ class TestFoldDetachPass(TestUtils): | |||
| 30 | std_result = self.op_calc(t1) | 30 | std_result = self.op_calc(t1) |
| 31 | with torch.no_grad(): | 31 | with torch.no_grad(): |
| 32 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 32 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 33 | - inductor_result = compiled_op_calc(t1) | 33 | + inductor_result = compiled_op_calc(t1) |
| 34 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 34 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | 37 | ||
| @@ -30,8 +30,8 @@ class TestFoldDivPass(TestUtils): | |||
| 30 | std_result = self.op_calc(t1) | 30 | std_result = self.op_calc(t1) |
| 31 | with torch.no_grad(): | 31 | with torch.no_grad(): |
| 32 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 32 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 33 | - inductor_result = compiled_op_calc(t1) | 33 | + inductor_result = compiled_op_calc(t1) |
| 34 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 34 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | 37 | ||
| @@ -30,8 +30,8 @@ class TestFoldExpandPass(TestUtils): | |||
| 30 | std_result = self.op_calc(t1) | 30 | std_result = self.op_calc(t1) |
| 31 | with torch.no_grad(): | 31 | with torch.no_grad(): |
| 32 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 32 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 33 | - inductor_result = compiled_op_calc(t1) | 33 | + inductor_result = compiled_op_calc(t1) |
| 34 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 34 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | 37 | ||
| @@ -30,8 +30,8 @@ class TestFoldMulPass(TestUtils): | |||
| 30 | std_result = self.op_calc(t1) | 30 | std_result = self.op_calc(t1) |
| 31 | with torch.no_grad(): | 31 | with torch.no_grad(): |
| 32 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 32 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 33 | - inductor_result = compiled_op_calc(t1) | 33 | + inductor_result = compiled_op_calc(t1) |
| 34 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 34 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | 37 | ||
| @@ -28,8 +28,8 @@ class TestFoldReducePass(TestUtils): | |||
| 28 | std_result = self.op_calc(t1) | 28 | std_result = self.op_calc(t1) |
| 29 | with torch.no_grad(): | 29 | with torch.no_grad(): |
| 30 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 30 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 31 | - inductor_result = compiled_op_calc(t1) | 31 | + inductor_result = compiled_op_calc(t1) |
| 32 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 32 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | 35 | ||
| @@ -29,8 +29,8 @@ class TestFoldSinkViewPass(TestUtils): | |||
| 29 | std_result = self.op_calc(t1) | 29 | std_result = self.op_calc(t1) |
| 30 | with torch.no_grad(): | 30 | with torch.no_grad(): |
| 31 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 31 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 32 | - inductor_result = compiled_op_calc(t1) | 32 | + inductor_result = compiled_op_calc(t1) |
| 33 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 33 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | 36 | ||
| @@ -33,8 +33,8 @@ class TestFoldSubPass(TestUtils): | |||
| 33 | std_result = self.op_calc(t1) | 33 | std_result = self.op_calc(t1) |
| 34 | with torch.no_grad(): | 34 | with torch.no_grad(): |
| 35 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 35 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 36 | - inductor_result = compiled_op_calc(t1) | 36 | + inductor_result = compiled_op_calc(t1) |
| 37 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 37 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | 40 | ||
| @@ -29,8 +29,8 @@ class TestFoldToCopyPass(TestUtils): | |||
| 29 | std_result = self.op_calc(t1) | 29 | std_result = self.op_calc(t1) |
| 30 | with torch.no_grad(): | 30 | with torch.no_grad(): |
| 31 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 31 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 32 | - inductor_result = compiled_op_calc(t1) | 32 | + inductor_result = compiled_op_calc(t1) |
| 33 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 33 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | 36 | ||
| @@ -27,8 +27,8 @@ class TestFoldWherePass(TestUtils): | |||
| 27 | std_result = self.op_calc(t1) | 27 | std_result = self.op_calc(t1) |
| 28 | with torch.no_grad(): | 28 | with torch.no_grad(): |
| 29 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 29 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 30 | - inductor_result = compiled_op_calc(t1) | 30 | + inductor_result = compiled_op_calc(t1) |
| 31 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 31 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | 34 | ||
| @@ -742,8 +742,8 @@ class TestMultiStreamPass(TestUtils): | |||
| 742 | std_result = self.multi_stream_test(arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1, arg9_1, arg10_1, arg11_1, arg12_1, arg13_1, arg14_1, arg15_1, arg16_1, arg17_1, arg18_1, arg19_1, arg20_1, arg21_1, arg22_1, arg23_1, arg24_1, arg25_1, arg26_1, arg27_1, arg28_1, arg29_1, arg30_1, arg31_1, arg32_1, arg33_1, arg34_1, arg35_1, arg36_1, arg37_1, arg38_1, arg39_1) | 742 | std_result = self.multi_stream_test(arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1, arg9_1, arg10_1, arg11_1, arg12_1, arg13_1, arg14_1, arg15_1, arg16_1, arg17_1, arg18_1, arg19_1, arg20_1, arg21_1, arg22_1, arg23_1, arg24_1, arg25_1, arg26_1, arg27_1, arg28_1, arg29_1, arg30_1, arg31_1, arg32_1, arg33_1, arg34_1, arg35_1, arg36_1, arg37_1, arg38_1, arg39_1) |
| 743 | with torch.no_grad(): | 743 | with torch.no_grad(): |
| 744 | compiled_op_calc = torch.compile(self.multi_stream_test, backend="inductor") | 744 | compiled_op_calc = torch.compile(self.multi_stream_test, backend="inductor") |
| 745 | - inductor_result = compiled_op_calc(arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1, arg9_1, arg10_1, arg11_1, arg12_1, arg13_1, arg14_1, arg15_1, arg16_1, arg17_1, arg18_1, arg19_1, arg20_1, arg21_1, arg22_1, arg23_1, arg24_1, arg25_1, arg26_1, arg27_1, arg28_1, arg29_1, arg30_1, arg31_1, arg32_1, arg33_1, arg34_1, arg35_1, arg36_1, arg37_1, arg38_1, arg39_1) | 745 | + inductor_result = compiled_op_calc(arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1, arg9_1, arg10_1, arg11_1, arg12_1, arg13_1, arg14_1, arg15_1, arg16_1, arg17_1, arg18_1, arg19_1, arg20_1, arg21_1, arg22_1, arg23_1, arg24_1, arg25_1, arg26_1, arg27_1, arg28_1, arg29_1, arg30_1, arg31_1, arg32_1, arg33_1, arg34_1, arg35_1, arg36_1, arg37_1, arg38_1, arg39_1) |
| 746 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 746 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 747 | 747 | ||
| 748 | def op_calc(self, arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1): | 748 | def op_calc(self, arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1): |
| 749 | relu_1 = torch.ops.aten.relu.default(arg0_1) | 749 | relu_1 = torch.ops.aten.relu.default(arg0_1) |
| @@ -781,8 +781,8 @@ class TestMultiStreamPass(TestUtils): | |||
| 781 | std_result = self.op_calc(arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1) | 781 | std_result = self.op_calc(arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1) |
| 782 | with torch.no_grad(): | 782 | with torch.no_grad(): |
| 783 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 783 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 784 | - inductor_result = compiled_op_calc(arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1) | 784 | + inductor_result = compiled_op_calc(arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1) |
| 785 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 785 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 786 | 786 | ||
| 787 | 787 | ||
| 788 | instantiate_parametrized_tests(TestMultiStreamPass) | 788 | instantiate_parametrized_tests(TestMultiStreamPass) |
| @@ -31,8 +31,8 @@ class TestFoldPadSlicePass(TestUtils): | |||
| 31 | std_result = self.op_calc(t1) | 31 | std_result = self.op_calc(t1) |
| 32 | with torch.no_grad(): | 32 | with torch.no_grad(): |
| 33 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 33 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 34 | - inductor_result = compiled_op_calc(t1) | 34 | + inductor_result = compiled_op_calc(t1) |
| 35 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 35 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | 38 | ||
| @@ -476,7 +476,7 @@ def fold_sink_view(graph: torch.fx.Graph) -> None: | |||
| 476 | name=node.name + "_replacement", | 476 | name=node.name + "_replacement", |
| 477 | ) | 477 | ) |
| 478 | propagate_fake_tensor( | 478 | propagate_fake_tensor( |
| 479 | - new_act_view, new_act, lambda fake: node.target(fake, node.args[1]) | 479 | + new_act_view, new_act, lambda fake: node.target(fake, view_shape) |
| 480 | ) | 480 | ) |
| 481 | user.replace_all_uses_with(new_act_view) | 481 | user.replace_all_uses_with(new_act_view) |
| 482 | graph.erase_node(user) | 482 | graph.erase_node(user) |
| @@ -540,7 +540,7 @@ def fold_sink_view(graph: torch.fx.Graph) -> None: | |||
| 540 | propagate_fake_tensor( | 540 | propagate_fake_tensor( |
| 541 | new_add_view, | 541 | new_add_view, |
| 542 | new_add, | 542 | new_add, |
| 543 | - lambda fake: node.target(fake, node.args[1]), | 543 | + lambda fake: node.target(fake, view_shape), |
| 544 | ) | 544 | ) |
| 545 | user.replace_all_uses_with(new_add_view) | 545 | user.replace_all_uses_with(new_add_view) |
| 546 | graph.erase_node(user) | 546 | graph.erase_node(user) |