Run the graph with the associated session starting with the supplied feeds to compute the value of the requested fetches. Runs, but does not return Tensors for operations specified in targets. On success, returns the fetched Tensors in the same order as supplied in the fetches argument. If fetches
(feeds map[Output]*Tensor, fetches []Output, targets []*Operation)
| 131 | // the fetches argument. If fetches is set to nil, the returned Tensor fetches |
| 132 | // is empty. |
| 133 | func (s *Session) Run(feeds map[Output]*Tensor, fetches []Output, targets []*Operation) ([]*Tensor, error) { |
| 134 | s.mu.Lock() |
| 135 | if s.c == nil { |
| 136 | s.mu.Unlock() |
| 137 | return nil, errors.New("session is closed") |
| 138 | } |
| 139 | s.wg.Add(1) |
| 140 | s.mu.Unlock() |
| 141 | defer s.wg.Done() |
| 142 | |
| 143 | c := newCRunArgs(feeds, fetches, targets) |
| 144 | status := newStatus() |
| 145 | C.TF_SessionRun(s.c, nil, |
| 146 | ptrOutput(c.feeds), ptrTensor(c.feedTensors), C.int(len(feeds)), |
| 147 | ptrOutput(c.fetches), ptrTensor(c.fetchTensors), C.int(len(fetches)), |
| 148 | ptrOperation(c.targets), C.int(len(targets)), |
| 149 | nil, status.c) |
| 150 | |
| 151 | // Make sure GC won't harvest input tensors until SessionRun() is finished |
| 152 | runtime.KeepAlive(feeds) |
| 153 | |
| 154 | if err := status.Err(); err != nil { |
| 155 | return nil, err |
| 156 | } |
| 157 | return c.toGo(), nil |
| 158 | } |
| 159 | |
| 160 | // PartialRun enables incremental evaluation of graphs. |
| 161 | // |