Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions python/paddle/fluid/tests/unittests/test_op_name_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,35 @@

import numpy as np

import paddle
import paddle.fluid as fluid


class TestOpNameConflict(unittest.TestCase):
def test_conflict(self):
paddle.enable_static()
main = fluid.Program()
startup = fluid.Program()
with fluid.unique_name.guard():
with fluid.program_guard(main, startup):
x = fluid.data(name="x", 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")
n = fluid.layers.elementwise_add(y, z, name="add")
p = m + n
m = paddle.log2(x, name="log2")
n = paddle.log2(y, name="log2")

place = fluid.CPUPlace()
exe = fluid.Executor(place)
m_v, n_v, p_v = exe.run(
m_v, n_v = exe.run(
feed={
"x": np.ones((1), "float32") * 2,
"y": np.ones((1), "float32") * 3,
"z": np.ones((1), "float32") * 5,
"x": np.ones((1), "float32") * 1,
"y": np.ones((1), "float32") * 2,
},
fetch_list=[m, n, p],
fetch_list=[m, n],
)

self.assertEqual(m_v[0], 5.0)
self.assertEqual(n_v[0], 8.0)
self.assertEqual(p_v[0], 13.0)
self.assertEqual(m_v[0], 0.0)
self.assertEqual(n_v[0], 1.0)


if __name__ == '__main__':
Expand Down