Skip to main content

LowerCx

Trait LowerCx 

Source
pub trait LowerCx {
    // Required methods
    fn target(&self) -> Target;
    fn op(
        &mut self,
        name: &str,
        operands: &[HloValue],
        attributes: &str,
        results: &[AVal],
    ) -> Vec<HloValue>;
    fn op_with_regions(
        &mut self,
        name: &str,
        operands: &[HloValue],
        attributes: &str,
        regions: &mut [Region<'_>],
        results: &[AVal],
    ) -> Result<Vec<HloValue>>;
    fn constant(&mut self, value: &HostArray) -> HloValue;
    fn import(&mut self, module: &str, name_hint: &str) -> Result<String>;
    fn function(&mut self, f: &Function, name_hint: &str) -> Result<String>;

    // Provided method
    fn platform(&self) -> Platform { ... }
}
Expand description

A context that emits StableHLO operations.

Required Methods§

Source

fn target(&self) -> Target

Returns where the StableHLO will be compiled.

Source

fn op( &mut self, name: &str, operands: &[HloValue], attributes: &str, results: &[AVal], ) -> Vec<HloValue>

Emits an operation and returns its results.

attributes is the attribute dictionary without braces, such as broadcast_dimensions = array<i64: 1>, or empty.

Source

fn op_with_regions( &mut self, name: &str, operands: &[HloValue], attributes: &str, regions: &mut [Region<'_>], results: &[AVal], ) -> Result<Vec<HloValue>>

Emits an operation with regions and returns its results.

§Errors

Returns an error from lowering a region’s body.

Source

fn constant(&mut self, value: &HostArray) -> HloValue

Emits a constant.

Source

fn import(&mut self, module: &str, name_hint: &str) -> Result<String>

Adds the functions of another StableHLO module (such as one written by jax.export) to the module, renamed after name_hint, and returns the new symbol name of its public main (without @).

§Errors

Returns an error if the module cannot be parsed or has no main.

Source

fn function(&mut self, f: &Function, name_hint: &str) -> Result<String>

Lowers a function as a private function of the module and returns its symbol name (without @).

§Errors

Returns an error from lowering the function.

Provided Methods§

Source

fn platform(&self) -> Platform

Returns the kind of device the StableHLO is compiled for.

Implementations§

Source§

impl dyn LowerCx + '_

Source

pub fn op1( &mut self, name: &str, operands: &[HloValue], attributes: &str, result: &AVal, ) -> HloValue

Emits an operation with one result.

Source

pub fn min_max( &mut self, op: &str, a: &HloValue, b: &HloValue, aval: &AVal, ) -> HloValue

Emits stablehlo.maximum or stablehlo.minimum (given as op) with NaN propagation, which StableHLO specifies but some PJRT plugins disable by default (see Target::Pjrt).

Source

pub fn splat(&mut self, value: Value, aval: &AVal) -> HloValue

Emits a scalar constant broadcast to aval.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§