-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[CPU-PSLIB] Add consistency insepection of use_var_list and data_generator data, test=develop #34463
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 e05a7d6
[CPU-PSLIB] Add consistency insepection of use_var_list and data_gene…
WorgenZhang 733c9dc
[CPU-PSLIB] Add consistency insepection of use_var_list and data_gene…
WorgenZhang a8fb3dd
[CPU-PSLIB] Add consistency insepection of use_var_list and data_gene…
WorgenZhang 61f9514
Merge branch 'develop' of https://github.com/WorgenZhang/Paddle into …
WorgenZhang 0f5b7a0
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
WorgenZhang 3bb1fd3
Merge branch 'PaddlePaddle:develop' into fan-dev
WorgenZhang 628d8eb
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
WorgenZhang 01113dd
Merge branch 'develop' of https://github.com/WorgenZhang/Paddle into …
WorgenZhang 7d8db62
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
WorgenZhang a375b2c
Merge branch 'PaddlePaddle:develop' into fan-dev
WorgenZhang 09d1a81
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
WorgenZhang f485502
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
WorgenZhang 9d222e7
[CPU-PSLIB] Add Unitest For: consistency insepection of use_var_list …
WorgenZhang 327eddc
Merge branch 'fan-dev' of https://github.com/WorgenZhang/Paddle into …
WorgenZhang 493c91f
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
WorgenZhang b1123e9
[CPU-PSLIB] Add Unitest For: consistency insepection of use_var_list …
WorgenZhang 6b8d16a
[CPU-PSLIB] Add Unitest For: consistency insepection of use_var_list…
WorgenZhang 9aafded
[CPU-PSLIB] Add Unitest For: consistency insepection of use_var_list…
WorgenZhang 9f96612
[CPU-PSLIB] Add Unitest For: consistency insepection of use_var_list…
WorgenZhang f84da1c
[CPU-PSLIB] Add Unitest For: consistency insepection of use_var_list…
WorgenZhang a4713d6
[CPU-PSLIB] Add consistency insepection of use_var_list and data_gen…
WorgenZhang a5da0d6
[CPU-PSLIB] Add consistency insepection of use_var_list and data_gen…
WorgenZhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") | ||
|
||
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]): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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端报错更明显