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.
Files changed (230) hide show
  1. fpy2-0.2.4/PKG-INFO +190 -0
  2. fpy2-0.2.4/README.md +159 -0
  3. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/__init__.py +14 -1
  4. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/__init__.py +13 -2
  5. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/alias.py +324 -12
  6. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/array_size.py +309 -88
  7. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/call_graph.py +0 -6
  8. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/context_use.py +102 -20
  9. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/define_use.py +30 -4
  10. fpy2-0.2.4/fpy2/analysis/digit_bound/__init__.py +34 -0
  11. fpy2-0.2.4/fpy2/analysis/digit_bound/infer.py +1778 -0
  12. fpy2-0.2.4/fpy2/analysis/digit_bound/solver.py +419 -0
  13. fpy2-0.2.4/fpy2/analysis/digit_bound/store.py +265 -0
  14. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/format_infer/__init__.py +20 -0
  15. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/format_infer/analysis.py +749 -191
  16. fpy2-0.2.4/fpy2/analysis/format_infer/double_round.py +288 -0
  17. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/format_infer/format.py +168 -68
  18. fpy2-0.2.4/fpy2/analysis/hoistability.py +228 -0
  19. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/live_vars.py +2 -0
  20. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/partial_eval.py +37 -44
  21. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/purity.py +0 -4
  22. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/reachability.py +20 -9
  23. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/reaching_defs.py +37 -1
  24. fpy2-0.2.4/fpy2/analysis/storage_infer.py +418 -0
  25. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/syntax_check.py +55 -6
  26. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/type_infer.py +4 -4
  27. fpy2-0.2.4/fpy2/analysis/value_class.py +1975 -0
  28. fpy2-0.2.4/fpy2/ast/accessors.py +149 -0
  29. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/ast/fpyast.py +16 -6
  30. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/ast/visitor.py +2 -0
  31. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/__init__.py +3 -0
  32. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/compiler.py +285 -61
  33. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/emitter.py +1065 -575
  34. fpy2-0.2.4/fpy2/backend/cpp/storage.py +286 -0
  35. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/target.py +58 -30
  36. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/types.py +16 -0
  37. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/unbox.py +70 -164
  38. fpy2-0.2.4/fpy2/backend/cpp/unfold_round.py +72 -0
  39. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/utils.py +4 -1
  40. fpy2-0.2.2/fpy2/backend/cpp/storage_infer.py → fpy2-0.2.4/fpy2/backend/cpp/variables.py +119 -199
  41. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/fpc.py +46 -36
  42. fpy2-0.2.4/fpy2/backend/triton/__init__.py +47 -0
  43. fpy2-0.2.4/fpy2/backend/triton/compiler.py +167 -0
  44. fpy2-0.2.4/fpy2/backend/triton/emitter.py +2895 -0
  45. fpy2-0.2.4/fpy2/backend/triton/launcher.py +265 -0
  46. fpy2-0.2.4/fpy2/backend/triton/normalize.py +131 -0
  47. fpy2-0.2.4/fpy2/backend/triton/split_names.py +84 -0
  48. fpy2-0.2.4/fpy2/backend/triton/storage.py +196 -0
  49. fpy2-0.2.4/fpy2/backend/triton/target.py +258 -0
  50. fpy2-0.2.4/fpy2/backend/triton/types.py +92 -0
  51. fpy2-0.2.4/fpy2/backend/triton/unfold_round.py +109 -0
  52. fpy2-0.2.4/fpy2/backend/triton/vectorize.py +471 -0
  53. fpy2-0.2.4/fpy2/backend/unfold_round.py +308 -0
  54. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/decorator.py +26 -3
  55. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/function.py +62 -2
  56. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/interpret/__init__.py +1 -0
  57. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/interpret/byte.py +102 -83
  58. fpy2-0.2.4/fpy2/interpret/value.py +174 -0
  59. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/__init__.py +1 -1
  60. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/context.py +21 -1
  61. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/efloat.py +18 -14
  62. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/exponential.py +3 -0
  63. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/mp_fixed.py +9 -11
  64. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/mp_float.py +163 -19
  65. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/mpb_fixed.py +9 -10
  66. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/mpb_float.py +168 -19
  67. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/mps_float.py +171 -19
  68. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/real.py +3 -0
  69. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/number/__init__.py +1 -1
  70. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/number/floats.py +17 -0
  71. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/number/reals.py +1 -1
  72. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/ops.py +11 -19
  73. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/primitive.py +6 -22
  74. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/rewrite/__init__.py +2 -1
  75. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/rewrite/applier.py +24 -29
  76. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/rewrite/matcher.py +60 -102
  77. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/rewrite/pattern.py +10 -0
  78. fpy2-0.2.4/fpy2/rewrite/rewrite.py +313 -0
  79. fpy2-0.2.4/fpy2/rewrite/search.py +120 -0
  80. fpy2-0.2.4/fpy2/strategies/__init__.py +112 -0
  81. fpy2-0.2.4/fpy2/strategies/anf.py +69 -0
  82. fpy2-0.2.4/fpy2/strategies/assert_elim.py +55 -0
  83. fpy2-0.2.4/fpy2/strategies/comp_lower.py +108 -0
  84. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/context_lift.py +1 -2
  85. fpy2-0.2.4/fpy2/strategies/exit_single.py +78 -0
  86. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/fixed_rescale.py +31 -21
  87. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/float_lower.py +36 -30
  88. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/free_var.py +1 -2
  89. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/func_inline.py +13 -8
  90. fpy2-0.2.4/fpy2/strategies/hoistable.py +85 -0
  91. fpy2-0.2.4/fpy2/strategies/if_simplify.py +78 -0
  92. fpy2-0.2.4/fpy2/strategies/invariant_hoist.py +121 -0
  93. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/iter_elim.py +3 -0
  94. fpy2-0.2.4/fpy2/strategies/iter_unfold.py +166 -0
  95. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/loop_split.py +44 -10
  96. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/loop_unroll.py +29 -15
  97. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/mono.py +1 -2
  98. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/neg_zero_unfold.py +28 -21
  99. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/overflow_unfold.py +35 -39
  100. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/reduce_fusion.py +3 -0
  101. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/round_elim.py +3 -0
  102. fpy2-0.2.4/fpy2/strategies/round_insert.py +108 -0
  103. fpy2-0.2.4/fpy2/strategies/round_split.py +123 -0
  104. fpy2-0.2.4/fpy2/strategies/scale_hoist.py +117 -0
  105. fpy2-0.2.4/fpy2/strategies/simple.py +63 -0
  106. fpy2-0.2.4/fpy2/strategies/sites.py +240 -0
  107. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/strategies/special_unfold.py +32 -27
  108. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/__init__.py +32 -0
  109. fpy2-0.2.4/fpy2/transform/anf.py +439 -0
  110. fpy2-0.2.4/fpy2/transform/assert_elim.py +85 -0
  111. fpy2-0.2.4/fpy2/transform/comp_to_loop.py +581 -0
  112. fpy2-0.2.4/fpy2/transform/const_fold.py +408 -0
  113. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/copy_propagate.py +2 -2
  114. fpy2-0.2.4/fpy2/transform/cursor.py +440 -0
  115. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/dead_code.py +112 -25
  116. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/error.py +6 -5
  117. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/float_to_fixed.py +116 -104
  118. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/for_bundling.py +4 -1
  119. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/for_unroll.py +156 -46
  120. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/free_var_elim.py +13 -2
  121. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/func_inline.py +157 -57
  122. fpy2-0.2.4/fpy2/transform/hoist_invariant.py +581 -0
  123. fpy2-0.2.4/fpy2/transform/hoist_scale.py +477 -0
  124. fpy2-0.2.4/fpy2/transform/hoistable.py +431 -0
  125. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/if_bundling.py +4 -1
  126. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/iter_elim.py +1 -6
  127. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/lift_context.py +18 -1
  128. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/monomorphize.py +47 -29
  129. fpy2-0.2.4/fpy2/transform/path.py +233 -0
  130. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/reduce_fusion.py +40 -44
  131. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/rescale_fixed.py +93 -81
  132. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/round_elim.py +53 -152
  133. fpy2-0.2.4/fpy2/transform/round_insert.py +189 -0
  134. fpy2-0.2.4/fpy2/transform/simplify.py +102 -0
  135. fpy2-0.2.4/fpy2/transform/simplify_if.py +502 -0
  136. fpy2-0.2.4/fpy2/transform/single_exit.py +224 -0
  137. fpy2-0.2.4/fpy2/transform/specialize.py +858 -0
  138. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/split_loop.py +232 -56
  139. fpy2-0.2.4/fpy2/transform/split_round.py +395 -0
  140. fpy2-0.2.4/fpy2/transform/statement_form.py +50 -0
  141. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/subst_var.py +20 -1
  142. fpy2-0.2.4/fpy2/transform/unfold_iter.py +241 -0
  143. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/unfold_neg_zero.py +105 -98
  144. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/unfold_overflow.py +149 -140
  145. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/unfold_special.py +148 -128
  146. fpy2-0.2.4/fpy2/transform/unnest_context.py +187 -0
  147. fpy2-0.2.4/fpy2/transform/utils.py +915 -0
  148. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/while_bundling.py +4 -1
  149. fpy2-0.2.4/fpy2/transform/while_unroll.py +117 -0
  150. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/types.py +20 -14
  151. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/decorator.py +8 -5
  152. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/gensym.py +8 -4
  153. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/unionfind.py +2 -2
  154. fpy2-0.2.4/fpy2.egg-info/PKG-INFO +190 -0
  155. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2.egg-info/SOURCES.txt +51 -1
  156. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2.egg-info/requires.txt +4 -3
  157. {fpy2-0.2.2 → fpy2-0.2.4}/pyproject.toml +10 -4
  158. fpy2-0.2.2/PKG-INFO +0 -121
  159. fpy2-0.2.2/README.md +0 -91
  160. fpy2-0.2.2/fpy2/analysis/value_class.py +0 -707
  161. fpy2-0.2.2/fpy2/backend/cpp/storage.py +0 -266
  162. fpy2-0.2.2/fpy2/rewrite/rewrite.py +0 -235
  163. fpy2-0.2.2/fpy2/strategies/__init__.py +0 -42
  164. fpy2-0.2.2/fpy2/strategies/simple.py +0 -73
  165. fpy2-0.2.2/fpy2/transform/const_fold.py +0 -175
  166. fpy2-0.2.2/fpy2/transform/simplify_if.py +0 -181
  167. fpy2-0.2.2/fpy2/transform/specialize.py +0 -540
  168. fpy2-0.2.2/fpy2/transform/utils.py +0 -312
  169. fpy2-0.2.2/fpy2/transform/while_unroll.py +0 -111
  170. fpy2-0.2.2/fpy2.egg-info/PKG-INFO +0 -121
  171. {fpy2-0.2.2 → fpy2-0.2.4}/LICENSE +0 -0
  172. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/defs.py +0 -0
  173. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/analysis/escape.py +0 -0
  174. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/ast/__init__.py +0 -0
  175. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/ast/formatter.py +0 -0
  176. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/backend.py +0 -0
  177. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/__init__.py +0 -0
  178. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/backend/cpp/ops.py +0 -0
  179. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/env.py +0 -0
  180. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/fpc_context.py +0 -0
  181. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/frontend/__init__.py +0 -0
  182. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/frontend/fpc.py +0 -0
  183. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/frontend/parser.py +0 -0
  184. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/interpret/interpreter.py +0 -0
  185. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/__init__.py +0 -0
  186. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/base.py +0 -0
  187. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/core.py +0 -0
  188. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/eft.py +0 -0
  189. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/matrix.py +0 -0
  190. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/metrics.py +0 -0
  191. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/libraries/vector.py +0 -0
  192. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/module.py +0 -0
  193. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/__init__.py +0 -0
  194. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/fixed.py +0 -0
  195. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/format.py +0 -0
  196. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/ieee754.py +0 -0
  197. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/context/sm_fixed.py +0 -0
  198. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/engine/__init__.py +0 -0
  199. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/engine/engine.py +0 -0
  200. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/engine/gmp.py +0 -0
  201. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/engine/real.py +0 -0
  202. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/format.py +0 -0
  203. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/globals.py +0 -0
  204. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/gmputils.py +0 -0
  205. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/native.py +0 -0
  206. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/number/flags.py +0 -0
  207. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/number/round.py +0 -0
  208. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/rewrite/subst.py +0 -0
  209. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/runner.py +0 -0
  210. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/enumerate_elim.py +0 -0
  211. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/for_unpack.py +0 -0
  212. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/rename_target.py +0 -0
  213. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/transform/zip_elim.py +0 -0
  214. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/__init__.py +0 -0
  215. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/bits.py +0 -0
  216. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/compare.py +0 -0
  217. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/default.py +0 -0
  218. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/float_params.py +0 -0
  219. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/fractions.py +0 -0
  220. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/identifier.py +0 -0
  221. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/inspect.py +0 -0
  222. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/iterator.py +0 -0
  223. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/loader.py +0 -0
  224. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/location.py +0 -0
  225. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/ordering.py +0 -0
  226. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/string.py +0 -0
  227. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2/utils/uninit.py +0 -0
  228. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2.egg-info/dependency_links.txt +0 -0
  229. {fpy2-0.2.2 → fpy2-0.2.4}/fpy2.egg-info/top_level.txt +0 -0
  230. {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 analysis, ast, libraries, number, strategies, transform, types, utils
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 (