fpy2 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fpy2-0.2.4/PKG-INFO +190 -0
- fpy2-0.2.4/README.md +159 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/__init__.py +14 -1
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/__init__.py +13 -2
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/alias.py +324 -12
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/array_size.py +309 -88
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/call_graph.py +0 -6
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/context_use.py +102 -20
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/define_use.py +30 -4
- fpy2-0.2.4/fpy2/analysis/digit_bound/__init__.py +34 -0
- fpy2-0.2.4/fpy2/analysis/digit_bound/infer.py +1778 -0
- fpy2-0.2.4/fpy2/analysis/digit_bound/solver.py +419 -0
- fpy2-0.2.4/fpy2/analysis/digit_bound/store.py +265 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/format_infer/__init__.py +20 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/format_infer/analysis.py +749 -191
- fpy2-0.2.4/fpy2/analysis/format_infer/double_round.py +288 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/format_infer/format.py +168 -68
- fpy2-0.2.4/fpy2/analysis/hoistability.py +228 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/live_vars.py +2 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/partial_eval.py +37 -44
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/purity.py +0 -4
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/reachability.py +20 -9
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/reaching_defs.py +37 -1
- fpy2-0.2.4/fpy2/analysis/storage_infer.py +418 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/syntax_check.py +55 -6
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/type_infer.py +4 -4
- fpy2-0.2.4/fpy2/analysis/value_class.py +1975 -0
- fpy2-0.2.4/fpy2/ast/accessors.py +149 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/ast/fpyast.py +16 -6
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/ast/visitor.py +2 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/__init__.py +3 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/compiler.py +285 -61
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/emitter.py +1065 -575
- fpy2-0.2.4/fpy2/backend/cpp/storage.py +286 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/target.py +58 -30
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/types.py +16 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/unbox.py +70 -164
- fpy2-0.2.4/fpy2/backend/cpp/unfold_round.py +72 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/utils.py +4 -1
- fpy2-0.2.2/fpy2/backend/cpp/storage_infer.py → fpy2-0.2.4/fpy2/backend/cpp/variables.py +119 -199
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/fpc.py +46 -36
- fpy2-0.2.4/fpy2/backend/triton/__init__.py +47 -0
- fpy2-0.2.4/fpy2/backend/triton/compiler.py +167 -0
- fpy2-0.2.4/fpy2/backend/triton/emitter.py +2895 -0
- fpy2-0.2.4/fpy2/backend/triton/launcher.py +265 -0
- fpy2-0.2.4/fpy2/backend/triton/normalize.py +131 -0
- fpy2-0.2.4/fpy2/backend/triton/split_names.py +84 -0
- fpy2-0.2.4/fpy2/backend/triton/storage.py +196 -0
- fpy2-0.2.4/fpy2/backend/triton/target.py +258 -0
- fpy2-0.2.4/fpy2/backend/triton/types.py +92 -0
- fpy2-0.2.4/fpy2/backend/triton/unfold_round.py +109 -0
- fpy2-0.2.4/fpy2/backend/triton/vectorize.py +471 -0
- fpy2-0.2.4/fpy2/backend/unfold_round.py +308 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/decorator.py +26 -3
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/function.py +62 -2
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/interpret/__init__.py +1 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/interpret/byte.py +102 -83
- fpy2-0.2.4/fpy2/interpret/value.py +174 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/__init__.py +1 -1
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/context.py +21 -1
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/efloat.py +18 -14
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/exponential.py +3 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/mp_fixed.py +9 -11
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/mp_float.py +163 -19
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/mpb_fixed.py +9 -10
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/mpb_float.py +168 -19
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/mps_float.py +171 -19
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/real.py +3 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/number/__init__.py +1 -1
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/number/floats.py +17 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/number/reals.py +1 -1
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/ops.py +11 -19
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/primitive.py +6 -22
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/rewrite/__init__.py +2 -1
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/rewrite/applier.py +24 -29
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/rewrite/matcher.py +60 -102
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/rewrite/pattern.py +10 -0
- fpy2-0.2.4/fpy2/rewrite/rewrite.py +313 -0
- fpy2-0.2.4/fpy2/rewrite/search.py +120 -0
- fpy2-0.2.4/fpy2/strategies/__init__.py +112 -0
- fpy2-0.2.4/fpy2/strategies/anf.py +69 -0
- fpy2-0.2.4/fpy2/strategies/assert_elim.py +55 -0
- fpy2-0.2.4/fpy2/strategies/comp_lower.py +108 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/context_lift.py +1 -2
- fpy2-0.2.4/fpy2/strategies/exit_single.py +78 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/fixed_rescale.py +31 -21
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/float_lower.py +36 -30
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/free_var.py +1 -2
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/func_inline.py +13 -8
- fpy2-0.2.4/fpy2/strategies/hoistable.py +85 -0
- fpy2-0.2.4/fpy2/strategies/if_simplify.py +78 -0
- fpy2-0.2.4/fpy2/strategies/invariant_hoist.py +121 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/iter_elim.py +3 -0
- fpy2-0.2.4/fpy2/strategies/iter_unfold.py +166 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/loop_split.py +44 -10
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/loop_unroll.py +29 -15
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/mono.py +1 -2
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/neg_zero_unfold.py +28 -21
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/overflow_unfold.py +35 -39
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/reduce_fusion.py +3 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/round_elim.py +3 -0
- fpy2-0.2.4/fpy2/strategies/round_insert.py +108 -0
- fpy2-0.2.4/fpy2/strategies/round_split.py +123 -0
- fpy2-0.2.4/fpy2/strategies/scale_hoist.py +117 -0
- fpy2-0.2.4/fpy2/strategies/simple.py +63 -0
- fpy2-0.2.4/fpy2/strategies/sites.py +240 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/special_unfold.py +32 -27
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/__init__.py +32 -0
- fpy2-0.2.4/fpy2/transform/anf.py +439 -0
- fpy2-0.2.4/fpy2/transform/assert_elim.py +85 -0
- fpy2-0.2.4/fpy2/transform/comp_to_loop.py +581 -0
- fpy2-0.2.4/fpy2/transform/const_fold.py +408 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/copy_propagate.py +2 -2
- fpy2-0.2.4/fpy2/transform/cursor.py +440 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/dead_code.py +112 -25
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/error.py +6 -5
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/float_to_fixed.py +116 -104
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/for_bundling.py +4 -1
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/for_unroll.py +156 -46
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/free_var_elim.py +13 -2
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/func_inline.py +157 -57
- fpy2-0.2.4/fpy2/transform/hoist_invariant.py +581 -0
- fpy2-0.2.4/fpy2/transform/hoist_scale.py +477 -0
- fpy2-0.2.4/fpy2/transform/hoistable.py +431 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/if_bundling.py +4 -1
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/iter_elim.py +1 -6
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/lift_context.py +18 -1
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/monomorphize.py +47 -29
- fpy2-0.2.4/fpy2/transform/path.py +233 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/reduce_fusion.py +40 -44
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/rescale_fixed.py +93 -81
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/round_elim.py +53 -152
- fpy2-0.2.4/fpy2/transform/round_insert.py +189 -0
- fpy2-0.2.4/fpy2/transform/simplify.py +102 -0
- fpy2-0.2.4/fpy2/transform/simplify_if.py +502 -0
- fpy2-0.2.4/fpy2/transform/single_exit.py +224 -0
- fpy2-0.2.4/fpy2/transform/specialize.py +858 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/split_loop.py +232 -56
- fpy2-0.2.4/fpy2/transform/split_round.py +395 -0
- fpy2-0.2.4/fpy2/transform/statement_form.py +50 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/subst_var.py +20 -1
- fpy2-0.2.4/fpy2/transform/unfold_iter.py +241 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/unfold_neg_zero.py +105 -98
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/unfold_overflow.py +149 -140
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/unfold_special.py +148 -128
- fpy2-0.2.4/fpy2/transform/unnest_context.py +187 -0
- fpy2-0.2.4/fpy2/transform/utils.py +915 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/while_bundling.py +4 -1
- fpy2-0.2.4/fpy2/transform/while_unroll.py +117 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/types.py +20 -14
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/decorator.py +8 -5
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/gensym.py +8 -4
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/unionfind.py +2 -2
- fpy2-0.2.4/fpy2.egg-info/PKG-INFO +190 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2.egg-info/SOURCES.txt +51 -1
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2.egg-info/requires.txt +4 -3
- {fpy2-0.2.2 → fpy2-0.2.4}/pyproject.toml +10 -4
- fpy2-0.2.2/PKG-INFO +0 -121
- fpy2-0.2.2/README.md +0 -91
- fpy2-0.2.2/fpy2/analysis/value_class.py +0 -707
- fpy2-0.2.2/fpy2/backend/cpp/storage.py +0 -266
- fpy2-0.2.2/fpy2/rewrite/rewrite.py +0 -235
- fpy2-0.2.2/fpy2/strategies/__init__.py +0 -42
- fpy2-0.2.2/fpy2/strategies/simple.py +0 -73
- fpy2-0.2.2/fpy2/transform/const_fold.py +0 -175
- fpy2-0.2.2/fpy2/transform/simplify_if.py +0 -181
- fpy2-0.2.2/fpy2/transform/specialize.py +0 -540
- fpy2-0.2.2/fpy2/transform/utils.py +0 -312
- fpy2-0.2.2/fpy2/transform/while_unroll.py +0 -111
- fpy2-0.2.2/fpy2.egg-info/PKG-INFO +0 -121
- {fpy2-0.2.2 → fpy2-0.2.4}/LICENSE +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/defs.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/escape.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/ast/__init__.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/ast/formatter.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/backend.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/__init__.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/ops.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/env.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/fpc_context.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/frontend/__init__.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/frontend/fpc.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/frontend/parser.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/interpret/interpreter.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/__init__.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/base.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/core.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/eft.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/matrix.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/metrics.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/vector.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/module.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/__init__.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/fixed.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/format.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/ieee754.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/sm_fixed.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/engine/__init__.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/engine/engine.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/engine/gmp.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/engine/real.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/format.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/globals.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/gmputils.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/native.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/number/flags.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/round.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/rewrite/subst.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/runner.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/enumerate_elim.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/for_unpack.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/rename_target.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/zip_elim.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/__init__.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/bits.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/compare.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/default.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/float_params.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/fractions.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/identifier.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/inspect.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/iterator.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/loader.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/location.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/ordering.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/string.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/uninit.py +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2.egg-info/dependency_links.txt +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/fpy2.egg-info/top_level.txt +0 -0
- {fpy2-0.2.2 → fpy2-0.2.4}/setup.cfg +0 -0
fpy2-0.2.4/PKG-INFO
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fpy2
|
|
3
|
+
Version: 0.2.4
|
|
4
|
+
Summary: An embedded DSL for numerical computing
|
|
5
|
+
Author-email: Brett Saiki <bsaiki@cs.washington.edu>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/bksaiki/fpy
|
|
8
|
+
Project-URL: Issues, https://github.com/bksaiki/fpy/issues
|
|
9
|
+
Project-URL: Documentation, https://fpy.readthedocs.io/
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: titanfp==0.1.2
|
|
16
|
+
Requires-Dist: gmpy2==2.3.1
|
|
17
|
+
Requires-Dist: numpy
|
|
18
|
+
Requires-Dist: z3-solver>=4.13
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest; extra == "dev"
|
|
21
|
+
Requires-Dist: pytest-xdist; extra == "dev"
|
|
22
|
+
Requires-Dist: hypothesis==6.135; extra == "dev"
|
|
23
|
+
Requires-Dist: mypy; extra == "dev"
|
|
24
|
+
Requires-Dist: ruff; extra == "dev"
|
|
25
|
+
Requires-Dist: build; extra == "dev"
|
|
26
|
+
Requires-Dist: twine; extra == "dev"
|
|
27
|
+
Requires-Dist: sphinx; extra == "dev"
|
|
28
|
+
Requires-Dist: sphinx-rtd-theme; extra == "dev"
|
|
29
|
+
Requires-Dist: sphinx-pyproject; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# FPy
|
|
33
|
+
|
|
34
|
+
An embedded Python DSL for specifying and simulating numerical algorithms.
|
|
35
|
+
|
|
36
|
+
Important links:
|
|
37
|
+
- PyPI package: [fpy2](https://pypi.org/project/fpy2/)
|
|
38
|
+
- Documentation: [fpy.readthedocs.io](https://fpy.readthedocs.io/)
|
|
39
|
+
- GitHub: [fpy](https://github.com/bksaiki/fpy)
|
|
40
|
+
- Guide: [USAGE.md](docs/USAGE.md)
|
|
41
|
+
|
|
42
|
+
## Example
|
|
43
|
+
|
|
44
|
+
FPy is Python with explicit control of both the mathematics and
|
|
45
|
+
rounding: every operation is correctly rounded by the *rounding context*
|
|
46
|
+
it appears in, and contexts are ordinary values you can pass around —
|
|
47
|
+
including `fp.REAL`, which never rounds. Here is a blocked dot product:
|
|
48
|
+
the products are exact, each block of `K` elements is summed in a narrow
|
|
49
|
+
format, and the running total is `float32`.
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import fpy2 as fp
|
|
53
|
+
|
|
54
|
+
@fp.fpy(ctx=fp.REAL)
|
|
55
|
+
def dot(xs: list[fp.Real], ys: list[fp.Real], K: int, block: fp.Context) -> fp.Real:
|
|
56
|
+
"""A blocked dot product: exact products, blocks of `K` summed in `block`.
|
|
57
|
+
The length of `xs` must be a multiple of `K`."""
|
|
58
|
+
assert len(xs) == len(ys)
|
|
59
|
+
acc = 0
|
|
60
|
+
for start in range(0, len(xs), K):
|
|
61
|
+
with block:
|
|
62
|
+
inner_acc = 0
|
|
63
|
+
for x, y in zip(xs[start:start + K], ys[start:start + K]):
|
|
64
|
+
with fp.REAL:
|
|
65
|
+
p = x * y # every product is exact ...
|
|
66
|
+
inner_acc += p # ... but block sums round to `block`
|
|
67
|
+
with fp.FP32:
|
|
68
|
+
acc += inner_acc # one fp32 addition per block
|
|
69
|
+
return acc
|
|
70
|
+
|
|
71
|
+
@fp.fpy(ctx=fp.REAL)
|
|
72
|
+
def dot_ref(xs: list[fp.Real], ys: list[fp.Real]) -> fp.Real:
|
|
73
|
+
"""The same dot product, with no rounding anywhere."""
|
|
74
|
+
return sum([x * y for x, y in zip(xs, ys)])
|
|
75
|
+
|
|
76
|
+
xs = ys = [0.1] * 4096
|
|
77
|
+
exact = dot_ref(xs, ys).as_rational() # the true value, as a Fraction
|
|
78
|
+
|
|
79
|
+
print(f'{"block":>6} {"format":>9} {"result":>11} {"rel. error":>11}')
|
|
80
|
+
for K, name, ctx in [(4096, 'float16', fp.FP16), (32, 'float16', fp.FP16),
|
|
81
|
+
(4096, 'bfloat16', fp.BF16), (32, 'bfloat16', fp.BF16),
|
|
82
|
+
(32, 'float32', fp.FP32)]:
|
|
83
|
+
r = dot(xs, ys, K, ctx)
|
|
84
|
+
err = abs(r.as_rational() - exact) / exact
|
|
85
|
+
print(f'{K:>6} {name:>9} {float(r):>11.6f} {float(err):>11.3%}')
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
which prints
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
block format result rel. error
|
|
92
|
+
4096 float16 32.000000 21.875%
|
|
93
|
+
32 float16 40.968750 0.021%
|
|
94
|
+
4096 bfloat16 4.000000 90.234%
|
|
95
|
+
32 bfloat16 40.250000 1.733%
|
|
96
|
+
32 float32 40.959972 0.000%
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
A flat `float16` accumulator stalls out once the running total dwarfs
|
|
100
|
+
the product being added to it; summing 32 elements at a time keeps the
|
|
101
|
+
error three orders of magnitude smaller.
|
|
102
|
+
|
|
103
|
+
See the [usage guide](docs/USAGE.md) for the language and the
|
|
104
|
+
[examples page](https://fpy.readthedocs.io/en/latest/example.html) for
|
|
105
|
+
more.
|
|
106
|
+
|
|
107
|
+
## Installation
|
|
108
|
+
|
|
109
|
+
FPy can be installed from PyPI with either `uv` or `pip`, or built from
|
|
110
|
+
source for development. The following instructions assume a `bash`-like
|
|
111
|
+
shell.
|
|
112
|
+
|
|
113
|
+
### Installing from PyPI
|
|
114
|
+
|
|
115
|
+
Requirements:
|
|
116
|
+
- Python 3.11 or later
|
|
117
|
+
|
|
118
|
+
To install the latest stable release of FPy, run:
|
|
119
|
+
```bash
|
|
120
|
+
uv pip install fpy2
|
|
121
|
+
```
|
|
122
|
+
or, with `pip`:
|
|
123
|
+
```bash
|
|
124
|
+
pip install fpy2
|
|
125
|
+
```
|
|
126
|
+
The Triton backend also needs PyTorch, Triton and a GPU: install `fpy2[triton]`.
|
|
127
|
+
|
|
128
|
+
### Installing from source
|
|
129
|
+
|
|
130
|
+
Requirements:
|
|
131
|
+
- Python 3.11 or later
|
|
132
|
+
- `make`
|
|
133
|
+
|
|
134
|
+
#### With `uv` (preferred)
|
|
135
|
+
|
|
136
|
+
[uv](https://docs.astral.sh/uv/) is the recommended development
|
|
137
|
+
workflow — it handles the virtual environment and dependency
|
|
138
|
+
installation in a single step:
|
|
139
|
+
```bash
|
|
140
|
+
uv sync
|
|
141
|
+
```
|
|
142
|
+
This creates `.venv/` and installs FPy in editable mode along with the
|
|
143
|
+
`dev` dependency group, pinned by `uv.lock`. Rerun it to reset `.venv/` to
|
|
144
|
+
the lockfile; it removes anything installed by hand. Activate the
|
|
145
|
+
environment with
|
|
146
|
+
```bash
|
|
147
|
+
source .venv/bin/activate
|
|
148
|
+
```
|
|
149
|
+
or prefix individual commands with `uv run` (e.g. `uv run pytest tests/unit`).
|
|
150
|
+
|
|
151
|
+
#### With `pip` (legacy)
|
|
152
|
+
|
|
153
|
+
This path is preserved for compatibility with existing tooling; new
|
|
154
|
+
contributors should prefer `uv` above.
|
|
155
|
+
|
|
156
|
+
If you do not have a Python virtual environment,
|
|
157
|
+
create one using
|
|
158
|
+
```bash
|
|
159
|
+
python3 -m venv .venv/
|
|
160
|
+
```
|
|
161
|
+
and activate it using
|
|
162
|
+
```bash
|
|
163
|
+
source .venv/bin/activate
|
|
164
|
+
```
|
|
165
|
+
To install an instance of FPy for development, run:
|
|
166
|
+
```bash
|
|
167
|
+
pip install -e .[dev]
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
To uninstall FPy, run:
|
|
171
|
+
```bash
|
|
172
|
+
pip uninstall fpy2
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Testing
|
|
176
|
+
|
|
177
|
+
There are a number of tests that can be run through
|
|
178
|
+
the `Makefile` including
|
|
179
|
+
```bash
|
|
180
|
+
make lint
|
|
181
|
+
```
|
|
182
|
+
to ensure formatting and type safety;
|
|
183
|
+
```bash
|
|
184
|
+
make unittest
|
|
185
|
+
```
|
|
186
|
+
to run the unit tests;
|
|
187
|
+
```bash
|
|
188
|
+
make infratest
|
|
189
|
+
```
|
|
190
|
+
to run the infrastructure tests.
|
fpy2-0.2.4/README.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# FPy
|
|
2
|
+
|
|
3
|
+
An embedded Python DSL for specifying and simulating numerical algorithms.
|
|
4
|
+
|
|
5
|
+
Important links:
|
|
6
|
+
- PyPI package: [fpy2](https://pypi.org/project/fpy2/)
|
|
7
|
+
- Documentation: [fpy.readthedocs.io](https://fpy.readthedocs.io/)
|
|
8
|
+
- GitHub: [fpy](https://github.com/bksaiki/fpy)
|
|
9
|
+
- Guide: [USAGE.md](docs/USAGE.md)
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
FPy is Python with explicit control of both the mathematics and
|
|
14
|
+
rounding: every operation is correctly rounded by the *rounding context*
|
|
15
|
+
it appears in, and contexts are ordinary values you can pass around —
|
|
16
|
+
including `fp.REAL`, which never rounds. Here is a blocked dot product:
|
|
17
|
+
the products are exact, each block of `K` elements is summed in a narrow
|
|
18
|
+
format, and the running total is `float32`.
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
import fpy2 as fp
|
|
22
|
+
|
|
23
|
+
@fp.fpy(ctx=fp.REAL)
|
|
24
|
+
def dot(xs: list[fp.Real], ys: list[fp.Real], K: int, block: fp.Context) -> fp.Real:
|
|
25
|
+
"""A blocked dot product: exact products, blocks of `K` summed in `block`.
|
|
26
|
+
The length of `xs` must be a multiple of `K`."""
|
|
27
|
+
assert len(xs) == len(ys)
|
|
28
|
+
acc = 0
|
|
29
|
+
for start in range(0, len(xs), K):
|
|
30
|
+
with block:
|
|
31
|
+
inner_acc = 0
|
|
32
|
+
for x, y in zip(xs[start:start + K], ys[start:start + K]):
|
|
33
|
+
with fp.REAL:
|
|
34
|
+
p = x * y # every product is exact ...
|
|
35
|
+
inner_acc += p # ... but block sums round to `block`
|
|
36
|
+
with fp.FP32:
|
|
37
|
+
acc += inner_acc # one fp32 addition per block
|
|
38
|
+
return acc
|
|
39
|
+
|
|
40
|
+
@fp.fpy(ctx=fp.REAL)
|
|
41
|
+
def dot_ref(xs: list[fp.Real], ys: list[fp.Real]) -> fp.Real:
|
|
42
|
+
"""The same dot product, with no rounding anywhere."""
|
|
43
|
+
return sum([x * y for x, y in zip(xs, ys)])
|
|
44
|
+
|
|
45
|
+
xs = ys = [0.1] * 4096
|
|
46
|
+
exact = dot_ref(xs, ys).as_rational() # the true value, as a Fraction
|
|
47
|
+
|
|
48
|
+
print(f'{"block":>6} {"format":>9} {"result":>11} {"rel. error":>11}')
|
|
49
|
+
for K, name, ctx in [(4096, 'float16', fp.FP16), (32, 'float16', fp.FP16),
|
|
50
|
+
(4096, 'bfloat16', fp.BF16), (32, 'bfloat16', fp.BF16),
|
|
51
|
+
(32, 'float32', fp.FP32)]:
|
|
52
|
+
r = dot(xs, ys, K, ctx)
|
|
53
|
+
err = abs(r.as_rational() - exact) / exact
|
|
54
|
+
print(f'{K:>6} {name:>9} {float(r):>11.6f} {float(err):>11.3%}')
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
which prints
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
block format result rel. error
|
|
61
|
+
4096 float16 32.000000 21.875%
|
|
62
|
+
32 float16 40.968750 0.021%
|
|
63
|
+
4096 bfloat16 4.000000 90.234%
|
|
64
|
+
32 bfloat16 40.250000 1.733%
|
|
65
|
+
32 float32 40.959972 0.000%
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
A flat `float16` accumulator stalls out once the running total dwarfs
|
|
69
|
+
the product being added to it; summing 32 elements at a time keeps the
|
|
70
|
+
error three orders of magnitude smaller.
|
|
71
|
+
|
|
72
|
+
See the [usage guide](docs/USAGE.md) for the language and the
|
|
73
|
+
[examples page](https://fpy.readthedocs.io/en/latest/example.html) for
|
|
74
|
+
more.
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
FPy can be installed from PyPI with either `uv` or `pip`, or built from
|
|
79
|
+
source for development. The following instructions assume a `bash`-like
|
|
80
|
+
shell.
|
|
81
|
+
|
|
82
|
+
### Installing from PyPI
|
|
83
|
+
|
|
84
|
+
Requirements:
|
|
85
|
+
- Python 3.11 or later
|
|
86
|
+
|
|
87
|
+
To install the latest stable release of FPy, run:
|
|
88
|
+
```bash
|
|
89
|
+
uv pip install fpy2
|
|
90
|
+
```
|
|
91
|
+
or, with `pip`:
|
|
92
|
+
```bash
|
|
93
|
+
pip install fpy2
|
|
94
|
+
```
|
|
95
|
+
The Triton backend also needs PyTorch, Triton and a GPU: install `fpy2[triton]`.
|
|
96
|
+
|
|
97
|
+
### Installing from source
|
|
98
|
+
|
|
99
|
+
Requirements:
|
|
100
|
+
- Python 3.11 or later
|
|
101
|
+
- `make`
|
|
102
|
+
|
|
103
|
+
#### With `uv` (preferred)
|
|
104
|
+
|
|
105
|
+
[uv](https://docs.astral.sh/uv/) is the recommended development
|
|
106
|
+
workflow — it handles the virtual environment and dependency
|
|
107
|
+
installation in a single step:
|
|
108
|
+
```bash
|
|
109
|
+
uv sync
|
|
110
|
+
```
|
|
111
|
+
This creates `.venv/` and installs FPy in editable mode along with the
|
|
112
|
+
`dev` dependency group, pinned by `uv.lock`. Rerun it to reset `.venv/` to
|
|
113
|
+
the lockfile; it removes anything installed by hand. Activate the
|
|
114
|
+
environment with
|
|
115
|
+
```bash
|
|
116
|
+
source .venv/bin/activate
|
|
117
|
+
```
|
|
118
|
+
or prefix individual commands with `uv run` (e.g. `uv run pytest tests/unit`).
|
|
119
|
+
|
|
120
|
+
#### With `pip` (legacy)
|
|
121
|
+
|
|
122
|
+
This path is preserved for compatibility with existing tooling; new
|
|
123
|
+
contributors should prefer `uv` above.
|
|
124
|
+
|
|
125
|
+
If you do not have a Python virtual environment,
|
|
126
|
+
create one using
|
|
127
|
+
```bash
|
|
128
|
+
python3 -m venv .venv/
|
|
129
|
+
```
|
|
130
|
+
and activate it using
|
|
131
|
+
```bash
|
|
132
|
+
source .venv/bin/activate
|
|
133
|
+
```
|
|
134
|
+
To install an instance of FPy for development, run:
|
|
135
|
+
```bash
|
|
136
|
+
pip install -e .[dev]
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
To uninstall FPy, run:
|
|
140
|
+
```bash
|
|
141
|
+
pip uninstall fpy2
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Testing
|
|
145
|
+
|
|
146
|
+
There are a number of tests that can be run through
|
|
147
|
+
the `Makefile` including
|
|
148
|
+
```bash
|
|
149
|
+
make lint
|
|
150
|
+
```
|
|
151
|
+
to ensure formatting and type safety;
|
|
152
|
+
```bash
|
|
153
|
+
make unittest
|
|
154
|
+
```
|
|
155
|
+
to run the unit tests;
|
|
156
|
+
```bash
|
|
157
|
+
make infratest
|
|
158
|
+
```
|
|
159
|
+
to run the infrastructure tests.
|
|
@@ -19,19 +19,31 @@ These number systems guarantee correct rounding via MPFR.
|
|
|
19
19
|
# base library
|
|
20
20
|
# standard library
|
|
21
21
|
# submodules
|
|
22
|
-
from . import
|
|
22
|
+
from . import (
|
|
23
|
+
analysis,
|
|
24
|
+
ast,
|
|
25
|
+
libraries,
|
|
26
|
+
number,
|
|
27
|
+
rewrite,
|
|
28
|
+
strategies,
|
|
29
|
+
transform,
|
|
30
|
+
types,
|
|
31
|
+
utils,
|
|
32
|
+
)
|
|
23
33
|
|
|
24
34
|
# compiler
|
|
25
35
|
from .backend import (
|
|
26
36
|
Backend,
|
|
27
37
|
CppCompiler,
|
|
28
38
|
FPCoreCompiler,
|
|
39
|
+
TritonCompiler,
|
|
29
40
|
)
|
|
30
41
|
|
|
31
42
|
# runtime support
|
|
32
43
|
from .fpc_context import FPCoreContext, NoSuchContextError
|
|
33
44
|
from .interpret import (
|
|
34
45
|
BytecodeInterpreter,
|
|
46
|
+
Foreign,
|
|
35
47
|
Interpreter,
|
|
36
48
|
get_default_interpreter,
|
|
37
49
|
set_default_interpreter,
|
|
@@ -40,6 +52,7 @@ from .libraries.base import *
|
|
|
40
52
|
|
|
41
53
|
# module
|
|
42
54
|
from .module import Module, ModuleCallGraph, ModuleEntry
|
|
55
|
+
from .rewrite import Rewrite, find, find_all
|
|
43
56
|
|
|
44
57
|
# runner
|
|
45
58
|
from .runner import Runner, RunnerWorkerTask
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Program analyses for FPy programs"""
|
|
2
2
|
|
|
3
|
-
from .alias import Alias, AliasAnalysis, AllocSite
|
|
3
|
+
from .alias import Alias, AliasAnalysis, AllocSite, Region, region_sizes
|
|
4
4
|
from .array_size import (
|
|
5
5
|
ArraySize,
|
|
6
6
|
ArraySizeAnalysis,
|
|
@@ -9,6 +9,7 @@ from .array_size import (
|
|
|
9
9
|
ListSize,
|
|
10
10
|
TupleSize,
|
|
11
11
|
concrete_size,
|
|
12
|
+
static_trip_count,
|
|
12
13
|
)
|
|
13
14
|
from .call_graph import CallGraph, CallGraphAnalysis, CallGraphError
|
|
14
15
|
from .context_use import (
|
|
@@ -17,13 +18,16 @@ from .context_use import (
|
|
|
17
18
|
ContextUse,
|
|
18
19
|
ContextUseAnalysis,
|
|
19
20
|
ContextUseSite,
|
|
21
|
+
PartialContext,
|
|
22
|
+
ScopeContext,
|
|
20
23
|
)
|
|
21
24
|
from .define_use import DefCtx, DefineUse, DefineUseAnalysis, UseSite
|
|
22
25
|
from .defs import DefAnalysis
|
|
23
26
|
from .escape import Escape, EscapeSummary
|
|
24
27
|
from .format_infer import FormatAnalysis, FormatInfer
|
|
28
|
+
from .hoistability import Hoistability, HoistabilityAnalysis
|
|
25
29
|
from .live_vars import LiveVars
|
|
26
|
-
from .partial_eval import PartialEval, PartialEvalInfo
|
|
30
|
+
from .partial_eval import PartialEval, PartialEvalInfo, base_env
|
|
27
31
|
from .purity import Purity
|
|
28
32
|
from .reachability import Reachability
|
|
29
33
|
from .reaching_defs import (
|
|
@@ -35,6 +39,13 @@ from .reaching_defs import (
|
|
|
35
39
|
ReachingDefs,
|
|
36
40
|
ReachingDefsAnalysis,
|
|
37
41
|
)
|
|
42
|
+
from .storage_infer import (
|
|
43
|
+
StorageAnalysis,
|
|
44
|
+
StorageDomain,
|
|
45
|
+
StorageInfer,
|
|
46
|
+
StorageSelectionError,
|
|
47
|
+
of_bound,
|
|
48
|
+
)
|
|
38
49
|
from .syntax_check import FPySyntaxError, SyntaxCheck
|
|
39
50
|
from .type_infer import TypeAnalysis, TypeInfer, TypeInferError
|
|
40
51
|
from .value_class import (
|