def testIgnoredArguments(self):
"""Tests that JIT computations can ignore formal parameters."""
with self.test_session() as sess:
x = array_ops.placeholder(dtypes.int32)
y = array_ops.placeholder(dtypes.int32)
with jit_scope():
z = math_ops.add(x, x)
w = math_ops.add(y, y)
# Pulls 'w' into the same compilation via control dependencies.
with ops.control_dependencies([w]):
n = control_flow_ops.no_op()
with ops.control_dependencies([n]):
t = math_ops.add(z, z)
run_metadata = config_pb2.RunMetadata()
out = sess.run(t, {x: np.int32(7),
y: np.int32(404)},
run_metadata=run_metadata,
options=config_pb2.RunOptions(
trace_level=config_pb2.RunOptions.FULL_TRACE))
self.assert_(MetadataHasXlaLaunch(run_metadata))
self.assertAllClose(28, out)
jit_test.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录