Skip to content

Commit

Permalink
Adjusting tolerance level and removing fixed seed for tests: test_iff…
Browse files Browse the repository at this point in the history
…t, test_fft (apache#12010)

* adjusting tolerance level and removing fixed seed

* CI retrigger

* removing status
  • Loading branch information
Roshrini authored and sandeep-krishnamurthy committed Aug 7, 2018
1 parent 5ee653e commit ecfef35
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tests/python/gpu/test_operator_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ def check_ifft(shape):
init_complex.real[:,i] = init[0][:,2*i]
init_complex.imag[:,i] = init[0][:,2*i+1]
a = np.fft.ifft(init_complex, n=None, axis=-1, norm=None)
assert_almost_equal(a.real, out1[0]/shape_old[1],rtol=1e-3, atol=1e-12)
assert_almost_equal(a.real, out1[0]/shape_old[1],rtol=1e-3, atol=1e-5)

if len(shape) == 4:
init_complex = np.zeros(shape_old,dtype = np.complex64)
for i in range(0,shape_old[3]):
init_complex.real[:,:,:,i] = init[0][:,:,:,2*i]
init_complex.imag[:,:,:,i] = init[0][:,:,:,2*i+1]
a = np.fft.ifft(init_complex, n=None, axis=-1, norm=None)
assert_almost_equal(a.real, out1[0]/shape_old[3],rtol=1e-3, atol=1e-12)
assert_almost_equal(a.real, out1[0]/shape_old[3],rtol=1e-3, atol=1e-5)
# backward
if len(shape) == 2:
out_grad = mx.nd.empty(shape_old)
Expand All @@ -148,7 +148,7 @@ def check_ifft(shape):
temp[:,i] = exe.grad_arrays[0].asnumpy()[:,2*i]

a = np.fft.fft(out_grad.asnumpy(), n=None, axis=-1, norm=None)
assert_almost_equal(a.real, temp, rtol=1e-3, atol=1e-12)
assert_almost_equal(a.real, temp, rtol=1e-3, atol=1e-5)
if len(shape) == 4:
out_grad = mx.nd.empty(shape_old)
out_grad[:] = np.random.normal(-3, 3, shape_old)
Expand All @@ -160,9 +160,9 @@ def check_ifft(shape):
temp[:,:,:,i] = exe.grad_arrays[0].asnumpy()[:,:,:,2*i]

a = np.fft.fft(out_grad.asnumpy(), n=None, axis=-1, norm=None)
assert_almost_equal(a.real, temp, rtol=1e-3, atol=1e-12)
assert_almost_equal(a.real, temp, rtol=1e-3, atol=1e-5)

@with_seed(0)
@with_seed()
def test_ifft():
nrepeat = 2
maxdim = 10
Expand Down Expand Up @@ -194,7 +194,7 @@ def check_fft(shape):
for exe in exe_list:
for arr, iarr in zip(exe.arg_arrays, init):
arr[:] = iarr.astype(arr.dtype)
#forward
# forward
for exe in exe_list:
exe.forward(is_train=True)
out1 = [exe.outputs[0].asnumpy() for exe in exe_list]
Expand All @@ -221,7 +221,7 @@ def check_fft(shape):
a[i,j,:,p+1] = out2[i,j+out1[0].shape[1],:,k]
p = p+2

assert_almost_equal(a, out1[0],rtol=1e-3, atol=1e-6)
assert_almost_equal(a, out1[0],rtol=1e-3, atol=1e-5)

# backward
if len(shape) == 2:
Expand All @@ -235,7 +235,7 @@ def check_fft(shape):
for exe in exe_list:
exe.backward([out_grad])
a = np.fft.ifft(out_grad_complex, n=None, axis=-1, norm=None)
assert_almost_equal(a.real, exe.grad_arrays[0].asnumpy()/shape[1],rtol=1e-3, atol=1e-8)
assert_almost_equal(a.real, exe.grad_arrays[0].asnumpy()/shape[1],rtol=1e-3, atol=1e-5)

if len(shape) == 4:
out_grad = mx.nd.empty(out1[0].shape)
Expand All @@ -248,9 +248,9 @@ def check_fft(shape):
for exe in exe_list:
exe.backward([out_grad])
a = np.fft.ifft(out_grad_complex, n=None, axis=-1, norm=None)
assert_almost_equal(a.real, exe.grad_arrays[0].asnumpy()/shape[3],rtol=1e-3, atol=1e-6)
assert_almost_equal(a.real, exe.grad_arrays[0].asnumpy()/shape[3],rtol=1e-3, atol=1e-5)

@with_seed(0)
@with_seed()
def test_fft():
nrepeat = 2
maxdim = 10
Expand Down

0 comments on commit ecfef35

Please sign in to comment.