def testAliasing(self):
"""Regression test for compiled functions that return an aliased buffer.
XLA returns aliased buffers if outputs are identical. Tests that
we handle that case.
"""
def AddOnceReturnTwice(x):
y = math_ops.add(x, x)
return y, y
# Exercises compling a function (say, Foo) which calls another
# function (say, Bar) which is not inlined. When the compiler compiles
# Foo, it needs to symbolic execute Bar correctly regardless whether
# Bar is inlined or not.
#
# Tests compiled=True and noinline=True.
self._compare(
AddOnceReturnTwice, [np.array(
[[[0.5, -1.0]]], dtype=np.float32)],
noinline=True)
# Tests compiled=True and noinline=False.
self._compare(
AddOnceReturnTwice, [np.array(
[[[0.5, -1.0]]], dtype=np.float32)],
noinline=False)
jit_test.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录