MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testNameScope

Method testNameScope

tensorflow/python/framework/ops_test.py:1398–1443  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1396 self.assertEqual("my_op:0", op3.outputs[0].name)
1397
1398 def testNameScope(self):
1399 g = ops.Graph()
1400
1401 with g.name_scope("foo") as foo:
1402 self.assertEqual("foo/", foo)
1403 with g.name_scope("foo2") as foo2:
1404 self.assertEqual("foo/foo2/", foo2)
1405 with g.name_scope(None) as empty1:
1406 self.assertEqual("", empty1)
1407 with g.name_scope("foo3") as foo3:
1408 self.assertEqual("foo3/", foo3)
1409 with g.name_scope("") as empty2:
1410 self.assertEqual("", empty2)
1411
1412 self.assertEqual("FloatOutput",
1413 g.create_op("FloatOutput", [], [dtypes.float32]).name)
1414 with g.name_scope("bar") as scope:
1415 self.assertEqual("bar/FloatOutput",
1416 g.create_op("FloatOutput", [], [dtypes.float32]).name)
1417 self.assertEqual("bar/FloatOutput_1",
1418 g.create_op("FloatOutput", [], [dtypes.float32]).name)
1419 # If you use the value from "with .. as", that values is used as-is.
1420 self.assertEqual(
1421 "bar", g.create_op(
1422 "FloatOutput", [], [dtypes.float32], name=scope).name)
1423 with g.name_scope("baz") as scope:
1424 with g.name_scope("quux"):
1425 self.assertEqual("baz/quux/FloatOutput",
1426 g.create_op("FloatOutput", [], [dtypes.float32]).name)
1427 # If you use the value from the enclosing "with .. as", nothing is pushed.
1428 with g.name_scope(scope):
1429 self.assertEqual("baz/FloatOutput",
1430 g.create_op("FloatOutput", [], [dtypes.float32]).name)
1431 self.assertEqual(
1432 "baz", g.create_op(
1433 "FloatOutput", [], [dtypes.float32], name=scope).name)
1434 self.assertEqual(
1435 "trailing",
1436 g.create_op(
1437 "FloatOutput", [], [dtypes.float32], name="trailing/").name)
1438 with g.name_scope("bar"):
1439 self.assertEqual("bar_1/FloatOutput",
1440 g.create_op("FloatOutput", [], [dtypes.float32]).name)
1441 with g.name_scope("bar/"):
1442 self.assertEqual("bar/FloatOutput_2",
1443 g.create_op("FloatOutput", [], [dtypes.float32]).name)
1444
1445
1446class DeviceTest(test_util.TensorFlowTestCase):

Callers

nothing calls this directly

Calls 3

name_scopeMethod · 0.95
create_opMethod · 0.95
GraphMethod · 0.45

Tested by

no test coverage detected