Skip to main content

lower_to_stablehlo

Function lower_to_stablehlo 

Source
pub fn lower_to_stablehlo(program: &SemanticProgram) -> Result<StableHloModule>
Expand description

Lower a static-shaped graph program to StableHLO MLIR text.

§Examples

use tenferro_runtime::{GraphCompiler, TracedTensor};
use tenferro_xla::lower_to_stablehlo;

let x = TracedTensor::from_vec_col_major(vec![1], vec![3.0_f64]).unwrap();
let mut compiler = GraphCompiler::new();
let y = x.neg().unwrap();
let program = compiler.compile(&y).unwrap();
let module = lower_to_stablehlo(program.program()).unwrap();
assert!(module.as_str().contains("stablehlo.negate"));

§Errors

Returns Error::UnsupportedDType, Error::UnsupportedOp, or Error::NonStaticShape for unsupported graph content, and Error::InvalidProgram for inconsistent graph metadata.