aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/graph_editor
diff options
context:
space:
mode:
authorGravatar Frank Perbet <fkp@google.com>2017-03-10 02:44:38 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-03-10 03:12:48 -0800
commit411f26595861ca28809e3178f79fadcf378cabd6 (patch)
tree4f00599656a8b65d13fa046d274eb47558ed8695 /tensorflow/contrib/graph_editor
parent2f4a8bc5b3bb50dbc1d8c33e19bfda7d357a8986 (diff)
graph_editor: move match.py into the the test folder as it is not meant to be part of the graph_editor public API.
Change: 149741516
Diffstat (limited to 'tensorflow/contrib/graph_editor')
-rw-r--r--tensorflow/contrib/graph_editor/BUILD21
-rw-r--r--tensorflow/contrib/graph_editor/__init__.py1
-rw-r--r--tensorflow/contrib/graph_editor/tests/edit_test.py7
-rw-r--r--tensorflow/contrib/graph_editor/tests/match.py (renamed from tensorflow/contrib/graph_editor/match.py)0
-rw-r--r--tensorflow/contrib/graph_editor/tests/match_test.py21
-rw-r--r--tensorflow/contrib/graph_editor/tests/reroute_test.py23
-rw-r--r--tensorflow/contrib/graph_editor/tests/transform_test.py13
7 files changed, 50 insertions, 36 deletions
diff --git a/tensorflow/contrib/graph_editor/BUILD b/tensorflow/contrib/graph_editor/BUILD
index 66fa06d84e..6902808ed3 100644
--- a/tensorflow/contrib/graph_editor/BUILD
+++ b/tensorflow/contrib/graph_editor/BUILD
@@ -14,7 +14,6 @@ py_library(
srcs = [
"__init__.py",
"edit.py",
- "match.py",
"reroute.py",
"select.py",
"subgraph.py",
@@ -72,7 +71,10 @@ py_test(
py_test(
name = "match_test",
- srcs = ["tests/match_test.py"],
+ srcs = [
+ "tests/match.py",
+ "tests/match_test.py",
+ ],
srcs_version = "PY2AND3",
deps = [
":graph_editor_py",
@@ -100,7 +102,10 @@ py_test(
py_test(
name = "reroute_test",
- srcs = ["tests/reroute_test.py"],
+ srcs = [
+ "tests/match.py",
+ "tests/reroute_test.py",
+ ],
srcs_version = "PY2AND3",
deps = [
":graph_editor_py",
@@ -114,7 +119,10 @@ py_test(
py_test(
name = "edit_test",
- srcs = ["tests/edit_test.py"],
+ srcs = [
+ "tests/edit_test.py",
+ "tests/match.py",
+ ],
srcs_version = "PY2AND3",
deps = [
":graph_editor_py",
@@ -128,7 +136,10 @@ py_test(
py_test(
name = "transform_test",
- srcs = ["tests/transform_test.py"],
+ srcs = [
+ "tests/match.py",
+ "tests/transform_test.py",
+ ],
srcs_version = "PY2AND3",
deps = [
":graph_editor_py",
diff --git a/tensorflow/contrib/graph_editor/__init__.py b/tensorflow/contrib/graph_editor/__init__.py
index 49111d5437..51b7f45274 100644
--- a/tensorflow/contrib/graph_editor/__init__.py
+++ b/tensorflow/contrib/graph_editor/__init__.py
@@ -23,7 +23,6 @@ from __future__ import print_function
# pylint: disable=wildcard-import
from tensorflow.contrib.graph_editor.edit import *
-from tensorflow.contrib.graph_editor.match import *
from tensorflow.contrib.graph_editor.reroute import *
from tensorflow.contrib.graph_editor.select import *
from tensorflow.contrib.graph_editor.subgraph import *
diff --git a/tensorflow/contrib/graph_editor/tests/edit_test.py b/tensorflow/contrib/graph_editor/tests/edit_test.py
index 8adaf84b42..2f669c5d20 100644
--- a/tensorflow/contrib/graph_editor/tests/edit_test.py
+++ b/tensorflow/contrib/graph_editor/tests/edit_test.py
@@ -18,6 +18,7 @@ from __future__ import division
from __future__ import print_function
from tensorflow.contrib import graph_editor as ge
+from tensorflow.contrib.graph_editor.tests import match
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
from tensorflow.python.ops import math_ops
@@ -54,7 +55,7 @@ class EditTest(test.TestCase):
ge.detach(sgv, control_ios=control_outputs)
# make sure the detached graph is as expected.
self.assertTrue(
- ge.OpMatcher("^foo/c$").input_ops("a", "geph__b_0")(self.c.op))
+ match.OpMatcher("^foo/c$").input_ops("a", "geph__b_0")(self.c.op))
def test_connect(self):
"""Test for ge.connect."""
@@ -66,13 +67,13 @@ class EditTest(test.TestCase):
sgv = ge.sgv(x.op, y.op, z.op)
ge.connect(sgv, ge.sgv(self.e.op).remap_inputs([0]))
self.assertTrue(
- ge.OpMatcher("^foo/bar/e$").input_ops("^z$", "foo/d$")(self.e.op))
+ match.OpMatcher("^foo/bar/e$").input_ops("^z$", "foo/d$")(self.e.op))
def test_bypass(self):
"""Test for ge.bypass."""
ge.bypass(ge.sgv(self.f.op).remap_inputs([0]))
self.assertTrue(
- ge.OpMatcher("^foo/bar/h$").input_ops("^foo/c$", "foo/bar/g$")(
+ match.OpMatcher("^foo/bar/h$").input_ops("^foo/c$", "foo/bar/g$")(
self.h.op))
diff --git a/tensorflow/contrib/graph_editor/match.py b/tensorflow/contrib/graph_editor/tests/match.py
index 1bf482b6c2..1bf482b6c2 100644
--- a/tensorflow/contrib/graph_editor/match.py
+++ b/tensorflow/contrib/graph_editor/tests/match.py
diff --git a/tensorflow/contrib/graph_editor/tests/match_test.py b/tensorflow/contrib/graph_editor/tests/match_test.py
index bcb8f3f0e3..d81dc34dba 100644
--- a/tensorflow/contrib/graph_editor/tests/match_test.py
+++ b/tensorflow/contrib/graph_editor/tests/match_test.py
@@ -17,7 +17,7 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
-from tensorflow.contrib import graph_editor as ge
+from tensorflow.contrib.graph_editor.tests import match
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
from tensorflow.python.ops import math_ops
@@ -42,20 +42,21 @@ class MatchTest(test.TestCase):
self.h = math_ops.add(self.f, self.g, name="h")
def test_simple_match(self):
- self.assertTrue(ge.OpMatcher("^.*/f$")(self.f.op))
+ self.assertTrue(match.OpMatcher("^.*/f$")(self.f.op))
self.assertTrue(
- ge.OpMatcher("^.*/f$").input_ops("^.*/c$", "^.*/d$")(self.f.op))
- self.assertTrue(ge.OpMatcher("^.*/f$").input_ops(True, "^.*/d$")(self.f.op))
+ match.OpMatcher("^.*/f$").input_ops("^.*/c$", "^.*/d$")(self.f.op))
self.assertTrue(
- ge.OpMatcher("^.*/f$").input_ops(
- ge.match.op_type("Add"), ge.match.op_type("Const"))(self.f.op))
+ match.OpMatcher("^.*/f$").input_ops(True, "^.*/d$")(self.f.op))
self.assertTrue(
- ge.OpMatcher("^.*/f$").input_ops("^.*/c$", "^.*/d$")
- .output_ops(ge.OpMatcher("^.*/h$")
+ match.OpMatcher("^.*/f$").input_ops(
+ match.op_type("Add"), match.op_type("Const"))(self.f.op))
+ self.assertTrue(
+ match.OpMatcher("^.*/f$").input_ops("^.*/c$", "^.*/d$")
+ .output_ops(match.OpMatcher("^.*/h$")
.control_input_ops("^.*/c$"))(self.f.op))
self.assertTrue(
- ge.OpMatcher("^.*/f$").input_ops("^.*/c$", "^.*/d$").output_ops(
- ge.OpMatcher("^.*/h$").control_input_ops("^.*/c$")
+ match.OpMatcher("^.*/f$").input_ops("^.*/c$", "^.*/d$").output_ops(
+ match.OpMatcher("^.*/h$").control_input_ops("^.*/c$")
.output_ops([]))(self.f.op))
diff --git a/tensorflow/contrib/graph_editor/tests/reroute_test.py b/tensorflow/contrib/graph_editor/tests/reroute_test.py
index d663c8839d..3c00304add 100644
--- a/tensorflow/contrib/graph_editor/tests/reroute_test.py
+++ b/tensorflow/contrib/graph_editor/tests/reroute_test.py
@@ -18,6 +18,7 @@ from __future__ import division
from __future__ import print_function
from tensorflow.contrib import graph_editor as ge
+from tensorflow.contrib.graph_editor.tests import match
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
from tensorflow.python.ops import math_ops
@@ -41,25 +42,25 @@ class RerouteTest(test.TestCase):
def test_swap(self):
ge.swap_ts([self.a0, self.b0], [self.a1, self.b1])
- self.assertTrue(ge.OpMatcher("c0").input_ops("a1", "b1")(self.c0.op))
- self.assertTrue(ge.OpMatcher("c1").input_ops("a0", "b0")(self.c1.op))
+ self.assertTrue(match.OpMatcher("c0").input_ops("a1", "b1")(self.c0.op))
+ self.assertTrue(match.OpMatcher("c1").input_ops("a0", "b0")(self.c1.op))
def test_multiswap(self):
with self.graph.as_default():
a3 = constant_op.constant(3.0, shape=[2], name="a3")
ge.swap_ios(ge.sgv(a3.op).remap_outputs([0, 0]),
ge.sgv(self.a0.op, self.a1.op))
- self.assertTrue(ge.OpMatcher("c0").input_ops("a3", "b0")(self.c0.op))
- self.assertTrue(ge.OpMatcher("c1").input_ops("a3", "b1")(self.c1.op))
+ self.assertTrue(match.OpMatcher("c0").input_ops("a3", "b0")(self.c0.op))
+ self.assertTrue(match.OpMatcher("c1").input_ops("a3", "b1")(self.c1.op))
def test_reroute(self):
ge.reroute_ts([self.a0, self.b0], [self.a1, self.b1])
- self.assertTrue(ge.OpMatcher("c0").input_ops("a0", "b0")(self.c0.op))
- self.assertTrue(ge.OpMatcher("c1").input_ops("a0", "b0")(self.c1.op))
+ self.assertTrue(match.OpMatcher("c0").input_ops("a0", "b0")(self.c0.op))
+ self.assertTrue(match.OpMatcher("c1").input_ops("a0", "b0")(self.c1.op))
ge.reroute_ts([self.a1, self.b1], [self.a0, self.b0])
- self.assertTrue(ge.OpMatcher("c0").input_ops("a1", "b1")(self.c0.op))
- self.assertTrue(ge.OpMatcher("c1").input_ops("a1", "b1")(self.c1.op))
+ self.assertTrue(match.OpMatcher("c0").input_ops("a1", "b1")(self.c0.op))
+ self.assertTrue(match.OpMatcher("c1").input_ops("a1", "b1")(self.c1.op))
def test_compatibility(self):
with self.assertRaises(ValueError):
@@ -84,9 +85,9 @@ class RerouteTest(test.TestCase):
ge.swap_outputs(sgv0, sgv1)
self.assertTrue(
- ge.OpMatcher("g").input_ops("a", ge.OpMatcher("c").input_ops("a", "b"))(
- g.op))
- self.assertTrue(ge.OpMatcher("d").input_ops("e", "f")(d.op))
+ match.OpMatcher("g").input_ops(
+ "a", match.OpMatcher("c").input_ops("a", "b"))(g.op))
+ self.assertTrue(match.OpMatcher("d").input_ops("e", "f")(d.op))
if __name__ == "__main__":
diff --git a/tensorflow/contrib/graph_editor/tests/transform_test.py b/tensorflow/contrib/graph_editor/tests/transform_test.py
index 33f1217412..a4105645c6 100644
--- a/tensorflow/contrib/graph_editor/tests/transform_test.py
+++ b/tensorflow/contrib/graph_editor/tests/transform_test.py
@@ -20,6 +20,7 @@ from __future__ import print_function
import collections
import numpy as np
from tensorflow.contrib import graph_editor as ge
+from tensorflow.contrib.graph_editor.tests import match
from tensorflow.python.client import session
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
@@ -100,12 +101,12 @@ class TransformTest(test.TestCase):
graph = ops.Graph()
transformer(self.graph, graph, "", "")
- matcher0 = ge.OpMatcher("AddNoise").input_ops(
- "Noise", ge.OpMatcher("Add").input_ops("Const", "Input"))
- matcher1 = ge.OpMatcher("AddNoise_1").input_ops(
- "Noise_1", ge.OpMatcher("Add_1").input_ops("Const_1", matcher0))
- matcher2 = ge.OpMatcher("AddNoise_2").input_ops(
- "Noise_2", ge.OpMatcher("Add_2").input_ops("Const_2", matcher1))
+ matcher0 = match.OpMatcher("AddNoise").input_ops(
+ "Noise", match.OpMatcher("Add").input_ops("Const", "Input"))
+ matcher1 = match.OpMatcher("AddNoise_1").input_ops(
+ "Noise_1", match.OpMatcher("Add_1").input_ops("Const_1", matcher0))
+ matcher2 = match.OpMatcher("AddNoise_2").input_ops(
+ "Noise_2", match.OpMatcher("Add_2").input_ops("Const_2", matcher1))
top = ge.select_ops("^AddNoise_2$", graph=graph)[0]
self.assertTrue(matcher2(top))