-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【complex op】No.25 add complex support for fold #56914
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,14 @@ def init_data(self): | |
self.output_sizes = [4, 5] | ||
input_shape = [self.batch_size, self.input_channels, self.length] | ||
self.x = np.random.rand(*input_shape).astype(np.float64) | ||
if self.dtype == np.complex64 or self.dtype == np.complex128: | ||
self.x = ( | ||
np.random.uniform(-1, 1, input_shape) | ||
+ 1j * np.random.uniform(-1, 1, input_shape) | ||
).astype(self.dtype) | ||
|
||
def init_dtype(self): | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
def calc_fold(self): | ||
output_shape = [0] * 4 | ||
|
@@ -75,7 +83,7 @@ def calc_fold(self): | |
) | ||
+ 1 | ||
) | ||
output = np.zeros(output_shape).astype(np.float64) | ||
output = np.zeros(output_shape).astype(self.dtype) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 建议 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 好的 |
||
# ------------- calculate output ------------- # | ||
for b in range(output_shape[0]): | ||
for c in range(self.input_channels): | ||
|
@@ -106,6 +114,7 @@ def calc_fold(self): | |
self.outputs = output | ||
|
||
def set_data(self): | ||
self.init_dtype() | ||
self.init_data() | ||
self.calc_fold() | ||
self.inputs = {'X': OpTest.np_dtype_to_fluid_dtype(self.x)} | ||
|
@@ -130,6 +139,16 @@ def test_check_grad(self): | |
self.check_grad(['X'], 'Y') | ||
|
||
|
||
class TestFold_Complex64(TestFoldOp): | ||
def init_dtype(self): | ||
self.dtype = np.complex64 | ||
|
||
|
||
class TestFold_Complex128(TestFoldOp): | ||
def init_dtype(self): | ||
self.dtype = np.complex128 | ||
|
||
|
||
class TestFoldshape(TestFoldOp): | ||
def init_data(self): | ||
self.batch_size = 8 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
astype(np.float64)
->astype(self.dtype)