diff options
author | Dandelion Man? <dandelion@google.com> | 2017-12-15 18:15:07 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-12-15 18:19:09 -0800 |
commit | 90e42f3ac8c43474633136af4242dca04b6a1e09 (patch) | |
tree | 64dbb44252c89c847bee86db07cea5aa94072e7c /tensorflow/go/graph.go | |
parent | 713d45278491d792c525344de6038a61ebcb2136 (diff) |
Automated g4 rollback of changelist 179260538
PiperOrigin-RevId: 179263865
Diffstat (limited to 'tensorflow/go/graph.go')
-rw-r--r-- | tensorflow/go/graph.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tensorflow/go/graph.go b/tensorflow/go/graph.go index f200a8e00a..fc087d9d99 100644 --- a/tensorflow/go/graph.go +++ b/tensorflow/go/graph.go @@ -28,7 +28,8 @@ package tensorflow // int num_shapes) { // const int64_t** dims = // (const int64_t**)malloc(sizeof(const int64_t*) * num_shapes); -// for (int i = 0; i < num_shapes; i++) { +// int i = 0; +// for (i = 0; i < num_shapes; i++) { // dims[i] = flat_dims; // if (num_dims[i] > 0) { // // flat_dims will be NULL iff num_shapes is 0 or all elements in num_dims are <= 0. @@ -132,6 +133,20 @@ func (g *Graph) Operation(name string) *Operation { return &Operation{cop, g} } +// Operations returns a list of all operations in the graph +func (g *Graph) Operations() []Operation { + var pos C.size_t = 0 + ops := []Operation{} + for { + cop := C.TF_GraphNextOperation(g.c, &pos) + if cop == nil { + break + } + ops = append(ops, Operation{cop, g}) + } + return ops +} + // OpSpec is the specification of an Operation to be added to a Graph // (using Graph.AddOperation). type OpSpec struct { |