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 all 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
65 changes: 65 additions & 0 deletions python/paddle/distributed/fleet/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,71 @@ def _dynamic_adjust_before_train(self, thread_num):
def _dynamic_adjust_after_train(self):
pass

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
from dataset_generator import CTRDataset
dataset = paddle.distributed.fleet.DatasetBase()
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):
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]):
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()


class InMemoryDataset(DatasetBase):
"""
Expand Down
Loading