已合并
【inductor】fix inductor ci bug #30175
kkjocker创建于 1月29日
【inductor】fix inductor ci bug #30175
已合并
共 9 个文件变更+9-19
| @@ -1,11 +1,9 @@ | |||
| 1 | -import unittest | ||
| 2 | import torch | 1 | import torch |
| 3 | from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests | 2 | from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests |
| 4 | from testutils import TestUtils | 3 | from testutils import TestUtils |
| 5 | import torch_npu | 4 | import torch_npu |
| 6 | 5 | ||
| 7 | 6 | ||
| 8 | - | ||
| 9 | class TestAttnCp(TestUtils): | 7 | class TestAttnCp(TestUtils): |
| 10 | shape = (8, 8, 256, 128) | 8 | shape = (8, 8, 256, 128) |
| 11 | dim = -1 | 9 | dim = -1 |
| @@ -1,11 +1,9 @@ | |||
| 1 | -import unittest | ||
| 2 | import torch | 1 | import torch |
| 3 | from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests | 2 | from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests |
| 4 | from testutils import TestUtils | 3 | from testutils import TestUtils |
| 5 | import torch_npu | 4 | import torch_npu |
| 6 | 5 | ||
| 7 | 6 | ||
| 8 | - | ||
| 9 | class TestNativeBatchNorm(TestUtils): | 7 | class TestNativeBatchNorm(TestUtils): |
| 10 | def op_calc(self, input_element): | 8 | def op_calc(self, input_element): |
| 11 | # 创建权重和偏置张量 | 9 | # 创建权重和偏置张量 |
| @@ -1,4 +1,3 @@ | |||
| 1 | -from unittest import skip | ||
| 2 | import torch | 1 | import torch |
| 3 | from torch.testing._internal.common_utils import run_tests | 2 | from torch.testing._internal.common_utils import run_tests |
| 4 | from testutils import TestUtils | 3 | from testutils import TestUtils |
| @@ -20,7 +19,6 @@ class Test_issue59(TestUtils): | |||
| 20 | mean_2 = rsqrt / torch.numel(rsqrt) | 19 | mean_2 = rsqrt / torch.numel(rsqrt) |
| 21 | return mul, add, mean_2 | 20 | return mul, add, mean_2 |
| 22 | 21 | ||
| 23 | - | ||
| 24 | def test_issue59(self): | 22 | def test_issue59(self): |
| 25 | device = 'npu' | 23 | device = 'npu' |
| 26 | x = torch.randn((1, 1024), device=device, dtype=torch.float32) | 24 | x = torch.randn((1, 1024), device=device, dtype=torch.float32) |
| @@ -1,4 +1,3 @@ | |||
| 1 | -import unittest | ||
| 2 | import torch | 1 | import torch |
| 3 | from torch_npu.npu import device_count | 2 | from torch_npu.npu import device_count |
| 4 | from torch_npu.utils._dynamo_device import NpuInterface, current_device, set_device | 3 | from torch_npu.utils._dynamo_device import NpuInterface, current_device, set_device |
| @@ -8,7 +7,6 @@ from torch_npu._inductor.npu_device import NewNPUDeviceOpOverrides | |||
| 8 | from torch_npu.testing.testcase import TestCase, run_tests | 7 | from torch_npu.testing.testcase import TestCase, run_tests |
| 9 | 8 | ||
| 10 | 9 | ||
| 11 | - | ||
| 12 | class TestNpuDevice(TestCase): | 10 | class TestNpuDevice(TestCase): |
| 13 | def test_aoti_get_stream(self): | 11 | def test_aoti_get_stream(self): |
| 14 | overrides = NewNPUDeviceOpOverrides() | 12 | overrides = NewNPUDeviceOpOverrides() |
| @@ -1,11 +1,9 @@ | |||
| 1 | -import unittest | ||
| 2 | import torch | 1 | import torch |
| 3 | from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests | 2 | from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests |
| 4 | from testutils import TestUtils | 3 | from testutils import TestUtils |
| 5 | import torch_npu | 4 | import torch_npu |
| 6 | 5 | ||
| 7 | 6 | ||
| 8 | - | ||
| 9 | class TestSumAdd(TestUtils): | 7 | class TestSumAdd(TestUtils): |
| 10 | def foo(self, a, b, dim, shape): | 8 | def foo(self, a, b, dim, shape): |
| 11 | y = a + b | 9 | y = a + b |
| @@ -1,11 +1,9 @@ | |||
| 1 | -import unittest | ||
| 2 | import torch | 1 | import torch |
| 3 | from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests | 2 | from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests |
| 4 | from testutils import TestUtils | 3 | from testutils import TestUtils |
| 5 | import torch_npu | 4 | import torch_npu |
| 6 | 5 | ||
| 7 | 6 | ||
| 8 | - | ||
| 9 | class TestRenorm(TestUtils): | 7 | class TestRenorm(TestUtils): |
| 10 | def op_calc(self, input_element, dim): | 8 | def op_calc(self, input_element, dim): |
| 11 | return torch.renorm(input_element, p=2, dim=dim, maxnorm=5) | 9 | return torch.renorm(input_element, p=2, dim=dim, maxnorm=5) |
| @@ -1,4 +1,3 @@ | |||
| 1 | -from unittest import skip | ||
| 2 | import torch | 1 | import torch |
| 3 | from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests | 2 | from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests |
| 4 | from testutils import TestUtils | 3 | from testutils import TestUtils |
| @@ -10,7 +9,6 @@ class TestVarMean(TestUtils): | |||
| 10 | return torch.var_mean(input_element, dim) | 9 | return torch.var_mean(input_element, dim) |
| 11 | 10 | ||
| 12 | # case:The shape must not be too large | 11 | # case:The shape must not be too large |
| 13 | - | ||
| 14 | 12 | ||
| 15 | 13 | ||
| 16 | 14 | ||
| @@ -166,12 +166,13 @@ def substituted_dims_in_indexing(self, indexing, kernel, range_tree_nodes_substi | |||
| 166 | return substituted | 166 | return substituted |
| 167 | 167 | ||
| 168 | 168 | ||
| 169 | -def generate_body_indexing(body, indices): | 169 | +def generate_body_indexing(body, indices, allow_same_symbol_in_index=False): |
| 170 | index = list(itertools.chain.from_iterable(indices)) | 170 | index = list(itertools.chain.from_iterable(indices)) |
| 171 | if not (len(index) == len(body.var_ranges)): | 171 | if not (len(index) == len(body.var_ranges)): |
| 172 | raise RuntimeError("assert len(index) == len(body.var_ranges), (index, body.var_ranges)") | 172 | raise RuntimeError("assert len(index) == len(body.var_ranges), (index, body.var_ranges)") |
| 173 | - if not (all(v not in body.var_ranges for v in index)): | 173 | + if not allow_same_symbol_in_index: |
| 174 | - raise RuntimeError("assert all(v not in body.var_ranges for v in index)") | 174 | + if not (all(v not in body.var_ranges for v in index)): |
| 175 | + raise RuntimeError("assert all(v not in body.var_ranges for v in index)") | ||
| 175 | 176 | ||
| 176 | replacements = dict(zip(body.var_ranges.keys(), index)) | 177 | replacements = dict(zip(body.var_ranges.keys(), index)) |
| 177 | indexing_map = dict(zip(index, body.var_ranges.keys())) | 178 | indexing_map = dict(zip(index, body.var_ranges.keys())) |
| @@ -193,7 +194,7 @@ def transform_dims_in_indexing(self, indices): | |||
| 193 | # select tiling axis, recover missing dimensions, | 194 | # select tiling axis, recover missing dimensions, |
| 194 | def loopbody__call__(self, *indices, allow_same_symbol_in_index=False): | 195 | def loopbody__call__(self, *indices, allow_same_symbol_in_index=False): |
| 195 | if self.indexing is None: | 196 | if self.indexing is None: |
| 196 | - generate_body_indexing(self, indices) | 197 | + generate_body_indexing(self, indices, allow_same_symbol_in_index) |
| 197 | result = self.root_block() | 198 | result = self.root_block() |
| 198 | self.indexing = None | 199 | self.indexing = None |
| 199 | return result | 200 | return result |
| @@ -1185,7 +1185,10 @@ class NPUIndexTritonKernel(TritonKernel): | |||
| 1185 | ) -> Union[CSEVariable, Tuple[CSEVariable, ...]]: | 1185 | ) -> Union[CSEVariable, Tuple[CSEVariable, ...]]: |
| 1186 | if not self.inside_reduction: | 1186 | if not self.inside_reduction: |
| 1187 | raise RuntimeError("assert self.inside_reduction") | 1187 | raise RuntimeError("assert self.inside_reduction") |
| 1188 | - masks = {f"{node.symbol()}_mask" for node in self.sorted_axis} | 1188 | + if self.persistent_reduction and self.numof_reduction_axis() == 1: |
| 1189 | + masks = {f"{node.symbol()}_mask" for node in self.sorted_axis if node.name[0] != "r"} | ||
| 1190 | + else: | ||
| 1191 | + masks = {f"{node.symbol()}_mask" for node in self.sorted_axis} | ||
| 1189 | self.filter_masks(masks) | 1192 | self.filter_masks(masks) |
| 1190 | masks = sorted(masks) | 1193 | masks = sorted(masks) |
| 1191 | if self._load_mask: | 1194 | if self._load_mask: |