|
|
|
@ -175,35 +175,5 @@ class TestFP16MulOp2(TestMulOp2):
|
|
|
|
|
no_grad_set=set('Y'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestMulOpAttr(unittest.TestCase):
|
|
|
|
|
def test_out(self):
|
|
|
|
|
with fluid.program_guard(fluid.Program()):
|
|
|
|
|
x = fluid.data(name="x", shape=[2, 3], dtype="float32")
|
|
|
|
|
y = fluid.data(name='y', shape=[3, 2], dtype='float32')
|
|
|
|
|
|
|
|
|
|
res = fluid.data(name="output", shape=[2, 2], dtype="float32")
|
|
|
|
|
y_1 = paddle.mul(x, y, out=res)
|
|
|
|
|
|
|
|
|
|
place = fluid.CPUPlace()
|
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
|
data1 = np.array([[1, 2, 3], [4, 5, 6]], dtype='float32')
|
|
|
|
|
data2 = np.array([[1, 2], [1, 2], [1, 2]], dtype='float32')
|
|
|
|
|
np_res, np_y_1 = exe.run(feed={'x': data1,
|
|
|
|
|
'y': data2},
|
|
|
|
|
fetch_list=[res, y_1])
|
|
|
|
|
|
|
|
|
|
self.assertEqual((np_res == np_y_1).all(), True)
|
|
|
|
|
|
|
|
|
|
def test_name(self):
|
|
|
|
|
with fluid.program_guard(fluid.Program()):
|
|
|
|
|
x = fluid.data(name="x", shape=[2, 3], dtype="float32")
|
|
|
|
|
y = fluid.data(name='y', shape=[3, 2], dtype='float32')
|
|
|
|
|
|
|
|
|
|
res = fluid.data(name="output", shape=[2, 2], dtype="float32")
|
|
|
|
|
y_1 = paddle.mul(x, y, name='mul_res')
|
|
|
|
|
y_2 = paddle.mul(x, y, out=res, name='mul_res')
|
|
|
|
|
self.assertEqual(('mul_res' in y_1.name), True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
unittest.main()
|
|
|
|
|