Skip to content

Commit efa010a

Browse files
committed
test: drop redundant no-clear sanity test to stay under PR size cap
1 parent baf3569 commit efa010a

1 file changed

Lines changed: 0 additions & 23 deletions

File tree

test/legacy_test/test_pylayer_clear_dataptr.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -172,29 +172,6 @@ def backward(ctx, dy):
172172
loss.backward()
173173
self.assertIsNotNone(x.grad)
174174

175-
def test_without_clear_dataptr(self):
176-
"""Sanity check: normal backward (no clear) still gives correct grad."""
177-
178-
class TanhLayer(PyLayer):
179-
@staticmethod
180-
def forward(ctx, x):
181-
y = paddle.tanh(x)
182-
ctx.save_for_backward(y)
183-
return y
184-
185-
@staticmethod
186-
def backward(ctx, dy):
187-
(y,) = ctx.saved_tensor()
188-
return dy * (1 - paddle.square(y))
189-
190-
x1 = paddle.randn([2, 3]).astype('float64')
191-
x2 = x1.detach().clone()
192-
x1.stop_gradient = False
193-
x2.stop_gradient = False
194-
TanhLayer.apply(x1).mean().backward()
195-
TanhLayer.apply(x2).mean().backward()
196-
np.testing.assert_allclose(x1.grad.numpy(), x2.grad.numpy(), rtol=1e-10)
197-
198175
def test_memory_cleanup(self):
199176
"""Multiple iterations: per-iteration objects are collectible."""
200177
import weakref

0 commit comments

Comments
 (0)