pub fn build<O>(self, op: O) -> Tensor<'graph, F>
    where
        O: op::Op<F> + 'static,
    {
        let graph = self.graph;
        let rank = if self.in_nodes.is_empty() {
            0
        } else {
            self.in_nodes
                .iter()
                .map(|a| graph.access_inner(a.id).topo_rank)
                .max()
                .map(|a| a + 1)
                .unwrap_or(0)
        };

        let input_indices = if let Some(a) = self.input_indices {
            assert_eq!(
                a.len(),
                self.in_nodes.len(),
                "input_indices.len() must match inputs length"
            );
            a
        } else {
            smallvec::smallvec!(0; self.in_nodes.len())
        };

        let new = TensorInternal {
            // `id` is set in `Graph::install`
            id: usize::default(),
            op: Some(Box::new(op)),
            in_nodes: self.in_nodes,
            topo_rank: rank,
            shape: self.shape,
            is_differentiable: self.can_have_gradient,
            input_indices,
            backprop_inputs: self.backprop_inputs,
            known_shape: self.known_shape,
            variable_id: self.variable_id,
            placeholder_name: self.placeholder_name,
        };
        Tensor {
            id: graph.install(new),
            graph,
        }
    }
/// Finalizes this builder and creates a tensor with given `Op` in the graph.
Finalizes this builder and creates a tensor with given `Op` in the graph.
Finalizes this builder and creates a tensor with given ` Op ` in the graph .
pub fn build<O>(self, op: O) -> Tensor<'graph, F>
    where
        O: op::Op<F> + 'static,
    {
        let graph = self.graph;
        let rank = if self.in_nodes.is_empty() {
            0
        } else {
            self.in_nodes
                .iter()
                .map(|a| graph.access_inner(a.id).topo_rank)
                .max()
                .map(|a| a + 1)
                .unwrap_or(0)
        };
        let input_indices = if let Some(a) = self.input_indices {
            assert_eq!(
                a.len(),
                self.in_nodes.len(),
                "input_indices.len() must match inputs length"
            );
            a
        } else {
            smallvec::smallvec!(0; self.in_nodes.len())
        };
        let new = TensorInternal {
            // `id` is set in `Graph::install`
            id: usize::default(),
            op: Some(Box::new(op)),
            in_nodes: self.in_nodes,
            topo_rank: rank,
            shape: self.shape,
            is_differentiable: self.can_have_gradient,
            input_indices,
            backprop_inputs: self.backprop_inputs,
            known_shape: self.known_shape,
            variable_id: self.variable_id,
            placeholder_name: self.placeholder_name,
        };
        Tensor {
            id: graph.install(new),
            graph,
        }
    }
pub fn build < O > ( self , op : O ) -> Tensor < ' graph , F > where O : op :: Op < F > + ' static , { let graph = self . graph ; let rank = if self . in_nodes . is_empty ( ) { 0 } else { self . in_nodes . iter ( ) . map ( | a | graph . access_inner ( a . id ) . topo_rank ) . max ( ) . map ( | a | a + 1 ) . unwrap_or ( 0 ) } ; let input_indices = if let Some ( a ) = self . input_indices { assert_eq ! ( a len ( ) self in_nodes len ( ) " " ) ; a } else { smallvec :: smallvec ! ( 0 self in_nodes len ( ) ) } ; let new = TensorInternal { // `id` is set in `Graph::install` id : usize :: default ( ) , op : Some ( Box :: new ( op ) ) , in_nodes : self . in_nodes , topo_rank : rank , shape : self . shape , is_differentiable : self . can_have_gradient , input_indices , backprop_inputs : self . backprop_inputs , known_shape : self . known_shape , variable_id : self . variable_id , placeholder_name : self . placeholder_name , } ; Tensor { id : graph . install ( new ) , graph , } }
Finalizes this builder and creates a tensor with given `Op` in the graph.
Finalizes this builder and creates a tensor with given ` Op ` in the graph .
self
op
O
self
op
O