pub trait PrimitiveRuleBuilder {
// Required method
fn add_operation(
&mut self,
operation: StdTensorOp,
inputs: Vec<ValueRef<StdTensorOp>>,
role: OperationRole,
) -> Vec<LocalValueId> ⓘ;
}Expand description
Builder interface used by tenferro AD rules.
§Examples
use computegraph::graph::GraphBuilder;
use computegraph::{OperationRole, ValueRef};
use tenferro_ops::ad::PrimitiveRuleBuilder;
use tenferro_ops::input_key::TensorInputKey;
use tenferro_ops::std_tensor_op::StdTensorOp;
let mut builder = GraphBuilder::<StdTensorOp>::new();
let x = builder.add_input(TensorInputKey::User { id: 1 });
let out = PrimitiveRuleBuilder::add_operation(
&mut builder,
StdTensorOp::Neg,
vec![ValueRef::Local(x)],
OperationRole::Primary,
);
assert_eq!(out.len(), 1);Required Methods§
Sourcefn add_operation(
&mut self,
operation: StdTensorOp,
inputs: Vec<ValueRef<StdTensorOp>>,
role: OperationRole,
) -> Vec<LocalValueId> ⓘ
fn add_operation( &mut self, operation: StdTensorOp, inputs: Vec<ValueRef<StdTensorOp>>, role: OperationRole, ) -> Vec<LocalValueId> ⓘ
Add one primitive graph operation and return local ids for its outputs.
Implementations on Foreign Types§
Source§impl PrimitiveRuleBuilder for GraphBuilder<StdTensorOp>
Available on crate feature autodiff only.
impl PrimitiveRuleBuilder for GraphBuilder<StdTensorOp>
Available on crate feature
autodiff only.fn add_operation( &mut self, operation: StdTensorOp, inputs: Vec<ValueRef<StdTensorOp>>, role: OperationRole, ) -> Vec<LocalValueId> ⓘ
Implementors§
impl<B> PrimitiveRuleBuilder for Bwhere
B: PrimitiveBuilder<StdTensorOp> + ?Sized,
Available on crate feature
autodiff only.