[Dy2Stat] Don't conver the function from third library logging (#29161)

musl/disable_test_yolov3_temporarily
liym27 5 years ago committed by GitHub
parent a7433cc379
commit 01bdea7c31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,6 +19,7 @@ __all__ = ['convert_call']
import collections
import copy
import functools
import logging
import inspect
import pdb
import re
@ -35,7 +36,9 @@ from paddle.fluid.dygraph.dygraph_to_static.program_translator import unwrap_dec
from paddle.fluid.dygraph.layers import Layer
# TODO(liym27): A better way to do this.
BUILTIN_LIKELY_MODULES = [collections, pdb, copy, inspect, re, six, numpy]
BUILTIN_LIKELY_MODULES = [
collections, pdb, copy, inspect, re, six, numpy, logging
]
translator_logger = TranslatorLogger()

@ -16,6 +16,7 @@ from __future__ import print_function
import unittest
import logging
import numpy as np
import paddle.fluid as fluid
@ -49,6 +50,16 @@ def nested_func(x_v):
return res
@declarative
def dyfunc_with_third_library_logging(x_v):
logging.info('test dyfunc_with_third_library_logging')
if fluid.layers.mean(x_v).numpy()[0] > 5:
x_v = x_v - 1
else:
x_v = x_v + 1
return x_v
class TestRecursiveCall1(unittest.TestCase):
def setUp(self):
self.input = np.random.random([10, 16]).astype('float32')
@ -163,5 +174,16 @@ class TestRecursiveCall2(unittest.TestCase):
static_res))
class TestThirdPartyLibrary(TestRecursiveCall2):
def _run(self):
with fluid.dygraph.guard():
self.dygraph_func = dyfunc_with_third_library_logging
fluid.default_startup_program.random_seed = SEED
fluid.default_main_program.random_seed = SEED
data = fluid.dygraph.to_variable(self.input)
res = self.dygraph_func(data)
return res.numpy()
if __name__ == '__main__':
unittest.main()

Loading…
Cancel
Save