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

Add simsimd #42

Merged
merged 6 commits into from
Oct 29, 2024
Merged

Add simsimd #42

merged 6 commits into from
Oct 29, 2024

Conversation

ternaus
Copy link
Contributor

@ternaus ternaus commented Oct 29, 2024

Summary by Sourcery

Add support for the SimSIMD library in image processing functions, enhancing performance and flexibility. Update the benchmark script to allow configurable parameters and improve the convert_value function for better type handling. Include new tests for SimSIMD functions and update dependencies.

New Features:

  • Introduce new functions for image processing using the SimSIMD library, including add_weighted_simsimd, add_array_simsimd, multiply_by_constant_simsimd, and add_constant_simsimd.

Enhancements:

  • Enhance the benchmark script to accept command-line arguments for channels, types, number of images, and repeats, with default values provided.
  • Update the convert_value function to handle different data types more robustly and raise a TypeError for unsupported types.

Build:

  • Add SimSIMD as a dependency in the setup.py file.

Tests:

  • Add tests for the new SimSIMD-based functions to ensure they produce expected results and are consistent with existing implementations.

Copy link
Contributor

sourcery-ai bot commented Oct 29, 2024

Reviewer's Guide by Sourcery

This pull request introduces simsimd integration for image processing operations, enhancing performance for certain operations. The implementation includes new simsimd-based functions for add, multiply, and weighted addition operations, along with comprehensive benchmarking infrastructure to compare performance across different implementations.

Sequence diagram for simsimd benchmarking process

sequenceDiagram
    participant User
    participant BenchmarkScript
    participant AlbucoreFunctions
    participant Simsimd
    User->>BenchmarkScript: Run benchmark.sh with options
    BenchmarkScript->>AlbucoreFunctions: Call add_weighted_simsimd
    AlbucoreFunctions->>Simsimd: Perform weighted addition
    Simsimd-->>AlbucoreFunctions: Return result
    AlbucoreFunctions-->>BenchmarkScript: Return processed image
    BenchmarkScript-->>User: Display benchmark results
Loading

Class diagram for new simsimd functions

classDiagram
    class AlbucoreFunctions {
        +add_weighted_simsimd(np.ndarray img1, float weight1, np.ndarray img2, float weight2) np.ndarray
        +add_array_simsimd(np.ndarray img, np.ndarray value) np.ndarray
        +multiply_by_constant_simsimd(np.ndarray img, float value) np.ndarray
        +add_constant_simsimd(np.ndarray img, float value) np.ndarray
    }
    note for AlbucoreFunctions "New simsimd-based functions for image processing operations"
Loading

File-Level Changes

Change Details Files
Added simsimd-based implementations for core image processing operations
  • Implemented add_weighted_simsimd for weighted addition of images
  • Added multiply_by_constant_simsimd for scalar multiplication
  • Created add_constant_simsimd for scalar addition
  • Implemented add_array_simsimd for array addition
albucore/functions.py
Enhanced benchmark infrastructure to support simsimd comparison
  • Added simsimd to benchmarking libraries
  • Implemented simsimd transform methods for various operations
  • Updated benchmark result formatting to use median instead of mean
  • Added new benchmark result files for different configurations
benchmark/albucore_benchmark/benchmark.py
benchmark/utils.py
benchmark/albucore_benchmark/results/
Updated benchmark script with improved configuration options
  • Added command-line options for channels, types, number of images, and repeats
  • Implemented help and usage information
  • Added default values for benchmark parameters
benchmark.sh
Refactored value conversion logic and error handling
  • Improved type checking and error handling in convert_value function
  • Enhanced documentation with detailed parameter descriptions
  • Simplified conditional logic for value conversion
albucore/utils.py
Added new benchmark comparison tool
  • Created dedicated benchmark tool for comparing stringzilla vs cv2 LUT
  • Implemented detailed performance metrics collection
  • Added CPU information gathering for benchmark context
benchmark/stringzilla_vs_cv2_lut/benchmark_add_weighted.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ternaus - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟡 Documentation: 1 issue found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

albucore/functions.py Show resolved Hide resolved
tests/test_add_weighted.py Show resolved Hide resolved
tests/test_add_weighted.py Show resolved Hide resolved
tests/test_add_weighted.py Show resolved Hide resolved
tests/test_add_weighted.py Show resolved Hide resolved
tests/test_add_weighted.py Show resolved Hide resolved
@ternaus ternaus merged commit 8b309b4 into main Oct 29, 2024
16 checks passed
@ternaus ternaus deleted the add_simsimd branch October 29, 2024 01:51
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.

1 participant