From 71f8707bb8eeac7f4d5074d4382b8da364068bb6 Mon Sep 17 00:00:00 2001 From: zhangchunle Date: Fri, 11 Jun 2021 12:35:18 +0800 Subject: [PATCH] fix undefined-variable-1 (#33425) --- python/paddle/fluid/net_drawer.py | 6 +++--- .../unittests/dygraph_to_static/simnet_dygraph_model.py | 1 + .../unittests/dygraph_to_static/simnet_dygraph_model_v2.py | 1 + .../unittests/dygraph_to_static/test_static_analysis.py | 1 + python/paddle/text/datasets/wmt14.py | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/net_drawer.py b/python/paddle/fluid/net_drawer.py index f991310384f..fd8f6eaf364 100644 --- a/python/paddle/fluid/net_drawer.py +++ b/python/paddle/fluid/net_drawer.py @@ -102,11 +102,11 @@ def parse_graph(program, graph, var_dict, **kwargs): def draw_graph(startup_program, main_program, **kwargs): if "graph_attr" in kwargs: - GRAPH_STYLE.update(kwargs[graph_attr]) + GRAPH_STYLE.update(kwargs["graph_attr"]) if "node_attr" in kwargs: - OP_STYLE.update(kwargs[node_attr]) + OP_STYLE.update(kwargs["node_attr"]) if "edge_attr" in kwargs: - VAR_STYLE.update(kwargs[edge_attr]) + VAR_STYLE.update(kwargs["edge_attr"]) graph_id = unique_id() filename = kwargs.get("filename") diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py index 4f35befda8e..affec2f7dfe 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py @@ -18,6 +18,7 @@ import paddle.fluid.param_attr as attr from functools import reduce from paddle.fluid.dygraph import declarative, to_variable from paddle.fluid.dygraph import Embedding, Layer, Linear +from paddle.static import Variable class EmbeddingLayer(object): diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model_v2.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model_v2.py index e0b7e9033dd..5cbaeb0f404 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model_v2.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model_v2.py @@ -14,6 +14,7 @@ from functools import reduce import paddle +from paddle.static import Variable class EmbeddingLayer(object): diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_static_analysis.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_static_analysis.py index e72688d800b..0fffb0c9853 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_static_analysis.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_static_analysis.py @@ -17,6 +17,7 @@ from __future__ import print_function import gast import inspect import numpy as np +import paddle import paddle.fluid as fluid import unittest diff --git a/python/paddle/text/datasets/wmt14.py b/python/paddle/text/datasets/wmt14.py index a50b9e81aac..38ca09bf299 100644 --- a/python/paddle/text/datasets/wmt14.py +++ b/python/paddle/text/datasets/wmt14.py @@ -18,6 +18,7 @@ import six import tarfile import numpy as np import gzip +import six from paddle.io import Dataset import paddle.compat as cpt -- GitLab