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

Method testOpProperties

tensorflow/python/grappler/item_test.py:62–83  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

60 self.assertItemsEqual(['Const', 'Const_1', 'add'], op_list)
61
62 def testOpProperties(self):
63 with ops.Graph().as_default() as g:
64 a = constant_op.constant(10)
65 b = constant_op.constant(20)
66 c = a + b
67 z = control_flow_ops.no_op()
68 train_op = ops.get_collection_ref(ops.GraphKeys.TRAIN_OP)
69 train_op.append(c)
70 mg = meta_graph.create_meta_graph_def(graph=g)
71 grappler_item = item.Item(mg)
72 op_properties = grappler_item.GetOpProperties()
73
74 # All the nodes in this model have one scalar output
75 for node in grappler_item.metagraph.graph_def.node:
76 node_prop = op_properties[node.name]
77
78 if node.name == z.name:
79 self.assertEqual(0, len(node_prop))
80 else:
81 self.assertEqual(1, len(node_prop))
82 self.assertEqual(dtypes.int32, node_prop[0].dtype)
83 self.assertEqual(tensor_shape.TensorShape([]), node_prop[0].shape)
84
85 def testUpdates(self):
86 with ops.Graph().as_default() as g:

Callers

nothing calls this directly

Calls 7

GetOpPropertiesMethod · 0.95
get_collection_refMethod · 0.80
ItemMethod · 0.80
as_defaultMethod · 0.45
GraphMethod · 0.45
constantMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected