Fix: Go GC could destroy input tensors while SessionRun() was still running, see https://github.com/tensorflow/tensorflow/issues/13129

This commit is contained in:
Andrei Nigmatulin 2017-09-20 15:33:28 +01:00
parent 03619fab3f
commit 846454faae

View File

@ -89,6 +89,10 @@ func (s *Session) Run(feeds map[Output]*Tensor, fetches []Output, targets []*Ope
ptrOutput(c.fetches), ptrTensor(c.fetchTensors), C.int(len(fetches)),
ptrOperation(c.targets), C.int(len(targets)),
nil, status.c)
// Make sure GC won't harvest input tensors until SessionRun() is finished
runtime.KeepAlive(feeds)
if err := status.Err(); err != nil {
return nil, err
}