SymbolicML / DynamicExpressions.jl

Ridiculously fast symbolic expressions
https://ai.damtp.cam.ac.uk/dynamicexpressions
Apache License 2.0
106 stars 15 forks source link

feat: allow expression algebra for safe aliases #107

Closed MilesCranmer closed 2 weeks ago

MilesCranmer commented 2 weeks ago

Allows one to declare safe_sqrt should map to sqrt in user space so that users can call sqrt(ex::Expression) and have it map to safe_sqrt (or whatever)

sweep-ai[bot] commented 2 weeks ago

Hey @MilesCranmer, here is an example of how you can ask me to improve this pull request:

@sweep Add unit tests for `declare_operator_alias` with binary operators (current tests only cover unary operators). For example, test that a custom safe division operator can be aliased to regular division.

:book: For more information on how to use Sweep, please read our documentation.

github-actions[bot] commented 2 weeks ago

Benchmark Results

master 911a9f0fbdf736... master/911a9f0fbdf736...
eval/ComplexF32/evaluation 7.22 ± 0.53 ms 7.27 ± 0.66 ms 0.993
eval/ComplexF64/evaluation 10.7 ± 0.78 ms 10.7 ± 0.75 ms 1
eval/Float32/derivative 11.5 ± 1 ms 11.4 ± 0.84 ms 1.01
eval/Float32/derivative_turbo 11.6 ± 1.1 ms 11.4 ± 0.94 ms 1.01
eval/Float32/evaluation 2.87 ± 0.26 ms 2.75 ± 0.26 ms 1.04
eval/Float32/evaluation_bumper 0.575 ± 0.014 ms 0.605 ± 0.016 ms 0.951
eval/Float32/evaluation_turbo 0.561 ± 0.033 ms 0.554 ± 0.032 ms 1.01
eval/Float32/evaluation_turbo_bumper 0.578 ± 0.014 ms 0.604 ± 0.015 ms 0.957
eval/Float64/derivative 15.4 ± 0.94 ms 14.8 ± 0.67 ms 1.04
eval/Float64/derivative_turbo 15 ± 0.85 ms 14.7 ± 0.6 ms 1.02
eval/Float64/evaluation 3.16 ± 0.29 ms 3.18 ± 0.33 ms 0.995
eval/Float64/evaluation_bumper 1.19 ± 0.043 ms 1.26 ± 0.048 ms 0.943
eval/Float64/evaluation_turbo 1.07 ± 0.071 ms 1.04 ± 0.067 ms 1.03
eval/Float64/evaluation_turbo_bumper 1.19 ± 0.045 ms 1.25 ± 0.048 ms 0.951
utils/combine_operators/break_sharing 0.0391 ± 0.00075 ms 0.0391 ± 0.0012 ms 1
utils/convert/break_sharing 27.2 ± 2.9 μs 27.1 ± 2.6 μs 1
utils/convert/preserve_sharing 0.0978 ± 0.0032 ms 0.0998 ± 0.0043 ms 0.98
utils/copy/break_sharing 27.7 ± 3.1 μs 27.7 ± 2.5 μs 1
utils/copy/preserve_sharing 0.0993 ± 0.004 ms 0.101 ± 0.0043 ms 0.986
utils/count_constant_nodes/break_sharing 8.89 ± 0.19 μs 8.59 ± 0.21 μs 1.04
utils/count_constant_nodes/preserve_sharing 0.0852 ± 0.0033 ms 0.0864 ± 0.0035 ms 0.986
utils/count_depth/break_sharing 9.9 ± 0.31 μs 9.33 ± 0.22 μs 1.06
utils/count_nodes/break_sharing 8.24 ± 0.2 μs 8.59 ± 0.2 μs 0.96
utils/count_nodes/preserve_sharing 0.0834 ± 0.0033 ms 0.0851 ± 0.0041 ms 0.98
utils/get_set_constants!/break_sharing 0.0346 ± 0.0022 ms 0.034 ± 0.0018 ms 1.02
utils/get_set_constants!/preserve_sharing 0.174 ± 0.0054 ms 0.174 ± 0.0058 ms 1
utils/get_set_constants_parametric 0.0444 ± 0.002 ms 0.0461 ± 0.0027 ms 0.963
utils/has_constants/break_sharing 4.06 ± 0.13 μs 4.31 ± 0.12 μs 0.943
utils/has_operators/break_sharing 2.04 ± 0.059 μs 1.71 ± 0.059 μs 1.19
utils/hash/break_sharing 22.4 ± 0.92 μs 23.4 ± 0.66 μs 0.957
utils/hash/preserve_sharing 0.0963 ± 0.0032 ms 0.0954 ± 0.003 ms 1.01
utils/index_constant_nodes/break_sharing 24.9 ± 1.1 μs 24.8 ± 1.1 μs 1
utils/index_constant_nodes/preserve_sharing 0.0977 ± 0.0032 ms 0.0992 ± 0.0042 ms 0.985
utils/is_constant/break_sharing 4.39 ± 0.14 μs 4.18 ± 0.11 μs 1.05
utils/simplify_tree/break_sharing 0.178 ± 0.0032 ms 0.178 ± 0.0027 ms 1
utils/simplify_tree/preserve_sharing 0.229 ± 0.0043 ms 0.234 ± 0.0053 ms 0.978
utils/string_tree/break_sharing 0.476 ± 0.017 ms 0.49 ± 0.017 ms 0.972
utils/string_tree/preserve_sharing 0.58 ± 0.017 ms 0.593 ± 0.019 ms 0.978
time_to_load 0.201 ± 0.002 s 0.205 ± 0.0017 s 0.98
coveralls commented 2 weeks ago

Pull Request Test Coverage Report for Build 11546348799

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details


Totals Coverage Status
Change from base Build 11318938552: 0.002%
Covered Lines: 2418
Relevant Lines: 2536

💛 - Coveralls