Skip to main content

Module memory_estimation

Module memory_estimation 

Source
Expand description

Memory estimation for tensor expressions.

This module provides tools for estimating the memory footprint of compiled tensor expressions. This is useful for:

  • Planning batch sizes
  • Deciding on execution strategies
  • GPU memory allocation
  • Optimization decisions

§Usage

use tensorlogic_compiler::optimize::{estimate_memory, MemoryEstimate};
use tensorlogic_compiler::CompilerContext;
use tensorlogic_ir::{TLExpr, Term};

let mut ctx = CompilerContext::new();
ctx.add_domain("Person", 1000);
ctx.add_domain("Thing", 500);

let expr = TLExpr::pred("knows", vec![Term::var("x"), Term::var("y")]);
let estimate = estimate_memory(&expr, &ctx);

println!("Estimated memory: {} bytes", estimate.total_bytes);
println!("Peak memory: {} bytes", estimate.peak_bytes);

Structs§

MemoryEstimate
Detailed memory estimate for an expression.

Functions§

estimate_batch_memory
Estimate memory for a batch of similar expressions.
estimate_memory
Estimate memory usage for an expression.