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.});
});

Implementations

Sets input tensors. See also Input.

Sets input tensors (vector). See also Input.

Sets inputs for backprop.

Not required unless backprop-inputs are differs from normal-case inputs

Finalizes this builder and creates a tensor with given Op in the graph.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.