未验证 提交 443cf71a 编写于 作者: Z zhangchunle 提交者: GitHub

fix undefined-variable (#33355)

上级 599e9e48
......@@ -14,6 +14,7 @@
from __future__ import print_function
import sys
import paddle
from paddle.optimizer import Optimizer
from paddle.fluid.clip import ClipGradByGlobalNorm
from ...utils.hybrid_parallel_util import fused_allreduce_gradients
......@@ -22,6 +23,8 @@ from paddle.fluid.dygraph import base as imperative_base
from paddle.fluid import framework
from paddle.fluid.framework import Variable
from ...utils.log_util import logger
from paddle.fluid import core
from paddle.fluid import layers
__all__ = []
......
......@@ -150,6 +150,7 @@ def _format_summary(collected_ops_list):
'''
_verify_dependent_package()
from prettytable import PrettyTable
summary_table = PrettyTable(
["No.", "TYPE", "INPUT", "OUTPUT", "PARAMs", "FLOPs"])
summary_table.align = 'r'
......
......@@ -13,7 +13,7 @@
# limitations under the License.
import os
import sys
import six
import unittest
import time
......
......@@ -268,7 +268,7 @@ class AutoCheckpointTest(AutoCheckPointACLBase):
def test_checker(self):
os.environ.pop("PADDLE_JOB_ID", None)
try:
checker = AutoCheckpointChecker()
checker = acp.AutoCheckpointChecker()
self.assertFalse(True)
except Exception as e:
pass
......
......@@ -333,7 +333,7 @@ class TestDynamicRNNErrors(unittest.TestCase):
hidden = fluid.layers.fc(input=[word, memory],
size=10,
act='tanh')
out = np.ones(1).astype('float32')
out = numpy.ones(1).astype('float32')
drnn.update_memory(ex_mem=memory, new_mem=hidden)
drnn.output(hidden, out)
......
......@@ -47,7 +47,7 @@ class TestExportWithTensor(unittest.TestCase):
self.x_spec = paddle.static.InputSpec(
shape=[None, 128], dtype='float32')
def test_with_tensor():
def test_with_tensor(self):
model = LinearNet()
paddle.onnx.export(model, 'linear_net', input_spec=[self.x_spec])
......
......@@ -163,7 +163,7 @@ def init_communicator(program, rank, nranks, wait_port, current_endpoint,
})
elif core.is_compiled_with_npu():
hccl_id_var = block.create_var(
name=unique_name.generate('hccl_id'),
name=fluid.unique_name.generate('hccl_id'),
persistable=True,
type=core.VarDesc.VarType.RAW)
endpoint_to_index_map = {e: idx for idx, e in enumerate(endpoints)}
......@@ -710,10 +710,10 @@ class DynamicGraphAdapter(object):
enable=self._amp_level != 'O0', **self._amp_custom_lists):
if self._nranks > 1:
outputs = self.ddp_model.forward(
* [to_variable(x) for x in inputs])
*[to_variable(x) for x in inputs])
else:
outputs = self.model.network.forward(
* [to_variable(x) for x in inputs])
*[to_variable(x) for x in inputs])
losses = self.model._loss(*(to_list(outputs) + labels))
losses = to_list(losses)
......@@ -732,7 +732,7 @@ class DynamicGraphAdapter(object):
metrics = []
for metric in self.model._metrics:
metric_outs = metric.compute(*(to_list(outputs) + labels))
m = metric.update(* [to_numpy(m) for m in to_list(metric_outs)])
m = metric.update(*[to_numpy(m) for m in to_list(metric_outs)])
metrics.append(m)
return ([to_numpy(l) for l in losses], metrics) \
......@@ -746,7 +746,7 @@ class DynamicGraphAdapter(object):
labels = labels or []
labels = [to_variable(l) for l in to_list(labels)]
outputs = self.model.network.forward(* [to_variable(x) for x in inputs])
outputs = self.model.network.forward(*[to_variable(x) for x in inputs])
if self.model._loss:
losses = self.model._loss(*(to_list(outputs) + labels))
losses = to_list(losses)
......@@ -777,7 +777,7 @@ class DynamicGraphAdapter(object):
self._merge_count[self.mode + '_batch'] = samples
metric_outs = metric.compute(*(to_list(outputs) + labels))
m = metric.update(* [to_numpy(m) for m in to_list(metric_outs)])
m = metric.update(*[to_numpy(m) for m in to_list(metric_outs)])
metrics.append(m)
if self.model._loss and len(metrics):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册