aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/grappler/utils_test.cc
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <bsteiner@google.com>2017-03-08 10:58:59 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-03-08 11:08:14 -0800
commit96cb8f886ad84202e363c5a9da56cdbce4eaf408 (patch)
tree1ef73f791ed07f394dc5f577d37c4b57633b46b4 /tensorflow/core/grappler/utils_test.cc
parentb2a4a7da1a07830bfd4618603637520e8a26bd3f (diff)
Started to open source Grappler. First application is the GPU layout optimizer.
Change: 149558284
Diffstat (limited to 'tensorflow/core/grappler/utils_test.cc')
-rw-r--r--tensorflow/core/grappler/utils_test.cc59
1 files changed, 59 insertions, 0 deletions
diff --git a/tensorflow/core/grappler/utils_test.cc b/tensorflow/core/grappler/utils_test.cc
new file mode 100644
index 0000000000..57ba45352a
--- /dev/null
+++ b/tensorflow/core/grappler/utils_test.cc
@@ -0,0 +1,59 @@
+/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==============================================================================*/
+
+#include "tensorflow/core/grappler/utils.h"
+#include "tensorflow/core/platform/test.h"
+
+namespace tensorflow {
+namespace grappler {
+namespace {
+
+class UtilsTest : public ::testing::Test {};
+
+TEST_F(UtilsTest, NodeName) {
+ EXPECT_EQ("abc", NodeName("abc"));
+ EXPECT_EQ("abc", NodeName("^abc"));
+ EXPECT_EQ("abc", NodeName("abc:0"));
+ EXPECT_EQ("abc", NodeName("^abc:0"));
+
+ EXPECT_EQ("abc/def", NodeName("abc/def"));
+ EXPECT_EQ("abc/def", NodeName("^abc/def"));
+ EXPECT_EQ("abc/def", NodeName("abc/def:1"));
+ EXPECT_EQ("abc/def", NodeName("^abc/def:1"));
+
+ EXPECT_EQ("abc/def0", NodeName("abc/def0"));
+ EXPECT_EQ("abc/def0", NodeName("^abc/def0"));
+ EXPECT_EQ("abc/def0", NodeName("abc/def0:0"));
+ EXPECT_EQ("abc/def0", NodeName("^abc/def0:0"));
+
+ EXPECT_EQ("abc/def_0", NodeName("abc/def_0"));
+ EXPECT_EQ("abc/def_0", NodeName("^abc/def_0"));
+ EXPECT_EQ("abc/def_0", NodeName("abc/def_0:3"));
+ EXPECT_EQ("abc/def_0", NodeName("^abc/def_0:3"));
+
+ EXPECT_EQ("abc/def_0", NodeName("^abc/def_0:3214"));
+}
+
+TEST_F(UtilsTest, NodePosition) {
+ EXPECT_EQ(2, NodePosition("abc:2"));
+ EXPECT_EQ(123, NodePosition("abc:123"));
+ EXPECT_EQ(-1, NodePosition("^abc:123"));
+ EXPECT_EQ(-1, NodePosition("^abc"));
+ EXPECT_EQ(0, NodePosition(""));
+}
+
+} // namespace
+} // namespace grappler
+} // namespace tensorflow