Expand description
Expression complexity analysis.
This module provides analysis tools for estimating the computational complexity of TLExpr expressions. It can estimate:
- Operation counts (additions, multiplications, etc.)
- Computational cost (weighted by operation type)
- Nesting depth
- Memory footprint estimates
§Usage
use tensorlogic_compiler::optimize::{analyze_complexity, ExpressionComplexity};
use tensorlogic_ir::{TLExpr, Term};
let x = TLExpr::pred("x", vec![Term::var("i")]);
let expr = TLExpr::mul(TLExpr::add(x, TLExpr::Constant(1.0)), TLExpr::Constant(2.0));
let complexity = analyze_complexity(&expr);
println!("Total cost: {}", complexity.total_cost());
println!("Operations: {}", complexity.total_operations());Structs§
- Cost
Weights - Cost weights for different operation types.
- Expression
Complexity - Detailed complexity analysis of an expression.
Functions§
- analyze_
complexity - Analyze the complexity of an expression.
- compare_
complexity - Compare two expressions by their complexity.