Skip to main content

Module ops

Module ops 

Source
Expand description

Op-builder helper enums — the variants the graph builder methods (g.binary, g.compare, g.activation, g.attention_kind, …) take as their first argument, plus the fused-chain primitives used by Op::ElementwiseRegion.

use rlx::{Graph, GraphExt, Shape, DType};
use rlx::ops::{Activation, BinaryOp};

let mut g = Graph::new("ex");
let x = g.input("x", Shape::new(&[4], DType::F32));
let y = g.input("y", Shape::new(&[4], DType::F32));
let s = g.binary(BinaryOp::Add, x, y, Shape::new(&[4], DType::F32));
let r = g.activation(Activation::Silu, s, Shape::new(&[4], DType::F32));
let scaled = g.mul(x, g.constant(2.0, DType::F32));
g.set_outputs(vec![r, scaled]);

Enums§

Activation
Unary element-wise activation functions.
BinaryOp
Binary element-wise operations.
ChainOperand
An operand inside a fused ChainStep — either a graph-level input to the Op::ElementwiseRegion (by index 0..num_inputs) or the result of a previous step in the chain (by index 0..step_position).
ChainStep
One step in a fused element-wise chain. Each step produces exactly one scalar result (per element); later steps can refer to it via ChainOperand::Step. The whole chain runs per element in registers.
CmpOp
Comparison operations (return Bool tensor).
MaskKind
What kind of attention mask the kernel should apply.