“d2edbe5709d013c56ff8f242e3dc5631423f46bf”上不存在“paddle/fluid/operators/scale_op.h”
test_utils.py 1.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#   Copyright (c) 2020 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.

15
import types
16 17
import unittest

18
from paddle.jit.dy2static.utils import index_in_list, is_paddle_func
19

20 21 22 23 24 25 26 27 28 29 30

class TestIndexInList(unittest.TestCase):
    def test_index_in_list(self):
        list_to_test = [1, 2, 3, 4, 5]
        self.assertEqual(index_in_list(list_to_test, 4), 3)
        self.assertEqual(index_in_list(list_to_test, 1), 0)
        self.assertEqual(index_in_list(list_to_test, 5), 4)
        self.assertEqual(index_in_list(list_to_test, 0), -1)
        self.assertEqual(index_in_list(list_to_test, 6), -1)


31 32 33 34 35 36 37
def dyfunc_assign(input):
    a = b = 1
    c, d = e, f = a, b
    z = [3, 4]
    [x, y] = m, n = z


38
class StaticCode:
39 40 41 42 43 44 45 46 47 48 49 50 51
    def dyfunc_assign(input):
        b = 1
        a = b
        e = a
        f = b
        c = e
        d = f
        z = [3, 4]
        m, n = z
        x = m
        y = n


52 53 54 55 56 57 58 59 60
class TestIsPaddle(unittest.TestCase):
    def fake_module(self):
        return types.ModuleType('paddlenlp')

    def test_func(self):
        m = self.fake_module()
        self.assertFalse(is_paddle_func(m))


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