Skip to main content

ScGraphBuilder

Struct ScGraphBuilder 

Source
pub struct ScGraphBuilder {
    graph: ScGraph,
}
Expand description

Builder for constructing ScGraph instances.

Fields§

§graph: ScGraph

Implementations§

Source§

impl ScGraphBuilder

Source

pub fn new(name: impl Into<String>) -> Self

Start building a new graph with the given module name.

Source

pub fn input(&mut self, name: impl Into<String>, ty: ScType) -> ValueId

Add a module input port.

Source

pub fn output(&mut self, name: impl Into<String>, source: ValueId) -> ValueId

Add a module output port.

Source

pub fn constant(&mut self, value: ScConst, ty: ScType) -> ValueId

Add a compile-time constant.

Source

pub fn encode(&mut self, prob: ValueId, length: usize, seed: u16) -> ValueId

Add a bitstream encode operation.

Source

pub fn bitwise_and(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Add a bitwise AND (stochastic multiply).

Source

pub fn popcount(&mut self, input: ValueId) -> ValueId

Add a popcount operation.

Source

pub fn lif_step( &mut self, current: ValueId, leak: ValueId, gain: ValueId, noise: ValueId, params: LifParams, ) -> ValueId

Add a LIF neuron step.

Source

pub fn dense_forward( &mut self, inputs: ValueId, weights: ValueId, leak: ValueId, gain: ValueId, params: DenseParams, ) -> ValueId

Add a dense SC layer forward pass.

Source

pub fn bitwise_xor(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Add a bitwise XOR (HDC binding).

Source

pub fn reduce(&mut self, input: ValueId, mode: ReduceMode) -> ValueId

Add a reduce operation (Sum or Max).

Source

pub fn graph_forward( &mut self, features: ValueId, adjacency: ValueId, n_nodes: usize, n_features: usize, ) -> ValueId

Add a graph forward pass.

Source

pub fn softmax_attention( &mut self, q: ValueId, k: ValueId, v: ValueId, dim_k: usize, ) -> ValueId

Add a softmax attention operation.

Source

pub fn kuramoto_step( &mut self, phases: ValueId, omega: ValueId, coupling: ValueId, dt: f64, ) -> ValueId

Add a Kuramoto integration step.

Source

pub fn scale(&mut self, input: ValueId, factor: f64) -> ValueId

Add a scale (multiply by constant) operation.

Source

pub fn offset(&mut self, input: ValueId, offset_val: f64) -> ValueId

Add an offset (add constant) operation.

Source

pub fn div_const(&mut self, input: ValueId, divisor: u64) -> ValueId

Add a constant integer division.

Source

pub fn build(self) -> ScGraph

Consume the builder and return the completed graph.

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Ungil for T
where T: Send,