Lambda and Variable Expressions and BoundExpressions - #9257
Conversation
Merging this PR will degrade performance by 1.18%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | compress_fsst[(1000, 64, 8)] |
1 ms | 1.2 ms | -12.2% |
| ⚡ | Simulation | eq_pushdown_low_match |
1.6 ms | 1.4 ms | +11.22% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing mk/lambda-variables (09e0c14) with develop (204d1d4)2
Footnotes
-
89 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
No successful run was found on
develop(f8d4db9) during the generation of this report, so 204d1d4 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
e41b484 to
c077107
Compare
Lambda and Variable Expressions and BoundExpressions
752dc14 to
1ce48c3
Compare
893ab28 to
1fb9ad6
Compare
| use crate::expr::analysis::BooleanLabels; | ||
| use crate::expr::label_tree; | ||
|
|
||
| pub fn label_is_fallible(expr: &Expression) -> BooleanLabels<'_> { |
There was a problem hiding this comment.
We should expand this doc str its all about well typed expressions
| return if expr.is_root() { | ||
| scope.names().iter().cloned().collect() | ||
| } else { | ||
| vec![] |
There was a problem hiding this comment.
I am not sure about this?
| match self { | ||
| BoundExpression::Scalar { children, .. } => f(&mut children.iter()), | ||
| BoundExpression::Root { .. } => f(&mut std::iter::empty()), | ||
| _ => f(&mut std::iter::empty()), |
There was a problem hiding this comment.
can you leave this enum as closed?
| pub struct BoundLambda { | ||
| /// The parameters and their dtypes: the argument side of the function type. | ||
| params: Box<[Variable]>, | ||
| param_dtypes: Box<[DType]>, | ||
| body: Arc<BoundExpression>, | ||
| } | ||
|
|
||
| impl BoundLambda { | ||
| /// The variables this lambda binds, in declaration order. | ||
| pub fn params(&self) -> &[Variable] { |
There was a problem hiding this comment.
How do I use this it its not a BoundExpression?
|
|
||
| /// The name of a value bound in a [`Scope`](crate::expr::Scope). | ||
| #[derive(Clone, Debug)] | ||
| pub struct Variable(Arc<str>); |
There was a problem hiding this comment.
I think need to be able to go from a series of FieldNames to a series of Variable efficently. Does this allow that?
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
…ialization docs Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Variable and Lambda get reserved expression ids alongside Root, so the unbound tree stays fully serializable. Variable carries its name in VariableOpts; Lambda carries its params in LambdaOpts and its body as its single proto child. All three reserved ids resolve before the registry lookup. Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
9f63521 to
09e0c14
Compare
Add
Variableexpressions and standalone lambda syntax for future higher-order functions.Variablereferences andScopebindings (name -> dtype), rejecting duplicate names.BoundExpression::Variablenodes.LambdaandBoundLambdaas callable syntax/types owned by higher-order functions.Lambdas are deliberately not
Expressionvariants: they do not have an array dtype or genericarray-execution semantics.
Expressionmachinery focused on array values: scalar functions, root, andvariables.
binding coverage.
available.
This establishes the type/binding representation; a future HOF vtable will supply parameter dtypes,
bind and optimize the lambda body, and evaluate it against its parameter arrays.