From 3ce7082c07802f5e86e61f5e9fa09ea0e60d95d6 Mon Sep 17 00:00:00 2001 From: Zeref996 <53218160+Zeref996@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:28:21 +0800 Subject: [PATCH] plt fix builder_data (#3000) * plt update, test=model * plt update, test=model * plt update, test=model * plt update testing reporter, test=model * plt update testing reporter, test=model * plt update testing reporter, test=model * plt update test reporter, test=model * plt update test reporter, test=model * plt update test reporter, test=model * plt update test reporter, test=model * plt update test reporter, test=model * plt update test reporter, test=model * plt add pr_info * plt fix ocr case, test=model * plt fix ocr case, test=model * plt add nlp case, test=model * plt add nlp case, test=model * plt add nlp case, test=model * plt add nlp case, test=model * plt add nlp case, test=model * plt add more nlp case, test=model * plt add more nlp case, test=model * plt add nlp, test=model * plt fix case, test=model * fix plt builder data, test=model * fix plt builder data, test=model * fix plt builder data, test=model --- .../PaddleLT_new/generator/builder_data.py | 5 ++- .../layerNLPcase/debug/__init__.py | 18 ++++++++ .../layerNLPcase/debug/case_bug/__init__.py | 18 ++++++++ .../debug/case_bug/transformers/__init__.py | 18 ++++++++ .../transformers/layoutlmv2/__init__.py | 2 +- .../layoutlmv2/layoutlmv2_model.py | 16 ++++---- .../transformers/layoutxlm/__init__.py | 2 +- .../transformers/layoutxlm/layoutxlm_model.py | 19 ++++----- .../transformers/reformer/__init__.py | 2 +- .../layerNLPcase/debug/real_bug/__init__.py | 18 ++++++++ .../PaddleLT_new/layerNLPcase/llm/__init__.py | 15 +++++++ .../llm/meta_llama_Llama_2_7b_chat.py | 30 ++++++++++++++ .../transformers/layoutlm/layoutlm_model.py | 41 +++++++++++++++++++ .../transformers/layoutlmv2/__init__.py | 15 +++++++ .../layoutlmv2/layoutlmv2_model.py | 41 +++++++++++++++++++ .../transformers/layoutxlm/__init__.py | 15 +++++++ .../transformers/layoutxlm/layoutxlm_model.py | 38 +++++++++++++++++ .../layerOCRcase/debug/__init__.py | 18 ++++++++ .../layerOCRcase/debug/case_bug/__init__.py | 18 ++++++++ .../debug/case_bug/backbones/__init__.py | 15 +++++++ 20 files changed, 341 insertions(+), 23 deletions(-) create mode 100644 framework/e2e/PaddleLT_new/layerNLPcase/debug/__init__.py create mode 100644 framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/__init__.py create mode 100644 framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/__init__.py create mode 100644 framework/e2e/PaddleLT_new/layerNLPcase/debug/real_bug/__init__.py create mode 100644 framework/e2e/PaddleLT_new/layerNLPcase/llm/__init__.py create mode 100644 framework/e2e/PaddleLT_new/layerNLPcase/llm/meta_llama_Llama_2_7b_chat.py create mode 100644 framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlm/layoutlm_model.py create mode 100644 framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlmv2/__init__.py create mode 100644 framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlmv2/layoutlmv2_model.py create mode 100644 framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutxlm/__init__.py create mode 100644 framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutxlm/layoutxlm_model.py create mode 100644 framework/e2e/PaddleLT_new/layerOCRcase/debug/__init__.py create mode 100644 framework/e2e/PaddleLT_new/layerOCRcase/debug/case_bug/__init__.py create mode 100644 framework/e2e/PaddleLT_new/layerOCRcase/debug/case_bug/backbones/__init__.py diff --git a/framework/e2e/PaddleLT_new/generator/builder_data.py b/framework/e2e/PaddleLT_new/generator/builder_data.py index c31334d499..919bfee9e4 100644 --- a/framework/e2e/PaddleLT_new/generator/builder_data.py +++ b/framework/e2e/PaddleLT_new/generator/builder_data.py @@ -68,11 +68,14 @@ def get_single_data(self): data.append(torch.tensor(i, requires_grad=False)) else: data.append(torch.tensor(i, requires_grad=True)) + elif isinstance(i, float): + data.append(paddle.to_tensor(i, stop_gradient=False)) + elif isinstance(i, int): + data.append(paddle.to_tensor(i, stop_gradient=True)) else: data.append(i) else: data = self.get_single_tensor() - return data def get_single_tensor(self): diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/__init__.py new file mode 100644 index 0000000000..202014bc34 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/__init__.py @@ -0,0 +1,18 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的文件夹路径(注意:这里不需要尾随的斜杠) +folders = glob.glob(os.path.join(current_dir, '*')) + +# 过滤出文件夹(排除文件) +folders = [folder for folder in folders if os.path.isdir(folder) and not os.path.basename(folder) == '__pycache__'] + +# 动态导入所有 .py 文件 +for folder in folders: + # 获取文件名(不含扩展名) + module_name = os.path.basename(folder) + # 导入模块 + __import__('layerNLPcase.debug.' + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/__init__.py new file mode 100644 index 0000000000..116ae737d3 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/__init__.py @@ -0,0 +1,18 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的文件夹路径(注意:这里不需要尾随的斜杠) +folders = glob.glob(os.path.join(current_dir, '*')) + +# 过滤出文件夹(排除文件) +folders = [folder for folder in folders if os.path.isdir(folder) and not os.path.basename(folder) == '__pycache__'] + +# 动态导入所有 .py 文件 +for folder in folders: + # 获取文件名(不含扩展名) + module_name = os.path.basename(folder) + # 导入模块 + __import__('layerNLPcase.debug.case_bug.' + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/__init__.py new file mode 100644 index 0000000000..93dfc54054 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/__init__.py @@ -0,0 +1,18 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的文件夹路径(注意:这里不需要尾随的斜杠) +folders = glob.glob(os.path.join(current_dir, '*')) + +# 过滤出文件夹(排除文件) +folders = [folder for folder in folders if os.path.isdir(folder) and not os.path.basename(folder) == '__pycache__'] + +# 动态导入所有 .py 文件 +for folder in folders: + # 获取文件名(不含扩展名) + module_name = os.path.basename(folder) + # 导入模块 + __import__('layerNLPcase.debug.case_bug.transformers.' + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/__init__.py index cc048992ad..67e8b62f17 100644 --- a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/__init__.py +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/__init__.py @@ -12,4 +12,4 @@ # 获取文件名(不含扩展名) module_name = os.path.basename(py_file)[:-3] # 导入模块 - __import__("layerNLPcase.transformers.layoutlmv2." + module_name, globals(), locals(), []) + __import__("layerNLPcase.debug.case_bug.transformers.layoutlmv2." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/layoutlmv2_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/layoutlmv2_model.py index 2388263b2b..5eeb853370 100644 --- a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/layoutlmv2_model.py +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/layoutlmv2_model.py @@ -10,8 +10,8 @@ def LayerCase(): def create_inputspec(): inputspec = ( paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), - None, - None, + paddle.static.InputSpec(shape=(-1, 13, 4), dtype=paddle.int64, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 3, 224, 224), dtype=paddle.float32, stop_gradient=False), paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), ) return inputspec @@ -21,10 +21,10 @@ def create_tensor_inputs(): tokenizer = LayoutLMv2Tokenizer.from_pretrained('layoutlmv2-base-uncased') inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") inputs = ( - paddle.to_tensor(inputs_dict['input_ids'], stop_gradient=False), - None, - None, - paddle.to_tensor(inputs_dict['token_type_ids'], stop_gradient=False), + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.to_tensor(np.random.random((1, 13, 4)).astype("int64"), stop_gradient=False), + paddle.to_tensor(np.random.random((1, 3, 224, 224)), stop_gradient=False), + paddle.to_tensor([inputs_dict['token_type_ids']], stop_gradient=False), ) return inputs @@ -34,8 +34,8 @@ def create_numpy_inputs(): inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") inputs = ( np.array([inputs_dict['input_ids']]), - None, - None, + np.random.random((1, 13, 4)).astype("int64"), + np.random.random((1, 3, 224, 224)), np.array([inputs_dict['token_type_ids']]), ) return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutxlm/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutxlm/__init__.py index 2c2523d753..680329673d 100644 --- a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutxlm/__init__.py +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutxlm/__init__.py @@ -12,4 +12,4 @@ # 获取文件名(不含扩展名) module_name = os.path.basename(py_file)[:-3] # 导入模块 - __import__("layerNLPcase.transformers.layoutxlm." + module_name, globals(), locals(), []) + __import__("layerNLPcase.debug.case_bug.transformers.layoutxlm." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutxlm/layoutxlm_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutxlm/layoutxlm_model.py index 3cfe1eab89..894c31cce0 100644 --- a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutxlm/layoutxlm_model.py +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutxlm/layoutxlm_model.py @@ -9,10 +9,9 @@ def LayerCase(): def create_inputspec(): inputspec = ( - paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), - None, - None, - paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15, 4), dtype=paddle.int64, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 3, 224, 224), dtype=paddle.float32, stop_gradient=False), ) return inputspec @@ -21,10 +20,9 @@ def create_tensor_inputs(): tokenizer = LayoutXLMTokenizer.from_pretrained('layoutxlm-base-uncased') inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") inputs = ( - paddle.to_tensor(inputs_dict['input_ids'], stop_gradient=False), - None, - None, - paddle.to_tensor(inputs_dict['token_type_ids'], stop_gradient=False), + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.to_tensor(np.random.random((1, 15, 4)).astype("int64"), stop_gradient=False), + paddle.to_tensor(np.random.random((1, 3, 224, 224)), stop_gradient=False), ) return inputs @@ -34,8 +32,7 @@ def create_numpy_inputs(): inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") inputs = ( np.array([inputs_dict['input_ids']]), - None, - None, - np.array([inputs_dict['token_type_ids']]), + np.random.random((1, 15, 4)).astype("int64"), + np.random.random((1, 3, 224, 224)), ) return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/reformer/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/reformer/__init__.py index 7b9329543b..1deb7e2789 100644 --- a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/reformer/__init__.py +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/reformer/__init__.py @@ -12,4 +12,4 @@ # 获取文件名(不含扩展名) module_name = os.path.basename(py_file)[:-3] # 导入模块 - __import__("layerNLPcase.transformers.reformer." + module_name, globals(), locals(), []) + __import__("layerNLPcase.debug.case_bug.transformers.reformer." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/real_bug/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/real_bug/__init__.py new file mode 100644 index 0000000000..133e7d1f5f --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/real_bug/__init__.py @@ -0,0 +1,18 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的文件夹路径(注意:这里不需要尾随的斜杠) +folders = glob.glob(os.path.join(current_dir, '*')) + +# 过滤出文件夹(排除文件) +folders = [folder for folder in folders if os.path.isdir(folder) and not os.path.basename(folder) == '__pycache__'] + +# 动态导入所有 .py 文件 +for folder in folders: + # 获取文件名(不含扩展名) + module_name = os.path.basename(folder) + # 导入模块 + __import__('layerNLPcase.debug.real_bug.' + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/llm/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/llm/__init__.py new file mode 100644 index 0000000000..b0c0abf450 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/llm/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.llm." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/llm/meta_llama_Llama_2_7b_chat.py b/framework/e2e/PaddleLT_new/layerNLPcase/llm/meta_llama_Llama_2_7b_chat.py new file mode 100644 index 0000000000..8178956ca3 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/llm/meta_llama_Llama_2_7b_chat.py @@ -0,0 +1,30 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AutoModelForCausalLM, AutoTokenizer + +def LayerCase(): + """模型库中间态""" + model = AutoModelForCausalLM.from_pretrained('meta-llama/Llama-2-7b-chat') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 14), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 14), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 14), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AutoTokenizer.from_pretrained('meta-llama/Llama-2-7b-chat') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AutoTokenizer.from_pretrained('meta-llama/Llama-2-7b-chat') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlm/layoutlm_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlm/layoutlm_model.py new file mode 100644 index 0000000000..dc82bfffad --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlm/layoutlm_model.py @@ -0,0 +1,41 @@ +import paddle +import numpy as np +from paddlenlp.transformers import LayoutLMModel, LayoutLMTokenizer + +def LayerCase(): + """模型库中间态""" + model = LayoutLMModel.from_pretrained('layoutlm-base-uncased') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 13, 4), dtype=paddle.int64, stop_gradient=False), + # paddle.static.InputSpec(shape=(-1, 3, 224, 224), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = LayoutLMTokenizer.from_pretrained('layoutlm-base-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.to_tensor(np.random.random((1, 13, 4)).astype("int64"), stop_gradient=False), + # paddle.to_tensor(np.random.random((1, 3, 224, 224)), stop_gradient=False), + paddle.to_tensor([inputs_dict['token_type_ids']], stop_gradient=False), + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = LayoutLMTokenizer.from_pretrained('layoutlm-base-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + np.array([inputs_dict['input_ids']]), + np.random.random((1, 13, 4)).astype("int64"), + # np.random.random((1, 3, 224, 224)), + np.array([inputs_dict['token_type_ids']]), + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlmv2/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlmv2/__init__.py new file mode 100644 index 0000000000..cc048992ad --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlmv2/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.transformers.layoutlmv2." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlmv2/layoutlmv2_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlmv2/layoutlmv2_model.py new file mode 100644 index 0000000000..5eeb853370 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlmv2/layoutlmv2_model.py @@ -0,0 +1,41 @@ +import paddle +import numpy as np +from paddlenlp.transformers import LayoutLMv2Model, LayoutLMv2Tokenizer + +def LayerCase(): + """模型库中间态""" + model = LayoutLMv2Model.from_pretrained('layoutlmv2-base-uncased') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 13, 4), dtype=paddle.int64, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 3, 224, 224), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = LayoutLMv2Tokenizer.from_pretrained('layoutlmv2-base-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.to_tensor(np.random.random((1, 13, 4)).astype("int64"), stop_gradient=False), + paddle.to_tensor(np.random.random((1, 3, 224, 224)), stop_gradient=False), + paddle.to_tensor([inputs_dict['token_type_ids']], stop_gradient=False), + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = LayoutLMv2Tokenizer.from_pretrained('layoutlmv2-base-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + np.array([inputs_dict['input_ids']]), + np.random.random((1, 13, 4)).astype("int64"), + np.random.random((1, 3, 224, 224)), + np.array([inputs_dict['token_type_ids']]), + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutxlm/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutxlm/__init__.py new file mode 100644 index 0000000000..2c2523d753 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutxlm/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.transformers.layoutxlm." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutxlm/layoutxlm_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutxlm/layoutxlm_model.py new file mode 100644 index 0000000000..894c31cce0 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutxlm/layoutxlm_model.py @@ -0,0 +1,38 @@ +import paddle +import numpy as np +from paddlenlp.transformers import LayoutXLMModel, LayoutXLMTokenizer + +def LayerCase(): + """模型库中间态""" + model = LayoutXLMModel.from_pretrained('layoutxlm-base-uncased') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15, 4), dtype=paddle.int64, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 3, 224, 224), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = LayoutXLMTokenizer.from_pretrained('layoutxlm-base-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.to_tensor(np.random.random((1, 15, 4)).astype("int64"), stop_gradient=False), + paddle.to_tensor(np.random.random((1, 3, 224, 224)), stop_gradient=False), + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = LayoutXLMTokenizer.from_pretrained('layoutxlm-base-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + np.array([inputs_dict['input_ids']]), + np.random.random((1, 15, 4)).astype("int64"), + np.random.random((1, 3, 224, 224)), + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerOCRcase/debug/__init__.py b/framework/e2e/PaddleLT_new/layerOCRcase/debug/__init__.py new file mode 100644 index 0000000000..27757aa82e --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerOCRcase/debug/__init__.py @@ -0,0 +1,18 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的文件夹路径(注意:这里不需要尾随的斜杠) +folders = glob.glob(os.path.join(current_dir, '*')) + +# 过滤出文件夹(排除文件) +folders = [folder for folder in folders if os.path.isdir(folder) and not os.path.basename(folder) == '__pycache__'] + +# 动态导入所有 .py 文件 +for folder in folders: + # 获取文件名(不含扩展名) + module_name = os.path.basename(folder) + # 导入模块 + __import__('layerOCRcase.debug.' + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerOCRcase/debug/case_bug/__init__.py b/framework/e2e/PaddleLT_new/layerOCRcase/debug/case_bug/__init__.py new file mode 100644 index 0000000000..c2877dbe86 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerOCRcase/debug/case_bug/__init__.py @@ -0,0 +1,18 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的文件夹路径(注意:这里不需要尾随的斜杠) +folders = glob.glob(os.path.join(current_dir, '*')) + +# 过滤出文件夹(排除文件) +folders = [folder for folder in folders if os.path.isdir(folder) and not os.path.basename(folder) == '__pycache__'] + +# 动态导入所有 .py 文件 +for folder in folders: + # 获取文件名(不含扩展名) + module_name = os.path.basename(folder) + # 导入模块' + __import__('layerOCRcase.debug.case_bug.' + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerOCRcase/debug/case_bug/backbones/__init__.py b/framework/e2e/PaddleLT_new/layerOCRcase/debug/case_bug/backbones/__init__.py new file mode 100644 index 0000000000..4c661a1fc4 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerOCRcase/debug/case_bug/backbones/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerOCRcase.debug.case_bug.backbones." + module_name, globals(), locals(), [])