Skip to main content

BackendSlot

Struct BackendSlot 

Source
pub struct BackendSlot;
Expand description

Generic Backend slot. Carries the ai.onnx v1 DSL catalog (48 methods). Outputs are typed &TYPE_TENSOR_F32. The BackendSubgraph carrier is compiler-emitted, not a DSL method.

Implementations§

Source§

impl BackendSlot

Source

pub fn zeros(&self, g: &mut Graph, dims: Vec<i64>) -> Output

Zeros(dims) - zero-initialized tensor of given shape.

Source

pub fn ones(&self, g: &mut Graph, dims: Vec<i64>) -> Output

Ones(dims) - one-initialized tensor of given shape.

Source

pub fn constant(&self, g: &mut Graph, value: TensorProto) -> Output

Constant(value) - embedded literal tensor.

Source

pub fn add(&self, g: &mut Graph, a: Output, b: Output) -> Output

Add - element-wise a + b.

Source

pub fn sub(&self, g: &mut Graph, a: Output, b: Output) -> Output

Sub - element-wise a - b.

Source

pub fn mul(&self, g: &mut Graph, a: Output, b: Output) -> Output

Mul - element-wise a * b.

Source

pub fn div(&self, g: &mut Graph, a: Output, b: Output) -> Output

Div - element-wise a / b.

Source

pub fn neg(&self, g: &mut Graph, t: Output) -> Output

Neg - element-wise negation.

Source

pub fn abs(&self, g: &mut Graph, t: Output) -> Output

Abs - element-wise absolute value.

Source

pub fn sqrt(&self, g: &mut Graph, t: Output) -> Output

Sqrt - element-wise square root.

Source

pub fn exp(&self, g: &mut Graph, t: Output) -> Output

Exp - element-wise natural exponential.

Source

pub fn log(&self, g: &mut Graph, t: Output) -> Output

Log - element-wise natural logarithm.

Source

pub fn pow(&self, g: &mut Graph, a: Output, b: Output) -> Output

Pow - element-wise a ** b.

Source

pub fn matmul(&self, g: &mut Graph, a: Output, b: Output) -> Output

MatMul - matrix multiplication (canonical example).

Source

pub fn gemm( &self, g: &mut Graph, a: Output, b: Output, c: Option<Output>, alpha: f32, beta: f32, trans_a: bool, trans_b: bool, ) -> Output

Gemm - alpha * (a @ b) + beta * c with optional transpose.

Source

pub fn dot(&self, g: &mut Graph, a: Output, b: Output) -> Output

Dot - dot product (reduces along last axis for higher rank).

Source

pub fn relu(&self, g: &mut Graph, t: Output) -> Output

Relu - max(0, x).

Source

pub fn sigmoid(&self, g: &mut Graph, t: Output) -> Output

Sigmoid - 1 / (1 + exp(-x)).

Source

pub fn tanh(&self, g: &mut Graph, t: Output) -> Output

Tanh - hyperbolic tangent.

Source

pub fn softmax(&self, g: &mut Graph, t: Output, axis: i64) -> Output

Softmax(axis) - softmax along the given axis.

Source

pub fn leaky_relu(&self, g: &mut Graph, t: Output, alpha: f32) -> Output

LeakyRelu(alpha) - x if x > 0 else alpha * x.

Source

pub fn gelu(&self, g: &mut Graph, t: Output) -> Output

Gelu - Gaussian Error Linear Unit.

Source

pub fn reshape(&self, g: &mut Graph, t: Output, dims: Vec<i64>) -> Output

Reshape(dims) - reshape to given dims.

Source

pub fn transpose( &self, g: &mut Graph, t: Output, perm: Option<Vec<i64>>, ) -> Output

Transpose(perm) - None reverses all dims.

Source

pub fn concat(&self, g: &mut Graph, tensors: Vec<Output>, axis: i64) -> Output

Concat(axis) - concatenate tensors along axis.

Source

pub fn split( &self, g: &mut Graph, t: Output, axis: i64, sizes: Vec<i64>, ) -> Vec<Output>

Split(axis, sizes) - split into N parts. Returns one Output per size.

Source

pub fn slice( &self, g: &mut Graph, t: Output, starts: Vec<i64>, ends: Vec<i64>, axes: Option<Vec<i64>>, steps: Option<Vec<i64>>, ) -> Output

Slice(starts, ends, axes?, steps?) - NumPy-style slice.

Source

