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

Create cond operator #260

Merged
merged 9 commits into from
Dec 11, 2023
Merged

Create cond operator #260

merged 9 commits into from
Dec 11, 2023

Conversation

MilesCranmer
Copy link
Owner

@MilesCranmer MilesCranmer commented Sep 17, 2023

This seems like a fairly common operator for people to make by themselves, so might as well add it as a default option.

cond(x, y) = (x > zero(x)) * y

Basically an if statement with the false branch set to 0.

This also redefines a few of the logical operators to be SIMD-compatible by using multiplication-based definitions.

TODO:

  • Ensure operators are SIMD compatible in unittest

@github-actions
Copy link
Contributor

github-actions bot commented Sep 17, 2023

Benchmark Results

master f555298... t[master]/t[f555298...]
search/multithreading 27.7 ± 4.2 s 26.9 ± 3.7 s 1.03
search/serial 34 ± 0.94 s 34.1 ± 0.91 s 0.999
time_to_load 2.03 ± 0.012 s 2.03 ± 0.0064 s 1
utils/best_of_sample 0.952 ± 0.39 μs 0.892 ± 0.41 μs 1.07
utils/check_constraints_x10 12.6 ± 3.2 μs 12.7 ± 3.2 μs 0.995
utils/compute_complexity_x10/Float64 2.37 ± 0.13 μs 2.31 ± 0.12 μs 1.03
utils/compute_complexity_x10/Int64 2.32 ± 0.12 μs 2.31 ± 0.11 μs 1.01
utils/compute_complexity_x10/nothing 1.58 ± 0.12 μs 1.5 ± 0.12 μs 1.05
utils/optimize_constants_x10 30.8 ± 6.9 ms 31.5 ± 6.4 ms 0.978

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR.
Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

@MilesCranmer MilesCranmer merged commit 59abbd8 into master Dec 11, 2023
27 checks passed
@MilesCranmer MilesCranmer deleted the cond-operator branch December 11, 2023 18:03
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