已合并
修改图优化用例及说明文档 #39031
zzll创建于 6月23日
修改图优化用例及说明文档 #39031
已合并
共 5 个文件变更+18-17
| @@ -59,10 +59,10 @@ class TestFoldMultiShapeUnchangePass(TestUtils): | |||
| 59 | std_result = self.op_calc(arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1) | 59 | std_result = self.op_calc(arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1) |
| 60 | with torch.no_grad(): | 60 | with torch.no_grad(): |
| 61 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 61 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 62 | - inductor_result = compiled_op_calc(arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1) | 62 | + inductor_result = compiled_op_calc(arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1) |
| 63 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 63 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 64 | - | 64 | + |
| 65 | - | 65 | + |
| 66 | def test_ut_cases(self): | 66 | def test_ut_cases(self): |
| 67 | arg0_1 = torch.randn(289094, 64, dtype=torch.float32) | 67 | arg0_1 = torch.randn(289094, 64, dtype=torch.float32) |
| 68 | arg1_1 = torch.randint(0, 289094, (128,), dtype=torch.int64) | 68 | arg1_1 = torch.randint(0, 289094, (128,), dtype=torch.int64) |
| @@ -41,10 +41,10 @@ class TestFoldSlicePass(TestUtils): | |||
| 41 | std_result = self.op_calc(base, view, t1, t2, t3) | 41 | std_result = self.op_calc(base, view, t1, t2, t3) |
| 42 | with torch.no_grad(): | 42 | with torch.no_grad(): |
| 43 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 43 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 44 | - inductor_result = compiled_op_calc(base, view, t1, t2, t3) | 44 | + inductor_result = compiled_op_calc(base, view, t1, t2, t3) |
| 45 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 45 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 46 | - | 46 | + |
| 47 | - | 47 | + |
| 48 | def test_ut_cases(self): | 48 | def test_ut_cases(self): |
| 49 | base = torch.randn(8, 16, 32) | 49 | base = torch.randn(8, 16, 32) |
| 50 | view = torch.ones(8, 16, 32) | 50 | view = torch.ones(8, 16, 32) |
| @@ -34,10 +34,10 @@ class TestFoldSqueezePass(TestUtils): | |||
| 34 | std_result = self.op_calc(t1, t2) | 34 | std_result = self.op_calc(t1, t2) |
| 35 | with torch.no_grad(): | 35 | with torch.no_grad(): |
| 36 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 36 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 37 | - inductor_result = compiled_op_calc(t1, t2) | 37 | + inductor_result = compiled_op_calc(t1, t2) |
| 38 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 38 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 39 | - | 39 | + |
| 40 | - | 40 | + |
| 41 | def test_ut_cases(self): | 41 | def test_ut_cases(self): |
| 42 | t1 = torch.randn(2, 4) | 42 | t1 = torch.randn(2, 4) |
| 43 | t2 = torch.randn(2, 1, 1, 4) | 43 | t2 = torch.randn(2, 1, 1, 4) |
| @@ -34,10 +34,10 @@ class TestFoldViewPass(TestUtils): | |||
| 34 | std_result = self.op_calc(t1, t2) | 34 | std_result = self.op_calc(t1, t2) |
| 35 | with torch.no_grad(): | 35 | with torch.no_grad(): |
| 36 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") | 36 | compiled_op_calc = torch.compile(self.op_calc, backend="inductor") |
| 37 | - inductor_result = compiled_op_calc(t1, t2) | 37 | + inductor_result = compiled_op_calc(t1, t2) |
| 38 | - self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) | 38 | + self.assertEqual(std_result, inductor_result, atol=1e-3, rtol=1e-3) |
| 39 | - | 39 | + |
| 40 | - | 40 | + |
| 41 | def test_ut_cases(self): | 41 | def test_ut_cases(self): |
| 42 | t1 = torch.randn(1, 3, 1, 5) | 42 | t1 = torch.randn(1, 3, 1, 5) |
| 43 | t2 = torch.randn(128, 64) | 43 | t2 = torch.randn(128, 64) |
| @@ -12,6 +12,7 @@ | |||
| 12 | # pre | 12 | # pre |
| 13 | cat_slice_cat_fold_pass | 13 | cat_slice_cat_fold_pass |
| 14 | pad_slice_fold | 14 | pad_slice_fold |
| 15 | +fusion_attention_v3_pass | ||
| 15 | ``` | 16 | ``` |
| 16 | 17 | ||
| 17 | ```text | 18 | ```text |
| @@ -80,7 +81,7 @@ with torch.no_grad(): | |||
| 80 | ```python | 81 | ```python |
| 81 | # 设置 inductor 日志级别以便观察 pass 生效情况 | 82 | # 设置 inductor 日志级别以便观察 pass 生效情况 |
| 82 | import os | 83 | import os |
| 83 | -os.environ["INDUCTOR_ASCEND_LOG_LEVEL"] = "INFO" | 84 | +os.environ["INDUCTOR_ASCEND_LOG_LEVEL"] = "DEBUG" |
| 84 | import torch | 85 | import torch |
| 85 | ``` | 86 | ``` |
| 86 | 87 | ||