test_program_to_string.py 1.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
# 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
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# 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

C
Charles-hit 已提交
17
import paddle
18 19
import paddle.fluid as fluid

20 21 22 23

class TestProgram(unittest.TestCase):
    def test_program_to_string(self):
        prog = fluid.default_main_program()
24 25 26
        a = fluid.layers.data(
            name="X", shape=[2, 3], dtype="float32", append_batch_size=False
        )
C
Charles-hit 已提交
27
        c = paddle.static.nn.fc(a, size=3)
28
        prog_string = prog.to_string(throw_on_error=True, with_details=False)
29 30 31
        prog_string_with_details = prog.to_string(
            throw_on_error=False, with_details=True
        )
32 33 34 35 36 37
        assert prog_string is not None
        assert len(prog_string_with_details) > len(prog_string)


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