ivy icon indicating copy to clipboard operation
ivy copied to clipboard

Close #17091

Open Dharshannan opened this issue 2 years ago • 9 comments

Close #17091

Dharshannan avatar Jun 17 '23 20:06 Dharshannan

This PR is not complete, will need to add test function for ifftn frontend function.

Dharshannan avatar Jun 17 '23 20:06 Dharshannan

3rd commit: Fixed alignment issue and included statement to check if s shape and array shape are the same. It is difficult to pad and crop on the frontend as it results in inconsistent results between ivy.ifftn and numpy.fft.ifftn, RECOMMENDED : Code an ivy.ifftn backend function using numpy to allow for cropping and padding when the array shape and s argument shape do not match.

Dharshannan avatar Jun 18 '23 15:06 Dharshannan

Commit 4: Simplified and improved ifftn frontend function, now it is capable of handling zero padding and cropping via ivy.ifft.

Dharshannan avatar Jun 18 '23 16:06 Dharshannan

Commit 5: Removed ortho normalization handling in function as this is already done by ivy.ifft.

Dharshannan avatar Jun 18 '23 16:06 Dharshannan

@zhumakhan Could I get a review for my current work please? Thanks.

Dharshannan avatar Jun 18 '23 17:06 Dharshannan

Commit 6: Added Test function for ifftn frontend The ifftn frontend test has a 66% pass rate and fails for tensorflow backend, this might be caused by the fact that the ifft function also fails with tensorflow backend. ifft backend might have a problem and requires checking, since ifftn is coded using ifft, the failure with tensorflow backend is expected. Future Work: implement wider testing parameters (however this requires ifft fix for tensorflow backend to for better implementation).

Dharshannan avatar Jun 18 '23 23:06 Dharshannan

Commit 7: New ifftn function which works for a general case of any array, s and axes arguments!!!

Dharshannan avatar Jun 20 '23 17:06 Dharshannan

@zhumakhan Could I get a review for my work so far please?

Dharshannan avatar Jun 21 '23 11:06 Dharshannan

Commit 8: Simplified the previously complex ifftn function.

Dharshannan avatar Jun 21 '23 17:06 Dharshannan

Commit 9: Updated test function, now tests have a 100% pass rate. Might have to code a different function similar to x_and_ifft(draw) to allow for data generation more catered towards the ifftn function.

Dharshannan avatar Jun 21 '23 22:06 Dharshannan

Commit 10: Changed frontend ifftn function to include backend ivy.ifftn which was newly added.

Dharshannan avatar Jun 23 '23 13:06 Dharshannan

Hi, thanks for your PR! It seems to me that ivy.ifftn should handle wrong arguments on its own. So there is no need to do argument checks in the frontend.

@with_unsupported_dtypes({"1.24.3 and below": ("float16",)}, "numpy")
@to_ivy_arrays_and_back
def ifftn(a, s=None, axes=None, norm=None):
    a = ivy.array(a, dtype=ivy.complex128)
    a = ivy.ifftn(a, s=s, axes=axes, norm=norm)
    return a

Above implementation passes all the tests.

In addition to that, lets check if there are better ways of typecasting the input array. Currently it is done as below:

    a = ivy.array(a, dtype=ivy.complex128)

zhumakhan avatar Jun 23 '23 20:06 zhumakhan

Hi, thanks for your PR! It seems to me that ivy.ifftn should handle wrong arguments on its own. So there is no need to do argument checks in the frontend.

@with_unsupported_dtypes({"1.24.3 and below": ("float16",)}, "numpy")
@to_ivy_arrays_and_back
def ifftn(a, s=None, axes=None, norm=None):
    a = ivy.array(a, dtype=ivy.complex128)
    a = ivy.ifftn(a, s=s, axes=axes, norm=norm)
    return a

Above implementation passes all the tests.

In addition to that, lets check if there are better ways of typecasting the input array. Currently it is done as below:

    a = ivy.array(a, dtype=ivy.complex128)

@zhumakhan , should'nt the type casting be similar to that of the ifft function which is also ivy.complex128?

Dharshannan avatar Jun 23 '23 20:06 Dharshannan

Commit 11: Removed argument checks and changed type casting from "ivy.array" to "ivy.asarray" to handle type casting more flexibly and efficiently.

Dharshannan avatar Jun 23 '23 20:06 Dharshannan

Hi, currently it is failing all of the tests. Could please update this PR accordingly to pass all of the tests? Thanks!

zhumakhan avatar Jun 27 '23 10:06 zhumakhan

LGTM!

zhumakhan avatar Jun 30 '23 15:06 zhumakhan