Skip to content

Conversation

7908837174
Copy link
Contributor

@7908837174 7908837174 commented Aug 3, 2025

Issue Analysis

Identified that the clip_ function was missing from the main paddle math module (ivy/ivy/functional/frontends/paddle/math.py)
Found that it existed in the tensor math module but not in the main module where it should be accessible as paddle.clip_

Implementation
Added clip function to ivy/ivy/functional/frontends/paddle/math.py:
Proper error handling with ivy.utils.assertions.check_all_or_any_fn
Handles cases where min or max are None
Uses appropriate decorators: @with_supported_dtypes and @to_ivy_arrays_and_back
Supports dtypes: float32, float64, int32, int64
Added clip_ inplace function to ivy/ivy/functional/frontends/paddle/math.py:
Uses ivy.inplace_update(x, clip(x, min, max)) pattern consistent with other inplace operations
Same decorators and dtype support as clip

Testing
Added comprehensive tests to ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py:
Added get_clip_inputs() helper function for generating test data
Added test_paddle_clip() test function
Added test_paddle_clip_() test function
Tests use proper hypothesis strategies and follow established patterns

Files Modified
ivy/ivy/functional/frontends/paddle/math.py - Added clip and clip_ functions
ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py - Added helper and test functions

7908837174 added 2 commits July 25, 2025 01:25
- Implement missing subtract_ function in ivy/ivy/functional/frontends/paddle/math.py
- Add corresponding test case in ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py
- Follows same pattern as other inplace functions like add_
- Uses ivy.inplace_update for in-place subtraction operation
- Fixes issue ivy-llc#21937
…le frontend

- Added clip function to ivy/functional/frontends/paddle/math.py
- Added clip_ inplace function to ivy/functional/frontends/paddle/math.py
- Added comprehensive tests for both functions in test_paddle/test_math.py
- Functions follow established patterns with proper decorators and error handling
- clip_ uses ivy.inplace_update pattern consistent with other inplace operations
7908837174 and others added 7 commits August 3, 2025 20:58
- Add dtype preservation logic to clip function to maintain input dtype
- Update test function trees to use paddle.math.clip and paddle.math.clip_ paths
- Ensure clip function returns same dtype as input instead of float64
- Remove clip_ function from main math module (should only be in tensor.math)
- Update clip test to use standard dtype_and_values helper
- Remove unused _get_clip_inputs_ helper function
- Maintain clip function with dtype preservation in main math module
- Follow Ivy's pattern: non-inplace functions in math, inplace in tensor.math
- Remove subtract_ from main math module (should only be in tensor.math)
- Update remainder function to use supported_dtypes instead of unsupported_dtypes
- Fix pow function supported dtypes to match Paddle's actual support
- Restrict mod/remainder to: float32, float64, int32, int64
- Restrict pow to: float32, float64, int32, int64, complex64, complex128, bfloat16

These changes align with Paddle's actual kernel support and fix KeyError issues.
- Remove remaining subtract_ test from math test file
- Clean up extra blank lines
- Ensure test file has proper syntax and structure

This fixes the collection error that was preventing tests from running.
- Add overflow protection to handle very large input values
- Clamp infinite results to maximum finite values instead of inf
- This matches Paddle's behavior of returning large finite values rather than inf
- Should fix the final failing test and achieve 100% pass rate

Fixes the last remaining test failure in issue ivy-llc#21936.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants