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

Method _testMaxItersSimple

tensorflow/compiler/tests/while_test.py:134–157  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

132 self.assertAllClose(result, [10, 7], rtol=1e-3)
133
134 def _testMaxItersSimple(self):
135 if is_compile_on_demand():
136 self.skipTest("list_ops are not supported in cpu_ondemand")
137 with self.session() as sess, self.test_scope():
138 xla_context = control_flow_ops.XLAControlFlowContext()
139 xla_context.Enter()
140 v = constant_op.constant(1.0)
141 p = array_ops.placeholder(dtype=dtypes.int32)
142
143 def create_while_loop():
144 iterations = array_ops.size(p, name="iterations")
145 r = control_flow_ops.while_loop(
146 lambda *_: True,
147 lambda i, x: (i + 1, v * x), (0, 1.0),
148 maximum_iterations=iterations,
149 name="outer")
150 return array_ops.identity(r[1])
151
152 output = create_while_loop()
153 output = gradients_impl.gradients(output, v)[0]
154
155 result = sess.run(output, feed_dict={p: [0, 0, 0]})
156 print(result)
157 xla_context.Exit()
158
159 def testMaxItersSimple(self):
160 self.skipTest("Fails with v1 control flow")

Callers 1

testMaxItersSimpleV2Method · 0.95

Calls 8

is_compile_on_demandFunction · 0.85
sessionMethod · 0.45
test_scopeMethod · 0.45
EnterMethod · 0.45
constantMethod · 0.45
placeholderMethod · 0.45
runMethod · 0.45
ExitMethod · 0.45

Tested by

no test coverage detected