pub fn squeeze( &self, g: &mut Graph, t: Output, axes: Option<Vec<i64>>, ) -> Output

Squeeze(axes?) - remove length-1 dimensions.

Source

pub fn unsqueeze(&self, g: &mut Graph, t: Output, axes: Vec<i64>) -> Output

Unsqueeze(axes) - insert length-1 dimensions.

Source

pub fn identity(&self, g: &mut Graph, t: Output) -> Output

Identity - clone pass-through.

Source

pub fn cast(&self, g: &mut Graph, t: Output, to_elem_type: i32) -> Output

Cast(to) - cast to the given ONNX DataType enum value.

Source

pub fn reduce_sum( &self, g: &mut Graph, t: Output, axes: Option<Vec<i64>>, keepdims: bool, ) -> Output

ReduceSum(axes?, keepdims).

Source

pub fn reduce_mean( &self, g: &mut Graph, t: Output, axes: Option<Vec<i64>>, keepdims: bool, ) -> Output

ReduceMean(axes?, keepdims).

Source

pub fn reduce_max( &self, g: &mut Graph, t: Output, axes: Option<Vec<i64>>, keepdims: bool, ) -> Output

ReduceMax(axes?, keepdims).

Source

pub fn reduce_min( &self, g: &mut Graph, t: Output, axes: Option<Vec<i64>>, keepdims: bool, ) -> Output

ReduceMin(axes?, keepdims).

Source

pub fn equal(&self, g: &mut Graph, a: Output, b: Output) -> Output

Equal - element-wise a == b (bool tensor).

Source

pub fn greater(&self, g: &mut Graph, a: Output, b: Output) -> Output

Greater - element-wise a > b (bool tensor).

Source

pub fn less(&self, g: &mut Graph, a: Output, b: Output) -> Output

Less - element-wise a < b (bool tensor).

Source

pub fn batch_normalization( &self, g: &mut Graph, input: Output, scale: Output, bias: Output, mean: Output, variance: Output, epsilon: f32, momentum: f32, ) -> Output

BatchNormalization(epsilon, momentum).

Source

pub fn layer_normalization( &self, g: &mut Graph, input: Output, scale: Output, bias: Option<Output>, axis: i64, epsilon: f32, ) -> Output

LayerNormalization(axis, epsilon).

Source

pub fn conv( &self, g: &mut Graph, input: Output, weight: Output, bias: Option<Output>, kernel_shape: Vec<i64>, strides: Vec<i64>, pads: Vec<i64>, dilations: Vec<i64>, group: i64, ) -> Output

Conv(kernel_shape, strides, pads, dilations, group).

Source

pub fn max_pool( &self, g: &mut Graph, input: Output, kernel_shape: Vec<i64>, strides: Vec<i64>, pads: Vec<i64>, ) -> Output

MaxPool(kernel_shape, strides, pads).

Source

pub fn average_pool( &self, g: &mut Graph, input: Output, kernel_shape: Vec<i64>, strides: Vec<i64>, pads: Vec<i64>, count_include_pad: bool, ) -> Output

AveragePool(kernel_shape, strides, pads, count_include_pad).

Source

pub fn global_average_pool(&self, g: &mut Graph, input: Output) -> Output

GlobalAveragePool - collapse spatial dims to length 1.

Source

pub fn gather( &self, g: &mut Graph, data: Output, indices: Output, axis: i64, ) -> Output

Gather(axis).

Source

pub fn scatter( &self, g: &mut Graph, data: Output, indices: Output, updates: Output, axis: i64, ) -> Output

Scatter(axis).

Source

pub fn if_op( &self, g: &mut Graph, cond: Output, then_branch: GraphProto, else_branch: GraphProto, n_outputs: usize, ) -> Vec<Output>

If(then_branch, else_branch) - both branches are sub-graphs carried on AttributeProto.g per IR_AND_DSL.md Part 2 line 80. Returns one Output per branch output.

Source

pub fn loop_op( &self, g: &mut Graph, max_trip_count: Option<Output>, cond: Option<Output>, body: GraphProto, initial: Vec<Output>, n_outputs: usize, ) -> Vec<Output>

Loop(body) - execute body until cond becomes false or max_trip_count is reached.

Trait Implementations§

Source§

impl Clone for BackendSlot

Source§

fn clone(&self) -> BackendSlot

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for BackendSlot

Source§

impl Debug for BackendSlot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BackendSlot

Source§

fn default() -> BackendSlot

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedComponent for T
where T: Any + Send + Sync,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more