(expr: Expr, stage: OptimizerStage)
| 921 | |
| 922 | |
| 923 | def optimize_until(expr: Expr, stage: OptimizerStage) -> Expr: |
| 924 | result = expr |
| 925 | if stage == "logical": |
| 926 | return result |
| 927 | |
| 928 | # Simplify |
| 929 | expr = result.simplify() |
| 930 | if stage == "simplified-logical": |
| 931 | return expr |
| 932 | |
| 933 | # Manipulate Expression to make it more efficient |
| 934 | if dask.config.get("optimization.tune.active", True): |
| 935 | expr = expr.rewrite(kind="tune", rewritten={}) |
| 936 | if stage == "tuned-logical": |
| 937 | return expr |
| 938 | |
| 939 | # Lower |
| 940 | expr = expr.lower_completely() |
| 941 | if stage == "physical": |
| 942 | return expr |
| 943 | |
| 944 | # Simplify again |
| 945 | expr = expr.simplify() |
| 946 | if stage == "simplified-physical": |
| 947 | return expr |
| 948 | |
| 949 | # Final graph-specific optimizations |
| 950 | expr = expr.fuse() |
| 951 | if stage == "fused": |
| 952 | return expr |
| 953 | |
| 954 | raise ValueError(f"Stage {stage!r} not supported.") |
| 955 | |
| 956 | |
| 957 | class LLGExpr(Expr): |
no test coverage detected
searching dependent graphs…