MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / NewPartialRun

Method NewPartialRun

tensorflow/go/session.go:214–267  ·  view source on GitHub ↗

NewPartialRun sets up the graph for incremental evaluation. All values of feeds, fetches and targets that may be provided to Run calls on the returned PartialRun need to be provided to NewPartialRun. See documentation for the PartialRun type.

(feeds, fetches []Output, targets []*Operation)

Source from the content-addressed store, hash-verified

212//
213// See documentation for the PartialRun type.
214func (s *Session) NewPartialRun(feeds, fetches []Output, targets []*Operation) (*PartialRun, error) {
215 var (
216 cfeeds = make([]C.TF_Output, len(feeds))
217 cfetches = make([]C.TF_Output, len(fetches))
218 ctargets = make([]*C.TF_Operation, len(targets))
219
220 pcfeeds *C.TF_Output
221 pcfetches *C.TF_Output
222 pctargets **C.TF_Operation
223
224 status = newStatus()
225 )
226 if len(feeds) > 0 {
227 pcfeeds = &cfeeds[0]
228 for i, o := range feeds {
229 cfeeds[i] = o.c()
230 }
231 }
232 if len(fetches) > 0 {
233 pcfetches = &cfetches[0]
234 for i, o := range fetches {
235 cfetches[i] = o.c()
236 }
237 }
238 if len(targets) > 0 {
239 pctargets = &ctargets[0]
240 for i, o := range targets {
241 ctargets[i] = o.c
242 }
243 }
244
245 s.mu.Lock()
246 if s.c == nil {
247 s.mu.Unlock()
248 return nil, errors.New("session is closed")
249 }
250 s.wg.Add(1)
251 s.mu.Unlock()
252 defer s.wg.Done()
253
254 pr := &PartialRun{session: s}
255 C.TF_SessionPRunSetup(s.c,
256 pcfeeds, C.int(len(feeds)),
257 pcfetches, C.int(len(fetches)),
258 pctargets, C.int(len(targets)),
259 &pr.handle, status.c)
260 if err := status.Err(); err != nil {
261 return nil, err
262 }
263 runtime.SetFinalizer(pr, func(pr *PartialRun) {
264 C.TF_DeletePRunHandle(pr.handle)
265 })
266 return pr, nil
267}
268
269// Close a session. This contacts any other processes associated with this
270// session, if applicable. Blocks until all previous calls to Run have returned.

Callers 1

ExamplePartialRunFunction · 0.95

Calls 9

makeFunction · 0.85
newStatusFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
cMethod · 0.45
NewMethod · 0.45
AddMethod · 0.45
DoneMethod · 0.45
ErrMethod · 0.45

Tested by 1

ExamplePartialRunFunction · 0.76