未验证 提交 52116b16 编写于 作者: H HongyuJia 提交者: GitHub

clean test_op_name_conflict (#48704)

上级 464ef48a
...@@ -16,37 +16,35 @@ import unittest ...@@ -16,37 +16,35 @@ import unittest
import numpy as np import numpy as np
import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
class TestOpNameConflict(unittest.TestCase): class TestOpNameConflict(unittest.TestCase):
def test_conflict(self): def test_conflict(self):
paddle.enable_static()
main = fluid.Program() main = fluid.Program()
startup = fluid.Program() startup = fluid.Program()
with fluid.unique_name.guard(): with fluid.unique_name.guard():
with fluid.program_guard(main, startup): with fluid.program_guard(main, startup):
x = fluid.data(name="x", shape=[1], dtype='float32') x = fluid.data(name="x", shape=[1], dtype='float32')
y = fluid.data(name="y", shape=[1], dtype='float32') y = fluid.data(name="y", shape=[1], dtype='float32')
z = fluid.data(name="z", shape=[1], dtype='float32')
m = fluid.layers.elementwise_add(x, y, name="add") m = paddle.log2(x, name="log2")
n = fluid.layers.elementwise_add(y, z, name="add") n = paddle.log2(y, name="log2")
p = m + n
place = fluid.CPUPlace() place = fluid.CPUPlace()
exe = fluid.Executor(place) exe = fluid.Executor(place)
m_v, n_v, p_v = exe.run( m_v, n_v = exe.run(
feed={ feed={
"x": np.ones((1), "float32") * 2, "x": np.ones((1), "float32") * 1,
"y": np.ones((1), "float32") * 3, "y": np.ones((1), "float32") * 2,
"z": np.ones((1), "float32") * 5,
}, },
fetch_list=[m, n, p], fetch_list=[m, n],
) )
self.assertEqual(m_v[0], 5.0) self.assertEqual(m_v[0], 0.0)
self.assertEqual(n_v[0], 8.0) self.assertEqual(n_v[0], 1.0)
self.assertEqual(p_v[0], 13.0)
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册