Struct autograd::tensor::TensorBuilder [−][src]
pub struct TensorBuilder<F: Float> { /* fields omitted */ }
Expand description
Builder for ag::Tensor
returned by Tensor::builder.
This structure is required only when constructing user-defined Op
.
use autograd as ag;
use ag::tensor::Input;
struct DummyOp {
a: f32
}
impl ag::op::Op<f32> for DummyOp {
fn compute(&self, _: &mut ag::op::ComputeContext<f32>) {}
fn grad(&self, _: &mut ag::op::GradientContext<f32>) {}
}
ag::with(|g: &mut ag::Graph<f32>| {
let input = &g.zeros(&[0]);
let my_output: ag::Tensor<_> = ag::Tensor::builder()
.set_inputs(&[
Input::new(input), // immutable input
Input::new_mut(input) // mutable input
])
.build(g, DummyOp {a: 42.});
});