未验证 提交 0ae552fb 编写于 作者: G GGBond8488 提交者: GitHub

remove user define grad (#53864)

* remove user define grad

* fix errors

* remove unused self.x_grad, self.out_grad
上级 1b6972fd
...@@ -16,14 +16,7 @@ import re ...@@ -16,14 +16,7 @@ import re
import sys import sys
import numpy as np import numpy as np
from spectral_op_np import ( from spectral_op_np import fft_c2c, fft_c2r, fft_r2c
fft_c2c,
fft_c2c_backward,
fft_c2r,
fft_c2r_backward,
fft_r2c,
fft_r2c_backward,
)
import paddle import paddle
from paddle import _C_ops from paddle import _C_ops
...@@ -155,22 +148,13 @@ class TestFFTC2COp(OpTest): ...@@ -155,22 +148,13 @@ class TestFFTC2COp(OpTest):
} }
self.outputs = {'Out': out} self.outputs = {'Out': out}
self.out_grad = (
np.random.random(self.x.shape) + 1j * np.random.random(self.x.shape)
).astype(self.x.dtype)
self.x_grad = fft_c2c_backward(
self.out_grad, self.axes, self.norm, self.forward
)
def test_check_output(self): def test_check_output(self):
self.check_output() self.check_output()
def test_check_grad(self): def test_check_grad(self):
self.check_grad( self.check_grad(
"X", ["X"],
"Out", "Out",
user_defined_grads=[self.x_grad],
user_defined_grad_outputs=[self.out_grad],
) )
...@@ -248,16 +232,6 @@ class TestFFTC2ROp(OpTest): ...@@ -248,16 +232,6 @@ class TestFFTC2ROp(OpTest):
} }
self.outputs = {'Out': out} self.outputs = {'Out': out}
self.out_grad = np.random.random(out.shape).astype(out.dtype)
self.x_grad = fft_c2r_backward(
self.x,
self.out_grad,
self.axes,
self.norm,
self.forward,
self.last_dim_size,
)
def test_check_output(self): def test_check_output(self):
self.check_output() self.check_output()
...@@ -265,8 +239,6 @@ class TestFFTC2ROp(OpTest): ...@@ -265,8 +239,6 @@ class TestFFTC2ROp(OpTest):
self.check_grad( self.check_grad(
["X"], ["X"],
"Out", "Out",
user_defined_grads=[self.x_grad],
user_defined_grad_outputs=[self.out_grad],
) )
...@@ -332,23 +304,11 @@ class TestFFTR2COp(OpTest): ...@@ -332,23 +304,11 @@ class TestFFTR2COp(OpTest):
} }
self.outputs = {'Out': out} self.outputs = {'Out': out}
self.out_grad = np.random.random(out.shape).astype(out.dtype)
self.x_grad = fft_r2c_backward(
self.x,
self.out_grad,
self.axes,
self.norm,
self.forward,
self.onesided,
)
def test_check_output(self): def test_check_output(self):
self.check_output() self.check_output()
def test_check_grad(self): def test_check_grad(self):
self.check_grad( self.check_grad(
"X", ["X"],
"Out", "Out",
user_defined_grads=[self.x_grad],
user_defined_grad_outputs=[self.out_grad],
) )
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册