Skip to content
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

Fix gh-1279, implement tensor.allclose #1343

Merged
merged 15 commits into from Aug 18, 2023
Merged

Fix gh-1279, implement tensor.allclose #1343

merged 15 commits into from Aug 18, 2023

Commits on Aug 15, 2023

  1. Clean up of operator special methods

    1. Removed unused usm_ndarray._clone static C-only method
    2. Removed _dispatch* utilities
    3. Used direct calls to unary/binary operators in implementation
       of special methods
    oleksandr-pavlyk committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    48c2ad2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7d9974e View commit details
    Browse the repository at this point in the history
  3. Closes gh-1279

    Provide cabs private method implementating abs for complex types, paying
    attention to array-API mandated special values.
    
    To work-around gh-1279, use std::hypot to compute value for finite inputs.
    Compile with -DUSE_STD_ABS_FOR_COMPLEX_TYPES to use std::abs(z) instead of
    std::hypot(std::real(z), std::imag(z)).
    oleksandr-pavlyk committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    5f298e6 View commit details
    Browse the repository at this point in the history
  4. Closes gh-1279 for dpt.sqrt

    This change provides private method csqrt to evaluate square-root
    for complex types. It handles special values as mandated by array API.
    
    The finite input, it provides its own implementation based on std::hypot
    and std::sqrt for real types instead of calling std::sqrt on finite
    input of complex type.
    
    Compile with -DUSE_STD_SQRT_FOR_COMPLEX_TYPES to use std::sqrt instead
    of custom implementation.
    
    Cursory performance study suggests that custom implementation is at least
    not worse than std::sqrt one.
    oleksandr-pavlyk committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    4a2578f View commit details
    Browse the repository at this point in the history
  5. Implements dpctl.tensor.allclose

    This utility function is based on symmetric check, unlike numpy.allclose,
    and verifies that abs(x1-x2) < atol + rtol * max(abs(x1), abs(x2))
    
    This way allclose(x1, x2) is symmetric, and allclose(x1,x2) implies
    allclose(x2, x1).
    oleksandr-pavlyk committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    26862b4 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    b121d67 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    d60d58e View commit details
    Browse the repository at this point in the history

Commits on Aug 16, 2023

  1. Fixes per PR review feedback

    1. Aligned default values with those of np.allclose
    2. Replaced less test with less_equal to align with NumPy.
    oleksandr-pavlyk committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    ea6dd27 View commit details
    Browse the repository at this point in the history
  2. Adds tests for atol/rtol

    Also added tests for early exits to improve coverage.
    oleksandr-pavlyk committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    f36af57 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a75fff8 View commit details
    Browse the repository at this point in the history
  4. Completion of fix for gh-1058

    This changes builds up on gh-1265 and takes into account queue
    from the pre-allocated buffer, if provided.
    oleksandr-pavlyk committed Aug 16, 2023
    Configuration menu
    Copy the full SHA
    ff3c680 View commit details
    Browse the repository at this point in the history

Commits on Aug 17, 2023

  1. Scale down arguments and scale back the result

    This improves accuracy at extremes of supported range.
    
    Use sycl:: namespace ldexp and ilogb to prevent problem
    with VS 2017 headers.
    oleksandr-pavlyk committed Aug 17, 2023
    Configuration menu
    Copy the full SHA
    c4312cb View commit details
    Browse the repository at this point in the history
  2. Avoid using sycl::ilogb, but use own implementation

    ilogb would have to pay attention to correctly computing
    scale of denormal floats, while simpler code suffices.
    
    Also use unscaled version in most cases, and scaled version
    only for very large inputs.
    oleksandr-pavlyk committed Aug 17, 2023
    Configuration menu
    Copy the full SHA
    bb52bb1 View commit details
    Browse the repository at this point in the history
  3. Set defines to use std::abs and std::sqrt on Linux

    We work around issues with these functions when their implementation
    is taken from VS 2017 headers on Windows though.
    oleksandr-pavlyk committed Aug 17, 2023
    Configuration menu
    Copy the full SHA
    ba9a595 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    142190f View commit details
    Browse the repository at this point in the history