Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CPU-PSLIB] Add consistency insepection of use_var_list and data_generator data, test=develop #34463

Merged
merged 23 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
33e584b
[CPU-PSLIB] Add consistency insepection of use_var_list and data_gene…
WorgenZhang Jul 28, 2021
e05a7d6
[CPU-PSLIB] Add consistency insepection of use_var_list and data_gene…
WorgenZhang Jul 28, 2021
733c9dc
[CPU-PSLIB] Add consistency insepection of use_var_list and data_gene…
WorgenZhang Jul 28, 2021
a8fb3dd
[CPU-PSLIB] Add consistency insepection of use_var_list and data_gene…
WorgenZhang Jul 29, 2021
61f9514
Merge branch 'develop' of https://github.com/WorgenZhang/Paddle into …
WorgenZhang Aug 9, 2021
0f5b7a0
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
WorgenZhang Aug 9, 2021
3bb1fd3
Merge branch 'PaddlePaddle:develop' into fan-dev
WorgenZhang Aug 10, 2021
628d8eb
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
WorgenZhang Aug 11, 2021
01113dd
Merge branch 'develop' of https://github.com/WorgenZhang/Paddle into …
WorgenZhang Aug 11, 2021
7d8db62
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
WorgenZhang Aug 11, 2021
a375b2c
Merge branch 'PaddlePaddle:develop' into fan-dev
WorgenZhang Aug 11, 2021
09d1a81
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
WorgenZhang Aug 12, 2021
f485502
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
WorgenZhang Aug 12, 2021
9d222e7
[CPU-PSLIB] Add Unitest For: consistency insepection of use_var_list …
WorgenZhang Aug 16, 2021
327eddc
Merge branch 'fan-dev' of https://github.com/WorgenZhang/Paddle into …
WorgenZhang Aug 16, 2021
493c91f
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
WorgenZhang Aug 16, 2021
b1123e9
[CPU-PSLIB] Add Unitest For: consistency insepection of use_var_list …
WorgenZhang Aug 16, 2021
6b8d16a
[CPU-PSLIB] Add Unitest For: consistency insepection of use_var_list…
WorgenZhang Aug 17, 2021
9aafded
[CPU-PSLIB] Add Unitest For: consistency insepection of use_var_list…
WorgenZhang Aug 17, 2021
9f96612
[CPU-PSLIB] Add Unitest For: consistency insepection of use_var_list…
WorgenZhang Aug 17, 2021
f84da1c
[CPU-PSLIB] Add Unitest For: consistency insepection of use_var_list…
WorgenZhang Aug 17, 2021
a4713d6
[CPU-PSLIB] Add consistency insepection of use_var_list and data_gen…
WorgenZhang Aug 18, 2021
a5da0d6
[CPU-PSLIB] Add consistency insepection of use_var_list and data_gen…
WorgenZhang Aug 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions python/paddle/fluid/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,73 @@ def set_use_var(self, var_list):
"Currently, fluid.dataset only supports dtype=float32, dtype=int32 and dtype=int64"
)

def check_use_var_with_data_generator(self, var_list, data_generator_class,
test_file):
"""
Var consistency insepection of use_var_list and data_generator data.

Examples:
.. code-block:: python

# required: skiptest
import paddle.fluid as fluid
from dataset_generator import CTRDataset
dataset = fluid.DatasetFactory().create_dataset()
generator_class = CTRDataset()
dataset.check_use_var_with_data_generator([data, label], generator_class, "data/part-00000")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do this check in dataSet's loadintomemory? Sometimes, it's not easy to reproduce the error by using just one file

Copy link
Contributor Author

@WorgenZhang WorgenZhang Aug 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++端是按slot逐个解析的(MultiSlotDataFeed::ParseOneInstance),解析到报错点就停了,然后报错点感觉也没法加更多更明显的信息,因为它解析出来的已经是错误的值了,感觉还是不如Python端报错更明显


Args:
var_list(list): variable list
data_generator_class(class): data_generator class
test_file(str): local test file path
"""

f = open(test_file, "r")
var_len = len(var_list)

while True:
line = f.readline()
if line:
line_iter = data_generator_class.generate_sample(line)
for user_parsed_line in line_iter():
data_gen_len = len(user_parsed_line)
if var_len != data_gen_len:
raise ValueError(
"var length mismatch error: var_list = %s vs data_generator = %s"
% (var_len, data_gen_len))

for i, ele in enumerate(user_parsed_line):
# print(ele[0], ele[1])

if len(ele[1]) == 0:
raise ValueError(
"var length error: var %s's length in data_generator is 0"
% ele[0])

if var_list[
i].dtype == core.VarDesc.VarType.FP32 and not all(
isinstance(ele, float) for ele in ele[1]):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. write var_list[i] in one line? 2. if not all(isinstance(ele,float)), you'd better pring ele out. otherwise, user doesn't know which element in the current line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. pre-commit format in this way...
  2. have already printed ele out, see "raise TypeError"

raise TypeError(
"var dtype mismatch error: var name = %s, var type in var_list = %s, while var in data_generator contains non-float value, which is %s \n"
"Please check if order of var_list and data_generator are aligned. \n"
"Please check if var's type in data_generator is correct."
% (ele[0], "float", ele[1]))

if (var_list[i].dtype == core.VarDesc.VarType.INT64 or
var_list[i].dtype == core.VarDesc.VarType.INT32
) and not all(
isinstance(ele, int) for ele in ele[1]):
raise TypeError(
"var dtype mismatch error: var name = %s, var type in var_list = %s, while var in data_generator contains non-int value, which is %s \n"
"Please check if order of var_list and data_generator are aligned. \n"
"Please check if var's type in data_generator is correct."
% (ele[0], "int", ele[1]))

else:
break

f.close()

def set_hdfs_config(self, fs_name, fs_ugi):
"""
Set hdfs config: fs name ad ugi
Expand Down
Loading