Skip to content

Commit

Permalink
[CodeStyle][W291] trim trailing whitespace in python file (PaddlePadd…
Browse files Browse the repository at this point in the history
…le#45937)

* trim trailing whitespace

* fix `.cmake-format.py`

* revert npu ut changes, avoid npu ci error
  • Loading branch information
SigureMo authored Sep 14, 2022
1 parent cbe64cc commit de8c0ba
Show file tree
Hide file tree
Showing 416 changed files with 5,999 additions and 5,980 deletions.
6 changes: 3 additions & 3 deletions .cmake-format.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (c) 2022 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def GenerateFileStructureForFinalDygraph(eager_dir):
|- generated
| |- CMakeLists.txt
| | "add_subdirectory(forwards), add_subdirectory(backwards)"
|
|
| |- forwards
| |- "dygraph_functions.cc"
| |- "dygraph_functions.h"
Expand Down Expand Up @@ -59,7 +59,7 @@ def GenerateFileStructureForIntermediateDygraph(eager_dir, split_count):
|- generated
| |- CMakeLists.txt
| | "add_subdirectory(forwards), add_subdirectory(nodes)"
|
|
| |- forwards
| |- "dygraph_forward_functions.cc"
| |- CMakeLists.txt
Expand All @@ -70,7 +70,7 @@ def GenerateFileStructureForIntermediateDygraph(eager_dir, split_count):
| |- "nodes.h"
| |- CMakeLists.txt
| | "cc_library(dygraph_node SRCS nodes.cc DEPS ${eager_deps} ${fluid_deps})"
|
|
| |- dygraph_forward_api.h
"""
# Directory Generation
Expand Down
6 changes: 3 additions & 3 deletions paddle/fluid/eager/auto_code_generator/generator/eager_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,9 @@ class {} : public egr::GradNodeBase {{
if (paddle::imperative::LayoutAutoTune::Instance().UseLayoutAutoTune()) {{
VLOG(5) << "Check and Prepare For LAYOUT";
paddle::small_vector<std::vector<paddle::experimental::Tensor>, egr::kSlotSmallVectorSize> tensors_vector = {};
{}
{}
paddle::imperative::LayoutAutoTune::Instance().DisableLayoutAutoTune();
{}
paddle::imperative::LayoutAutoTune::Instance().DisableLayoutAutoTune();
{}
{}
paddle::imperative::LayoutAutoTune::Instance().EnableLayoutAutoTune();
Expand Down Expand Up @@ -1772,7 +1772,7 @@ def GenerateNodeDefinition(self, next_grad_node_creation_str,
autograd_api = self.grad_api_contents['invoke'].replace(
forward_api_name, forward_api_name + '_dygraph_function', 1)
grad_function_call_str = f"""
if (trace_backward) {{
if (trace_backward) {{
{indent}{autograd_api_out} api_output = {autograd_api};
{out_assign_str}}} else {{
{indent}{autograd_api_out} api_output = paddle::experimental::{self.namespace}{self.grad_api_contents['invoke']};
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/inference/api/demo_ci/untar_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def untar(fname, dirs):
"""
extract the tar.gz file
:param fname: the name of tar.gz file
:param dirs: the path of decompressed file
:param dirs: the path of decompressed file
:return: bool
"""
try:
Expand Down
78 changes: 39 additions & 39 deletions paddle/fluid/inference/tests/api/full_pascalvoc_test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def convert_pascalvoc_local2bin(args):
for object in objects:
bbox_sample = []
# start from 1
bbox_sample.append(
float(label_list.index(object.find('name').text)))
bbox_sample.append(float(label_list.index(
object.find('name').text)))
bbox = object.find('bndbox')
difficult = float(object.find('difficult').text)
bbox_sample.append(float(bbox.find('xmin').text) / im_width)
Expand All @@ -131,7 +131,7 @@ def convert_pascalvoc_local2bin(args):
f1.close()

object_nums_sum = sum(object_nums)
# The data should be contains
# The data should be contains
# number of images + all images data + an array that represent object numbers of each image
# + labels of all objects in images + bboxes of all objects + difficulties of all objects
# so the target size should be as follows:
Expand Down Expand Up @@ -210,8 +210,8 @@ def convert_pascalvoc_tar2bin(tar_path, data_out_path):

for object in objects:
bbox_sample = []
bbox_sample.append(
float(label_list.index(object.find('name').text)))
bbox_sample.append(float(label_list.index(
object.find('name').text)))
bbox = object.find('bndbox')
difficult = float(object.find('difficult').text)
bbox_sample.append(float(bbox.find('xmin').text) / im_width)
Expand All @@ -230,7 +230,7 @@ def convert_pascalvoc_tar2bin(tar_path, data_out_path):
if line_idx % per_percentage:
print_processbar(line_idx / per_percentage)

# The data should be stored in binary in following sequence:
# The data should be stored in binary in following sequence:
# number of images->all images data->an array that represent object numbers in each image
# ->labels of all objects in images->bboxes of all objects->difficulties of all objects
f1.write(np.array(object_nums).astype('uint64').tobytes())
Expand Down Expand Up @@ -258,9 +258,9 @@ def download_pascalvoc(data_url, data_dir, tar_targethash, tar_path):
def run_convert():
try_limit = 2
retry = 0
while not (os.path.exists(DATA_OUT_PATH) and
os.path.getsize(DATA_OUT_PATH) == BIN_FULLSIZE and BIN_TARGETHASH
== hashlib.md5(open(DATA_OUT_PATH, 'rb').read()).hexdigest()):
while not (os.path.exists(DATA_OUT_PATH) and os.path.getsize(DATA_OUT_PATH)
== BIN_FULLSIZE and BIN_TARGETHASH == hashlib.md5(
open(DATA_OUT_PATH, 'rb').read()).hexdigest()):
if os.path.exists(DATA_OUT_PATH):
sys.stderr.write(
"The existing binary file is broken. It is being removed...\n")
Expand All @@ -275,52 +275,52 @@ def run_convert():

def main_pascalvoc_preprocess(args):
parser = argparse.ArgumentParser(
description="Convert the full pascalvoc val set or local data to binary file.",
description=
"Convert the full pascalvoc val set or local data to binary file.",
usage=None,
add_help=True)
parser.add_argument(
'--local',
action="store_true",
help="If used, user need to set --data_dir and then convert file")
parser.add_argument(
"--data_dir", default="", type=str, help="Dataset root directory")
parser.add_argument("--data_dir",
default="",
type=str,
help="Dataset root directory")
parser.add_argument(
"--img_annotation_list",
type=str,
default="test_100.txt",
help="A file containing the image file path and corresponding annotation file path"
help=
"A file containing the image file path and corresponding annotation file path"
)
parser.add_argument(
"--label_file",
type=str,
default="label_list",
help="List of object labels with same sequence as denoted in the annotation file"
help=
"List of object labels with same sequence as denoted in the annotation file"
)
parser.add_argument(
"--output_file",
type=str,
default="pascalvoc_small.bin",
help="File path of the output binary file")
parser.add_argument(
"--resize_h",
type=int,
default=RESIZE_H,
help="Image preprocess with resize_h")
parser.add_argument(
"--resize_w",
type=int,
default=RESIZE_W,
help="Image prerocess with resize_w")
parser.add_argument(
"--mean_value",
type=str,
default=MEAN_VALUE,
help="Image preprocess with mean_value")
parser.add_argument(
"--ap_version",
type=str,
default=AP_VERSION,
help="Image preprocess with ap_version")
parser.add_argument("--output_file",
type=str,
default="pascalvoc_small.bin",
help="File path of the output binary file")
parser.add_argument("--resize_h",
type=int,
default=RESIZE_H,
help="Image preprocess with resize_h")
parser.add_argument("--resize_w",
type=int,
default=RESIZE_W,
help="Image prerocess with resize_w")
parser.add_argument("--mean_value",
type=str,
default=MEAN_VALUE,
help="Image preprocess with mean_value")
parser.add_argument("--ap_version",
type=str,
default=AP_VERSION,
help="Image preprocess with ap_version")
args = parser.parse_args()
if args.local:
convert_pascalvoc_local2bin(args)
Expand Down
12 changes: 6 additions & 6 deletions paddle/infrt/tests/models/abs_model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (c) 2022 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.
Expand All @@ -20,6 +20,7 @@


class AbsNet(paddle.nn.Layer):

def __init__(self):
super(AbsNet, self).__init__()

Expand All @@ -32,7 +33,6 @@ def forward(self, x):
# build network
model = AbsNet()
# save inferencing format model
net = to_static(
model, input_spec=[InputSpec(
shape=[None, 1, 28, 28], name='x')])
net = to_static(model,
input_spec=[InputSpec(shape=[None, 1, 28, 28], name='x')])
paddle.jit.save(net, sys.argv[1])
11 changes: 5 additions & 6 deletions paddle/infrt/tests/models/efficientnet-b4/model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (c) 2022 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.
Expand All @@ -20,7 +20,6 @@
import sys

model = EfficientNet.from_name('efficientnet-b4')
net = to_static(
model, input_spec=[InputSpec(
shape=[None, 3, 256, 256], name='x')])
net = to_static(model,
input_spec=[InputSpec(shape=[None, 3, 256, 256], name='x')])
paddle.jit.save(net, sys.argv[1])
6 changes: 3 additions & 3 deletions paddle/infrt/tests/models/efficientnet-b4/net/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (c) 2022 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.
Expand Down
Loading

0 comments on commit de8c0ba

Please sign in to comment.