已合并
[fix] fix UT about functionalization #35901
culechan创建于 5月18日
[fix] fix UT about functionalization #35901
已合并
共 1 个文件变更+5-13
| @@ -99,7 +99,6 @@ class TestFunctionalization(TestCase): | |||
| 99 | self.assertEqual(out_ref_, out_functional_) | 99 | self.assertEqual(out_ref_, out_functional_) |
| 100 | self.assertEqual(out_ref_, out_reinplace_) | 100 | self.assertEqual(out_ref_, out_reinplace_) |
| 101 | 101 | ||
| 102 | - | ||
| 103 | def test_scatter_update(self): | 102 | def test_scatter_update(self): |
| 104 | def f(iself, indices, updates): | 103 | def f(iself, indices, updates): |
| 105 | return torch.ops.npu.scatter_update_(iself, indices, updates, -2) | 104 | return torch.ops.npu.scatter_update_(iself, indices, updates, -2) |
| @@ -114,14 +113,13 @@ class TestFunctionalization(TestCase): | |||
| 114 | 113 | ||
| 115 | def forward(self, arg0_1, arg1_1, arg2_1): | 114 | def forward(self, arg0_1, arg1_1, arg2_1): |
| 116 | scatter_update = torch.ops.npu.scatter_update.default(arg0_1, arg1_1, arg2_1, -2); arg1_1 = arg2_1 = None | 115 | scatter_update = torch.ops.npu.scatter_update.default(arg0_1, arg1_1, arg2_1, -2); arg1_1 = arg2_1 = None |
| 117 | - copy_ = torch.ops.aten.copy_.default(arg0_1, scatter_update); arg0_1 = None | 116 | + copy_ = torch.ops.aten.copy_.default(arg0_1, scatter_update); arg0_1 = copy_ = None |
| 118 | return scatter_update | 117 | return scatter_update |
| 119 | """) | 118 | """) |
| 120 | 119 | ||
| 121 | self.assert_functionalization(f, in_self, in_indices, in_updates) | 120 | self.assert_functionalization(f, in_self, in_indices, in_updates) |
| 122 | 121 | ||
| 123 | 122 | ||
| 124 | - | ||
| 125 | def test_npu_quant_scatter(self): | 123 | def test_npu_quant_scatter(self): |
| 126 | def f(fake_var, fake_indices, fake_updates, fake_quant_scales): | 124 | def f(fake_var, fake_indices, fake_updates, fake_quant_scales): |
| 127 | return torch.ops.npu.npu_quant_scatter_(fake_var, fake_indices, fake_updates, fake_quant_scales, | 125 | return torch.ops.npu.npu_quant_scatter_(fake_var, fake_indices, fake_updates, fake_quant_scales, |
| @@ -142,14 +140,13 @@ def forward(self, arg0_1, arg1_1, arg2_1): | |||
| 142 | 140 | ||
| 143 | 141 | ||
| 144 | def forward(self, arg0_1, arg1_1, arg2_1, arg3_1): | 142 | def forward(self, arg0_1, arg1_1, arg2_1, arg3_1): |
| 145 | - npu_quant_scatter = torch.ops.npu.npu_quant_scatter.default(arg0_1, arg1_1, arg2_1, arg3_1, None, -2, -1); arg1_1 = arg2_1 = arg3_1 = None | 143 | + npu_quant_scatter = torch.ops.npu.npu_quant_scatter.default(arg0_1, arg1_1, arg2_1, arg3_1); arg1_1 = arg2_1 = arg3_1 = None |
| 146 | - copy_ = torch.ops.aten.copy_.default(arg0_1, npu_quant_scatter); arg0_1 = None | 144 | + copy_ = torch.ops.aten.copy_.default(arg0_1, npu_quant_scatter); arg0_1 = copy_ = None |
| 147 | return npu_quant_scatter | 145 | return npu_quant_scatter |
| 148 | """) | 146 | """) |
| 149 | 147 | ||
| 150 | self.assert_functionalization(f, in_var, in_indices, in_updates, in_quant_scales) | 148 | self.assert_functionalization(f, in_var, in_indices, in_updates, in_quant_scales) |
| 151 | 149 | ||
| 152 | - | ||
| 153 | def test_npu_scatter_nd_update(self): | 150 | def test_npu_scatter_nd_update(self): |
| 154 | def f(var, indices, updates): | 151 | def f(var, indices, updates): |
| 155 | return torch_npu.npu_scatter_nd_update_(var, indices, updates) | 152 | return torch_npu.npu_scatter_nd_update_(var, indices, updates) |
| @@ -168,18 +165,13 @@ def forward(self, arg0_1, arg1_1, arg2_1, arg3_1): | |||
| 168 | 165 | ||
| 169 | def forward(self, arg0_1, arg1_1, arg2_1): | 166 | def forward(self, arg0_1, arg1_1, arg2_1): |
| 170 | npu_scatter_nd_update = torch.ops.npu.npu_scatter_nd_update.default(arg0_1, arg1_1, arg2_1); arg1_1 = arg2_1 = None | 167 | npu_scatter_nd_update = torch.ops.npu.npu_scatter_nd_update.default(arg0_1, arg1_1, arg2_1); arg1_1 = arg2_1 = None |
| 171 | - copy_ = torch.ops.aten.copy_.default(arg0_1, npu_scatter_nd_update); arg0_1 = None | 168 | + copy_ = torch.ops.aten.copy_.default(arg0_1, npu_scatter_nd_update); arg0_1 = copy_ = None |
| 172 | return npu_scatter_nd_update | 169 | return npu_scatter_nd_update |
| 173 | """) | 170 | """) |
| 174 | 171 | ||
| 175 | self.assert_functionalization(f, var, indices, updates) | 172 | self.assert_functionalization(f, var, indices, updates) |
| 176 | 173 | ||
| 177 | - | ||
| 178 | def test_npu_silu_functionalize(self): | 174 | def test_npu_silu_functionalize(self): |
| 179 | - | ||
| 180 | - def npu_silu(self_): | ||
| 181 | - return torch.empty_like(self_) | ||
| 182 | - | ||
| 183 | 175 | ||
| 184 | def npu_silu_(self_): | 176 | def npu_silu_(self_): |
| 185 | return self_ | 177 | return self_ |
| @@ -195,7 +187,7 @@ def forward(self, arg0_1, arg1_1, arg2_1): | |||
| 195 | 187 | ||
| 196 | def forward(self, arg0_1): | 188 | def forward(self, arg0_1): |
| 197 | npu_silu = torch.ops.npu.npu_silu.default(arg0_1) | 189 | npu_silu = torch.ops.npu.npu_silu.default(arg0_1) |
| 198 | - copy_ = torch.ops.aten.copy_.default(arg0_1, npu_silu); arg0_1 = None | 190 | + copy_ = torch.ops.aten.copy_.default(arg0_1, npu_silu); arg0_1 = copy_ = None |
| 199 | return npu_silu | 191 | return npu_silu |
| 200 | """) | 192 | """) |
| 201 | self.assert_functionalization(f, a) | 193 | self.assert_functionalization(f, a) |