test_standalone_multiply_write.py 1.4 KB
Newer Older
X
xiongkun 已提交
1
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
2
#
X
xiongkun 已提交
3 4 5
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
6
#
X
xiongkun 已提交
7
#     http://www.apache.org/licenses/LICENSE-2.0
8
#
X
xiongkun 已提交
9 10 11 12 13 14 15 16 17 18
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

from test_standalone_controlflow import TestCompatibility

19 20 21
import paddle
from paddle.fluid.framework import Program

X
xiongkun 已提交
22 23 24 25 26
paddle.enable_static()


class TestMultiplyWrite(TestCompatibility):
    def _get_feed(self):
27
        """return the feeds"""
X
xiongkun 已提交
28 29 30
        return None

    def build_program(self):
31 32
        main_program = Program()
        startup_program = Program()
X
xiongkun 已提交
33
        with paddle.static.program_guard(main_program, startup_program):
34 35 36
            out = paddle.full((1,), 1)
            inp1 = paddle.full((1,), 2)
            inp2 = paddle.full((1,), 3)
X
xiongkun 已提交
37

38 39
            paddle.assign(inp1, out)
            paddle.assign(inp2, out)
X
xiongkun 已提交
40 41 42 43 44 45 46 47 48
        return main_program, startup_program, out

    def setUp(self):
        self.place = paddle.CPUPlace()
        self.iter_run = 5


if __name__ == "__main__":
    unittest.main()