Skip to main content

Module shape_inference

Module shape_inference 

Source
Expand description

Static shape inference for tensor operation graphs.

Provides TensorShapeInference which computes output shapes for common tensor operations (broadcast, matmul, reshape, transpose, concat, slice) following NumPy-compatible broadcasting rules.

§Examples

use ipfrs_tensorlogic::shape_inference::{TensorShapeInference, TensorShape, ShapeOp, InferenceRule};
use std::collections::HashMap;

let mut engine = TensorShapeInference::new();

// Matrix multiply (3,4) x (4,5) -> (3,5)
let rule = InferenceRule {
    op: ShapeOp::MatMul,
    input_shapes: vec![
        TensorShape { dims: vec![3, 4] },
        TensorShape { dims: vec![4, 5] },
    ],
    params: HashMap::new(),
};
let result = engine.infer(&rule).expect("example: should succeed in docs");
assert_eq!(result.dims, vec![3, 5]);

Structs§

InferenceRule
An inference rule: an operation together with its input shapes and optional parameters.
ShapeInferenceStats
Statistics collected by TensorShapeInference.
TensorShape
Shape descriptor for a tensor.
TensorShapeInference
Static shape inference engine for tensor operation graphs.

Enums§

ShapeOp
Supported tensor operations for shape inference.