aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/go/session.go
diff options
context:
space:
mode:
authorGravatar Andrei Nigmatulin <andrei.nigmatulin@gmail.com>2017-09-20 15:33:28 +0100
committerGravatar Andrei Nigmatulin <andrei.nigmatulin@gmail.com>2017-09-20 15:49:31 +0100
commit846454faae5a66fa430b03c82f571440919070f3 (patch)
treeb5df99a2b6aff9334e1e7fdb83424aafc9d4d21b /tensorflow/go/session.go
parent03619fab3f4dd6f28b67418455a953b0fccdd9bf (diff)
Fix: Go GC could destroy input tensors while SessionRun() was still running, see https://github.com/tensorflow/tensorflow/issues/13129
Diffstat (limited to 'tensorflow/go/session.go')
-rw-r--r--tensorflow/go/session.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/tensorflow/go/session.go b/tensorflow/go/session.go
index afa73030b8..fc914f86df 100644
--- a/tensorflow/go/session.go
+++ b/tensorflow/go/session.go
@@ -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
}