WithControlDependencies returns a new Scope which will cause all operations added to the graph to execute only after all the provided operations have executed first (in addition to any other control dependencies in s).
(ops ...*tf.Operation)
| 113 | // added to the graph to execute only after all the provided operations have |
| 114 | // executed first (in addition to any other control dependencies in s). |
| 115 | func (s *Scope) WithControlDependencies(ops ...*tf.Operation) *Scope { |
| 116 | // Force a copy of the control dependencies into a new underlying array on |
| 117 | // every call. We cannot alias the same underlying array as `ops`, otherwise |
| 118 | // the user could modify that array after calling s.WithControlDependencies, |
| 119 | // which would be confusing. We cannot alias the same underlying array as the |
| 120 | // original `s.controlDependencies`, since Scopes form a logical tree, and |
| 121 | // other calls to s.WithControlDependencies could stomp on each other. |
| 122 | deps := make([]*tf.Operation, 0, len(s.controlDependencies)+len(ops)) |
| 123 | deps = append(deps, s.controlDependencies...) |
| 124 | deps = append(deps, ops...) |
| 125 | return &Scope{ |
| 126 | graph: s.graph, |
| 127 | namemap: s.namemap, |
| 128 | namespace: s.namespace, |
| 129 | controlDependencies: deps, |
| 130 | device: s.device, |
| 131 | err: s.err, |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | // WithDevice returns a new Scope which will cause all operations added to the |
| 136 | // graph to execute on devices that match the provided device specification. |