pub struct KernelIrBuilder { /* private fields */ }Expand description
Builder for appending type-checked instructions to existing scalar IR.
Implementations§
Source§impl KernelIrBuilder
impl KernelIrBuilder
Sourcepub fn from_scalar(ir: &ScalarKernelIr) -> Self
pub fn from_scalar(ir: &ScalarKernelIr) -> Self
Creates a builder initialized with a scalar kernel’s values.
Sourcepub fn push(
&mut self,
instruction: KernelInstruction,
) -> Result<KernelValueId, KernelIrError>
pub fn push( &mut self, instruction: KernelInstruction, ) -> Result<KernelValueId, KernelIrError>
Appends an instruction after validating its operands and inferred type.
§Errors
Returns KernelIrError when an operand does not precede the new
instruction, the operand shapes are incompatible, or the instruction’s
value kind cannot be inferred.
Sourcepub fn finish_gradient(
self,
primal_root: KernelValueId,
outputs: Vec<KernelValueId>,
component: OutputComponent,
) -> Result<GradientKernelIr, KernelIrError>
pub fn finish_gradient( self, primal_root: KernelValueId, outputs: Vec<KernelValueId>, component: OutputComponent, ) -> Result<GradientKernelIr, KernelIrError>
Finishes the builder as a validated gradient kernel.
§Errors
Returns KernelIrError when the accumulated primal IR is invalid,
primal_root is not scalar, a gradient output is out of bounds, or a
gradient output is not real-valued.
Sourcepub fn values(&self) -> &[KernelValue]
pub fn values(&self) -> &[KernelValue]
Returns the values accumulated so far.
Trait Implementations§
Source§impl Clone for KernelIrBuilder
impl Clone for KernelIrBuilder
Source§fn clone(&self) -> KernelIrBuilder
fn clone(&self) -> KernelIrBuilder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for KernelIrBuilder
impl RefUnwindSafe for KernelIrBuilder
impl Send for KernelIrBuilder
impl Sync for KernelIrBuilder
impl Unpin for KernelIrBuilder
impl UnsafeUnpin for KernelIrBuilder
impl UnwindSafe for KernelIrBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more